Handle Manager
During the course of application execution, there will be multiple structures and pointers associated with hardware interfaces and modules. Rather than handling the pointer information directly, it might be a better idea to access them via logical numbers called handles. The handle manager provides such a mechanism to abstract private information by creating handles and managing them.
Typically the module that wants to abstract the information, can use the rs_handle_mgr_get_handle function to pass the pointer to be abstracted and get a handle to the same. This handle can be passed to other modules. Whenever the original information is needed, any module can use rs_handle_mgr_get_info_for_handle call to get the private information. When the purpose of using handle is over, the same can be released using rs_handle_mgr_free_handle function.
Handle Manager Header
Documentation from the relevant header as follows:
Definitions for RAPIDSEA Handle Manager.
Functions
-
rs_ret_val_t rs_handle_mgr_init()
Function to init handle manager.
This function initialises the handle manager
- Returns:
0 or error code
-
rs_handle_t rs_handle_mgr_get_handle(void *ptr_info)
Assigns a handle for given information.
This function allocates and assigns a new handle for the given information, which can be later retrieved
- Parameters:
ptr_info – [in] - Information Pointer
- Returns:
Handle to the information or negative error code
-
void *rs_handle_mgr_get_info_for_handle(rs_handle_t handle)
Returns the information corresponding to the given handle.
This function returns the information registered for the given handle
- Parameters:
handle – [in] - Handle
- Returns:
Pointer to the information or NULL
-
rs_ret_val_t rs_handle_mgr_free_handle(rs_handle_t handle)
Frees the given handle.
This function frees the given handle
- Parameters:
handle – [in] - Handle to be freed
- Returns:
Zero or negative error code