Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@
"ut_control_plane.h": "c",
"ut.h": "c",
"ut_log.h": "c",
"tuple": "c"
"tuple": "c",
"array": "c",
"compare": "c",
"functional": "c",
"type_traits": "c",
"utility": "c",
"istream": "c",
"ostream": "c"
},
"cmake.configureOnOpen": true
}
44 changes: 44 additions & 0 deletions include/ut_control_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,34 @@ typedef struct
typedef void ut_controlPlane_instance_t; /*!< Handle to a control plane instance */

/** @brief Callback function type for handling control plane messages. */
/**
* @typedef ut_control_callback_t
* @brief A callback function type for handling control operations.
*
* This callback function is called with a key, an instance of ut_kvp_instance_t,
* and user-defined data.
*
* @param key The key associated with the control operation.
* @param instance A pointer to a ut_kvp_instance_t instance.
* @param userData A pointer to user-defined data.
*/
typedef void (*ut_control_callback_t)( char *key, ut_kvp_instance_t *instance, void *userData );

/**
* @typedef ut_control_string_callback_t
* @brief A callback function type for handling control operations with formatted strings.
*
* This callback function is called with a key, an instance of ut_kvp_instance_t,
* user-defined data, and a format string. It returns a formatted string.
*
* @param key The key associated with the control operation.
* @param instance A pointer to a ut_kvp_instance_t instance.
* @param userData A pointer to user-defined data.
* @param format A constant character pointer representing the format string.
* @return A formatted string.
*/
typedef char* (*ut_control_string_callback_t)( char *key, ut_kvp_instance_t *instance, void *userData, const char* format );

/**
* @brief Initializes a control plane instance.
* @param monitorPort - Port number to monitor for incoming messages.
Expand All @@ -74,6 +100,24 @@ ut_control_plane_status_t UT_ControlPlane_RegisterCallbackOnMessage(ut_controlPl
ut_control_callback_t callbackFunction,
void *userData);

/**
* @brief Registers a string callback function for a specific message key in the control plane instance.
*
* This function allows the user to register a callback function that will be invoked when a message
* with the specified key is received by the control plane instance.
*
* @param pInstance Pointer to the control plane instance.
* @param key The key associated with the message for which the callback is to be registered.
* @param callbackFunction The callback function to be invoked when the message with the specified key is received.
* @param userData User-defined data to be passed to the callback function.
*
* @return Status of the registration operation.
*/
ut_control_plane_status_t UT_ControlPlane_RegisterStringCallbackOnMessage(ut_controlPlane_instance_t *pInstance,
char *key,
ut_control_string_callback_t callbackFunction,
void *userData);

/**
* @brief Starts the control plane listening for incoming messages.
* @param pInstance - Handle to the control plane instance.
Expand Down
10 changes: 10 additions & 0 deletions include/ut_kvp.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ uint32_t ut_kvp_getListCount( ut_kvp_instance_t *pInstance, const char *pszKey);
*/
unsigned char* ut_kvp_getDataBytes(ut_kvp_instance_t *pInstance, const char *pszKey, int *size);

/**
* @brief Get the data block from the instance based on the type requested by user.
* User to free the instance where the data is invalid, no output will be provided
* Also caller needs to ensure, that they free the pointer to the data block
*
* @param pInstance - pointer to the KVP instance
* @param pszType - type of data to be retrieved. Currently supported types are "json" and "yaml"
*/
char* ut_kvp_getDataOfType( ut_kvp_instance_t *pInstance, const char *pszType );

/* TODO:
* - Implement functions for getting signed integer values (`ut_kvp_getInt8Field`, `ut_kvp_getInt16Field`, `ut_kvp_getInt32Field`,
*`ut_kvp_getInt64Field`
Expand Down
Loading