data_source_configuration.c File Reference

Data source configuration module implementation file. More...

#include "mcl/mcl_data_source_configuration.h"
#include "data_source_configuration.h"
#include "log_util.h"
#include "memory.h"
#include "random.h"
#include "json_util.h"
#include "definitions.h"
Include dependency graph for data_source_configuration.c:

Go to the source code of this file.

Functions

static E_MCL_ERROR_CODE _initialize_meta (const char *version, data_source_configuration_t *data_source_configuration)
 
static E_MCL_ERROR_CODE _initialize_payload (data_source_configuration_t *data_source_configuration)
 
static void _destroy_data_source (data_source_t **data_source)
 
static void _destroy_data_point (data_point_t **data_point)
 
E_MCL_ERROR_CODE data_source_configuration_initialize (const char *version, data_source_configuration_t **data_source_configuration)
 
E_MCL_ERROR_CODE mcl_data_source_configuration_add_data_source (mcl_data_source_configuration_t *data_source_configuration, const char *name, const char *description, mcl_json_t *custom_data, mcl_data_source_t **data_source)
 
E_MCL_ERROR_CODE mcl_data_source_configuration_add_data_point (mcl_data_source_t *data_source, const char *id, const char *name, const char *description, const char *type, const char *unit, mcl_json_t *custom_data)
 
E_MCL_ERROR_CODE mcl_data_source_configuration_get_id (mcl_data_source_configuration_t *data_source_configuration, char **id)
 
void data_source_configuration_destroy (data_source_configuration_t **data_source_configuration)
 

Detailed Description

Data source configuration module implementation file.


Date
Nov 13, 2017

Definition in file data_source_configuration.c.

Function Documentation

static void _destroy_data_point ( data_point_t **  data_point)
static

Definition at line 266 of file data_source_configuration.c.

References DEBUG_ENTRY, DEBUG_LEAVE, json_util_destroy(), MCL_FREE, and string_destroy().

Referenced by _destroy_data_source(), and mcl_data_source_configuration_add_data_point().

Here is the call graph for this function:

Here is the caller graph for this function:

static void _destroy_data_source ( data_source_t **  data_source)
static

Definition at line 253 of file data_source_configuration.c.

References _destroy_data_point(), DEBUG_ENTRY, DEBUG_LEAVE, json_util_destroy(), list_destroy_with_content(), MCL_FREE, and string_destroy().

Referenced by data_source_configuration_destroy(), and mcl_data_source_configuration_add_data_source().

Here is the call graph for this function:

Here is the caller graph for this function:

static E_MCL_ERROR_CODE _initialize_payload ( data_source_configuration_t data_source_configuration)
static
void data_source_configuration_destroy ( data_source_configuration_t **  data_source_configuration)

Destroys data_source_configuration.

Parameters
[in]data_source_configuration

Definition at line 199 of file data_source_configuration.c.

References _destroy_data_source(), DEBUG_ENTRY, DEBUG_LEAVE, list_destroy_with_content(), MCL_FREE, MCL_NULL, and string_destroy().

Referenced by _store_list_destroy_callback(), data_source_configuration_initialize(), and mcl_store_new_data_source_configuration().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE data_source_configuration_initialize ( const char *  version,
data_source_configuration_t **  data_source_configuration 
)

Initializes data_source_configuration.

Parameters
[in]versionMeta version.
[out]data_source_configurationInitialized data_source_configuration_t object handle.
Returns

Definition at line 28 of file data_source_configuration.c.

References _initialize_meta(), _initialize_payload(), ASSERT_CODE_MESSAGE, data_source_configuration_destroy(), DEBUG_ENTRY, DEBUG_LEAVE, MCL_NEW, MCL_NULL, MCL_OK, and MCL_OUT_OF_MEMORY.

Referenced by mcl_store_new_data_source_configuration().

Here is the call graph for this function:

Here is the caller graph for this function:

E_MCL_ERROR_CODE mcl_data_source_configuration_add_data_point ( mcl_data_source_t data_source,
const char *  id,
const char *  name,
const char *  description,
const char *  type,
const char *  unit,
mcl_json_t custom_data 
)

Sets the list of data points held by the data_source.

Parameters
[in]data_sourceData source the data_source_configuration encloses.
[in]idAgent-unique identifier of the data point.
[in]nameName of the data point.
[in]descriptionDescription of the data point. This parameter is optional and can be NULL.
[in]typeData type of the data point.
[in]unitMeasurement unit of the data point.
[in]custom_dataCustom data of the data point. New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space. This parameter is optional and can be NULL.
Returns

Definition at line 113 of file data_source_configuration.c.

References _destroy_data_point(), ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, data_point_t::custom_data, DEBUG_ENTRY, DEBUG_LEAVE, data_point_t::description, data_point_t::id, json_util_duplicate(), list_add(), MCL_DEBUG, MCL_FALSE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_TRUE, data_point_t::name, string_initialize_new(), data_point_t::type, and data_point_t::unit.

Here is the call graph for this function:

E_MCL_ERROR_CODE mcl_data_source_configuration_add_data_source ( mcl_data_source_configuration_t data_source_configuration,
const char *  name,
const char *  description,
mcl_json_t custom_data,
mcl_data_source_t **  data_source 
)

Sets the list of data sources the data_source_configuration encloses.

Parameters
[in]data_source_configurationData source configuration object handle.
[in]nameName of the data_source.
[in]descriptionDescription of the data_source. This parameter is optional and can be NULL.
[in]custom_dataCustom data of the data_source. New memory space will be allocated for this parameter. Ownership passed to caller. Caller must free the space. This parameter is optional and can be NULL.
[out]data_sourceData source the data_source_configuration encloses.
Returns

Definition at line 60 of file data_source_configuration.c.

References _destroy_data_source(), ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, DEBUG_ENTRY, DEBUG_LEAVE, json_util_duplicate(), list_add(), list_initialize(), MCL_DEBUG, MCL_FALSE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_TRUE, and string_initialize_new().

Here is the call graph for this function:

E_MCL_ERROR_CODE mcl_data_source_configuration_get_id ( mcl_data_source_configuration_t data_source_configuration,
char **  id 
)

Returns id of data_source_configuration.

Memory allocation of id is done by the function. But the responsibility of freeing id is on the user.

Parameters
[in]data_source_configurationData source configuration object handle.
[out]idUnique identifier of the configuration.
Returns

Definition at line 177 of file data_source_configuration.c.

References ASSERT_CODE_MESSAGE, ASSERT_NOT_NULL, string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, MCL_FREE, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, and string_initialize().

Here is the call graph for this function: