Callback Manager
Many of the modules needs a provision to signal other modules via callback mechanism. RAPIDSEA provides a callback manager to achieve the same.
Typically the module (“source module”) that wants to implement the callback functionality can initialize the manager with rs_callback_mgr_init function with the memory needed for storing the functions and the maximum number of callbacks that can be registered. Any other module that wants to register for an notification, can call the rs_callback_mgr_register function to register along with optional argument. When the source module wants to send the notification, it can invoke all the call back functions via RS_CALLBACK_MGR_FOR_ALL_CALL_ARG1 or RS_CALLBACK_MGR_FOR_ALL_CALL_ARG2 macros. The modules can deregister themselves using the rs_callback_mgr_unregister function.
Callback Manager Header
Documentation from the relevant header as follows:
Definitions for RAPIDSEA Callback Manager.
Defines
-
RS_CALLBACK_MGR_FOR_ALL_CALL_ARG1(ptr_mgr, cast, arg1)
Macro to invoke callback function with one argument
-
RS_CALLBACK_MGR_FOR_ALL_CALL_ARG2(ptr_mgr, cast, arg1, arg2)
Macro to invoke callback function with two arguments
-
RS_CALLBACK_MGR_CALL_ARG2_FOR_INDEX(ptr_mgr, cast, arg1, arg2, u32_index)
Macro to invoke callback function with two arguments for u32_index variable
Typedefs
-
typedef struct tag_rs_callback_info rs_callback_info_t
Structure to hold information about one callback
-
typedef struct tag_rs_callback_mgr rs_callback_mgr_t
Structure to hold information about the callback manager
Functions
-
rs_ret_val_t rs_callback_mgr_init(rs_callback_mgr_t *ptr_mgr, rs_callback_info_t *ptr_list, uint32_t u32_count)
Initializes the callback manager.
This function initializes the callback manager with the given memory area and maximum number of callbacks functions that can be registered
Initializes the callback manager.
- Parameters:
ptr_mgr – [in] - Pointer to the callback manager memory
ptr_list – [in] - Array of rs_callback_info_t structures, pre-allocated by the caller
u32_count – [in] - Number of the array elements, that represents the maximum number of callbacks that can be registered with this manager
- Returns:
Zero for success or negative error code
-
rs_ret_val_t rs_callback_mgr_register(rs_callback_mgr_t *ptr_mgr, void *ptr_func, void *ptr_arg)
Register the given function with the callback manager.
This function is used to register the given callback function along with the context information with the manager
- Parameters:
ptr_mgr – [in] - Pointer to the callback manager
ptr_func – [in] - Pointer to callback function
ptr_arg – [in] - Argument with which the callback function is to be invoked
- Returns:
Zero for success or negative error code
-
rs_ret_val_t rs_callback_mgr_unregister(rs_callback_mgr_t *ptr_mgr, void *ptr_func)
Un-registers the given function.
This function is used to un-register the given callback function
- Parameters:
ptr_mgr – [in] - Pointer to the callback manager
ptr_func – [in] - Pointer to callback function
- Returns:
Zero for success or negative error code
-
struct tag_rs_callback_info
- #include <rs_callback_mgr.h>
Structure to hold information about one callback
-
struct tag_rs_callback_mgr
- #include <rs_callback_mgr.h>
Structure to hold information about the callback manager
Public Members
-
uint32_t num_callbacks
Maximum Number of callbacks.
-
rs_callback_info_t *arr_callbacks
Pointer to callback information.
-
uint32_t num_callbacks