draw class diagram for class BufMgr_BufferManager
{
public:
/***********************************************************************************************************************
* \fn BufMgr_BufferManager
* \brief Constructor of class BufMgr_BufferManager
* \param [out] ret_value: e_bufmngr_return_t
* RETURN_BUFMNGR_OK if all went well
* RETURN_BUFMNGR_ERROR_INTERNAL_PTR , while type_enu given is equal to R_HWA_BUFMNGR_NOT_INIT
* RETURN_BUFMNGR_ERROR_INTERNAL_STATE, while the current process has already an internal implementation
* defined
*\param [in] type_enu: Type of the Buffer Manager to be instantiated, \return None
**********************************************************************************************************************/
BufMgr_BufferManager(e_bufmngr_return_t * ret_value,
e_bufmngr_multiprocess_type_t type_enu = R_HWA_BUFMNGR_AUTOMATIC);
/***********************************************************************************************************************
* \fn ~BufMgr_BufferManage
* \brief Destructor of class BufMgr_BufferManager
* \param None
* \return None
**********************************************************************************************************************/
virtual ~BufMgr_BufferManager();
/***********************************************************************************************************************
* \fn R_BufMgr_Init
* \brief Initialisation method for buffer manager.
* \param [in] bufmngr_json_config: Path to json file with pool memory configuration.
* \param [in] comal_json_config: Path to json file of COMAL configuration.
* \return e_bufmngr_return_t
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_INIT_DONE if buffer manager is already initialized
* \retval RETURN_BUFMNGR_ERROR_USER_ID if limit of buffer manager instances (users) has been reached.
* \retval RETURN_BUFMNGR_ERROR_FACTORY_CONFIG if factory JSON configuration is incomplete
* (server and single process implementation)
* \retval RETURN_BUFMNGR_ERROR_MUTEX_CREATE if an error occurred when creating a mutex
* \retval RETURN_BUFMNGR_ERROR_MMNGR_CONFIG if HWA memory manager JSON configuration is incomplete
* (server and single process implementation)
* \retval RETURN_BUFMNGR_ERROR_COMAL_CONFIG if COMAL JSON configuration is incomplete
* (server and client implementation)
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while trying to connect to server
* (client implementation)
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while starting a server
* (server implementation)
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_Init(std::string bufmngr_json_config, std::string comal_json_config = std::string(""));
/***********************************************************************************************************************
* \fn R_BufMgr_InitByJsonString
* \brief Initialisation method for buffer manager.
* \param [in] bufmngr_json_contents: String that defines the OSAL resource configuration in JSON format.
* \param [in] comal_json_contents: String that defines the COMAL configuration in JSON format.
* \return e_bufmngr_return_t
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_INIT_DONE if buffer manager is already initialized
* \retval RETURN_BUFMNGR_ERROR_USER_ID if limit of buffer manager instances (users) has been reached.
* \retval RETURN_BUFMNGR_ERROR_FACTORY_CONFIG if factory JSON configuration is incomplete
* (server and single process implementation)
* \retval RETURN_BUFMNGR_ERROR_MUTEX_CREATE if an error occurred when creating a mutex
* \retval RETURN_BUFMNGR_ERROR_MMNGR_CONFIG if HWA memory manager JSON configuration is incomplete
* (server and single process implementation)
* \retval RETURN_BUFMNGR_ERROR_COMAL_CONFIG if COMAL JSON configuration is incomplete
* (server and client implementation)
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while trying to connect to server
* (client implementation)
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while starting a server
* (server implementation)
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
* \retval RETURN_BUFMNGR_ERROR_NOT_SUPPORT if the type of the instanced buffer Manager is not R_HWA_BUFMNGR_MULTI_PROCESS_CLIENT
* (server implementation)
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_InitByJsonString(const std::string & bufmngr_json_contents,
const std::string & comal_json_contents = std::string(""));
/***********************************************************************************************************************
* \fn R_BufMgr_Close
* \brief Close method for buffer manager.
* \param None
* \return e_bufmngr_return_t
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_NOT_INIT if buffer manager is not already initialized
* \retval RETURN_BUFMNGR_ERROR_OWNER_ID if buffer manager instance is not the one that initialized buffer manager
* \retval RETURN_BUFMNGR_ERROR_CONT_DELETE if containers are still alive in buffer manager.
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred with COMAL: IPC communication, server termination.
* (multi process only)
* \retval RETURN_BUFMNGR_ERROR_DISPATCHER if an error occurred while closing server.
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_Close() const;
/***********************************************************************************************************************
* \fn R_BufMgr_CreateContainer
* \brief Method to create a container inside buffer manager.
* \param [in] configParameter: Class which stores container configuration
* \param [out] p_container_id: Id of created container
* \return e_bufmngr_return_t
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_NOT_INIT if buffer manager is not already initialized
* \retval RETURN_BUFMNGR_ERROR_USER_ID if limit of buffer manager instances (users) has been reached.
* \retval RETURN_BUFMNGR_ERROR_NOT_IMPL if container type given is not supported.
* Types CONTAINER_TYPE_MULTIVA and CONTAINER_TYPE_SINGLEVA are not supported
* \retval RETURN_BUFMNGR_ERROR_CONT_CONFIG issue with container configuration:
* - if container type given is invalid. (only CONTAINER_TYPE_PHYSIC is supported for this release)
* - (For client only) if pool name contains too many characters (see BufMgr_ConfigParameter class)
* \retval RETURN_BUFMNGR_ERROR_CONT_ID if getting a new ID container failed (eg: limit of container reached,
* current limit is 500).
* \retval RETURN_BUFMNGR_ERROR_BUFFER_ALLOC error occurred when allocating memory with HWA memory manager.
* possible issues:
* - memory limit reached
* - Memory alignment must be higher or equal to 4KB
* - Memory alignment must be a multiple of 4KB
* - Buffer size must be higher or equal to memory alignment
* - Buffer size must a multiple of memory alignment
* \retval RETURN_BUFMNGR_ERROR_MMNGR_POOL_OPEN if pool name was not found
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while communicating with server
* (client implementation)
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_CreateContainer(const BufMgr_ConfigParameter configParameter, int * p_container_id);
/***********************************************************************************************************************
* \fn R_BufMgr_DeleteContainer
* \brief Method to delete a container inside buffer manager.
* \param [in] container_id: Id of container to delete
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_NOT_INIT if buffer manager is not already initialized
* \retval RETURN_BUFMNGR_ERROR_CONT_ID - if given container ID couldn't be found
* - if buffer manager instance didn't created the container (is not the owner)
* \retval RETURN_BUFMNGR_ERROR_STILL_REGISTER if at least one user is still registered to this container.
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while communicating with server
* (client implementation)
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_DeleteContainer(int container_id);
/***********************************************************************************************************************
* \fn R_BufMgr_GetBufferHandle
* \brief Method to get a buffer handle inside buffer manager
* \param [in] container_id: Id of container which stores required buffer
* \param [in] buffer_id: Id of buffer inside container
* \param [out] ptr_buffer: Handle of required buffer
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_NOT_INIT if buffer manager is not already initialized
* \retval RETURN_BUFMNGR_ERROR_CONT_ID if given container ID couldn't be found
* \retval RETURN_BUFMNGR_ERROR_BUFFER_ID if buffer index couldn't be found in container (out of range)
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while communicating with server
* (client implementation)
* \retval RETURN_BUFMNGR_ERROR_NOT_REGISTER_ID this instance needs to register to container before trying to access
* it.
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_GetBufferHandle(int container_id, int buffer_id, BufMgr_Buffer *& ptr_buffer) const;
/***********************************************************************************************************************
* \fn R_BufMgr_Swap
* \brief Method to update buffer configuration in multi-buffering
* \param [in] container : index of container affected by swap operation.
* \param [in] axi_id : Axi_id whose buffer configuration needs to be updated.
* \return e_bufmngr_return_t,
* RETURN_BUFMNGR_OK if all went well
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_Swap(int container_id, osal_axi_bus_id_t axi_id) const;
/***********************************************************************************************************************
* \fn R_BufMgr_Swap
* \brief Method to update all buffers configuration in multi-buffering container.
* \param [in] container : index of container affected by swap operation.
* \return e_bufmngr_return_t,
* RETURN_BUFMNGR_OK if all went well
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_Swap(int container_id) const;
/***********************************************************************************************************************
* \fn R_BufMgr_GetMemoryUsage
* \brief Get current memory usage (in bytes) for a memory manager object. This function is only working in server
* process or while using single process.
* \param [out] memoryUsage : Reference on memory usage struct
* \return e_bufmngr_return_t
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_NOT_INIT if buffer manager is not already initialized
* \retval RETURN_BUFMNGR_ERROR_MMNGR if error happened while retrieving memory usage from HWA memory manager
* \retval RETURN_BUFMNGR_ERROR_NOT_IMPL if not method is not implemented (case for a client process)
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
**********************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_GetMemoryUsage(st_hwa_mmngr_mem_usage * memoryUsage) const;
/*******************************************************************************************************************
* \fn R_BufMgr_RegisterToContainer
* \brief Register to a buffer manager container object
* \param [in] container_id: ID of the buffer manager container.
* \param [out] ptr_cont_info : Pointer on a structure to store container information.
* \return e_bufmngr_return_t
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_NOT_INIT if buffer manager is not already initialized
* \retval RETURN_BUFMNGR_ERROR_USER_ID if limit of buffer manager instances (users) has been reached.
* \retval RETURN_BUFMNGR_ERROR_CONT_ID if given container ID couldn't be found
* \retval RETURN_BUFMNGR_ERROR_OWNER_ID returned if the instance that created this container tries to register.
* This instance is automatically registered and does't need to unregister.
* \retval RETURN_BUFMNGR_ERROR_REGISTER_ID returned if an instance tries to register to a container more than once.
* \retval RETURN_BUFMNGR_ERROR_NULL_PARAM if pointer given is input is equal to a null pointer.
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while communicating with server
* (client implementation)
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
******************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_RegisterToContainer(int container_id, s_bufmngr_container_info_t * ptr_cont_info);
/*******************************************************************************************************************
* \fn R_BufMgr_UnregisterFromContainer
* \brief Unregister from a buffer manager container object
* \param [in] container_id: ID of the buffer manager container.
* \return e_bufmngr_return_t
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_NOT_INIT if buffer manager is not already initialized
* \retval RETURN_BUFMNGR_ERROR_CONT_ID if given container ID couldn't be found
* \retval RETURN_BUFMNGR_ERROR_OWNER_ID returned if the instance that created this container tries to unregister.
* This instance is automatically registered and does't need to unregister.
* \retval RETURN_BUFMNGR_ERROR_NOT_REGISTER_ID returned if an instance tries to register without being registered.
* \retval RETURN_BUFMNGR_ERROR_COMAL if an error occurred while communicating with server
* (client implementation)
* \retval RETURN_BUFMNGR_ERROR_INTERNAL_PTR if internal pointer has been invalidated since instance creation
* (eg: after calling buffer manager close method)
******************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_UnregisterFromContainer(int container_id) const;
/*******************************************************************************************************************
* \fn R_BufMgr_GetNextBufferHandler
* \brief This function returns a buffer handle and the index of the buffer inside the container.
* \param [in] container_id: ID of the buffer manager container.
* \param [out] buffer_id: pointer on index of buffer returned by Buffer Manager to user.
* \param [out] ptr_buffer: pointer on buffer handle returned by Buffer Manager to user.
* \return e_bufmngr_return_t
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_CONT_ID if the container given is not managed by this instance.
* \retval RETURN_BUFMNGR_ERROR_NO_BUFFER_AVAILABLE if all buffers in given container are busy.
******************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_GetNextBufferHandler(int container_id, int * buffer_id, BufMgr_Buffer ** ptr_buffer);
/*******************************************************************************************************************
* \fn R_BufMgr_ReleaseBufferHandler
* \brief This function releases a buffer handle that was taken with method R_BufMgr_GetNextBufferHandle.
* \param [in] Container_id: container ID indicated by user to Buffer Manager
* \param [in] buffer_id: buffer id to release indicated by user to Buffer Manager
* \retval RETURN_BUFMNGR_OK if all went well
* \retval RETURN_BUFMNGR_ERROR_CONT_ID if the container given is not managed by this instance.
* \retval RETURN_BUFMNGR_ERROR_RELEASING_UNUSED_BUFFER if given buffer is not in busy state.
* \retval RETURN_BUFMNGR_ERROR_BUFFER_ID if buffer ID does not belong to container.
******************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_ReleaseBufferHandler(int container_id, int buffer_id);
/*******************************************************************************************************************
* \fn R_BufMgr_SetConfigLink
* \brief This function reconfigure virtual address with IPMMU.
* \param [in] Container_id: container ID indicated by user to Buffer Manager
* \param [in] links: a list of new link object
* \retval RETURN_BUFMNGR_OK if all went well
******************************************************************************************************************/
e_bufmngr_return_t R_BufMgr_SetConfigLink(int container_id, std::list<ConfigLink> links);
/***********************************************************************************************************************
* \fn R_BufMgr_GetId
* \brief Getter method for member m_manager_id.
* \param None
* \return int, ID of buffer manager.
**********************************************************************************************************************/
int R_BufMgr_GetId() const;
/*Assignment operator deleted*/
void operator=(const BufMgr_BufferManager &) = delete;
/* Copy constructor deleted */
BufMgr_BufferManager(const BufMgr_BufferManager &) = delete;
/* Clone method deleted */
BufMgr_BufferManager(BufMgr_BufferManager &) = delete;
private:
/* Private ID used by buffer manager factory to identify buffer manager instance /
int m_manager_id;
/ Pointer to internal implementation Class /
BufferManagerInternal * m_managerInternal;
/ Internal map to store buffer state Handler object */
std::map<int, BufferStateHandler *> m_map_handler;
/***********************************************************************************************************************
* \fn checkInternalPtr
* \brief Private method to check the validity of the stored pointer to Internal implementation
* \param None
* \return e_bufmngr_return_t,
* RETURN_BUFMNGR_OK if all went well
**********************************************************************************************************************/
e_bufmngr_return_t checkInternalPtr() const;
};