timeseries_value.c
Go to the documentation of this file.
1 
10 #include "timeseries_value.h"
11 #include "mcl_core/mcl_memory.h"
13 
15 {
16  mcl_error_t code = MCL_OK;
17 
18  MCL_DEBUG_ENTRY("mcl_timeseries_value_t **timeseries_value = <%p>", timeseries_value);
19 
20  // Null check.
21  MCL_ASSERT_NOT_NULL(timeseries_value, code);
22 
23  // Allocate memory for timeseries value.
24  MCL_ASSERT_CODE_MESSAGE(MCL_NULL != MCL_NEW(*timeseries_value), MCL_OUT_OF_MEMORY, "Not enough memory to allocate new timeseries value.");
25 
26  // Set initial values.
27  (*timeseries_value)->data_point_id = MCL_NULL;
28  (*timeseries_value)->quality_code = MCL_NULL;
29  (*timeseries_value)->value = MCL_NULL;
30 
32  MCL_DEBUG_LEAVE("retVal = <%d>", code);
33  return code;
34 }
35 
37 {
38  mcl_error_t code;
39 
40  MCL_DEBUG_ENTRY("mcl_timeseries_value_t *timeseries_value = <%p>, E_MCL_TIMESERIES_VALUE_PARAMETER parameter = <%d>, const void *value = <%p>",
41  timeseries_value, parameter, value);
42 
43  // Null check.
44  MCL_ASSERT_NOT_NULL(timeseries_value, code);
45  MCL_ASSERT_NOT_NULL(value, code);
46 
47  switch (parameter)
48  {
50  code = mcl_string_util_reset(value, &timeseries_value->data_point_id);
51  break;
52 
54  code = mcl_string_util_reset(value, &timeseries_value->value);
55  break;
56 
58  code = mcl_string_util_reset(value, &timeseries_value->quality_code);
59  break;
60 
61  default:
62  code = MCL_INVALID_PARAMETER;
63  break;
64  }
65 
67  MCL_DEBUG_LEAVE("retVal = <%d>", code);
68  return code;
69 }
70 
72 {
73  MCL_DEBUG_ENTRY("timeseries_value_t *timeseries_value = <%p>", timeseries_value);
74 
75  // Timeseries value validation checks.
76  MCL_ASSERT_CODE_MESSAGE(MCL_NULL != timeseries_value->data_point_id, MCL_INVALID_PARAMETER, "Timeseries value data point id is not set.");
77  MCL_ASSERT_CODE_MESSAGE(MCL_NULL != timeseries_value->quality_code, MCL_INVALID_PARAMETER, "Timeseries value quality code is not set.");
78  MCL_ASSERT_CODE_MESSAGE(MCL_NULL != timeseries_value->value, MCL_INVALID_PARAMETER, "Timeseries value value is not set.");
79 
80  MCL_DEBUG_LEAVE("retVal = <%d>", MCL_OK);
81  return MCL_OK;
82 }
83 
85 {
86  MCL_DEBUG_ENTRY("mcl_timeseries_value_t **timeseries_value = <%p>", timeseries_value);
87 
88  // Destroys the timeseries value data structure.
89  if ((MCL_NULL != timeseries_value) && (MCL_NULL != *timeseries_value))
90  {
91  MCL_FREE((*timeseries_value)->data_point_id);
92  MCL_FREE((*timeseries_value)->quality_code);
93  MCL_FREE((*timeseries_value)->value);
94  MCL_FREE(*timeseries_value);
95  }
96 
97  MCL_DEBUG_LEAVE("retVal = void");
98 }
E_MCL_TIMESERIES_VALUE_PARAMETER
#define MCL_FUNCTION_LEAVE_LABEL
char * data_point_id
Data point id of the timeseries value.
MCL_OK
struct mcl_timeseries_value_t mcl_timeseries_value_t
MCL_CORE_EXPORT mcl_error_t mcl_string_util_reset(const void *value, char **target)
mcl_int32_t mcl_error_t
#define MCL_DEBUG_ENTRY(...)
Timeseries value module header file.
Timeseries value quality code parameter as char*.
#define MCL_ASSERT_CODE_MESSAGE(condition, return_code,...)
#define MCL_NEW(p)
#define MCL_NULL
mcl_error_t mcl_timeseries_value_initialize(mcl_timeseries_value_t **timeseries_value)
char * value
Value of the timeseries value.
mcl_error_t mcl_timeseries_value_set_parameter(mcl_timeseries_value_t *timeseries_value, E_MCL_TIMESERIES_VALUE_PARAMETER parameter, const void *value)
char * quality_code
Quality code of the timeseries value.
void mcl_timeseries_value_destroy(mcl_timeseries_value_t **timeseries_value)
#define MCL_FREE(p)
Timeseries value module interface header file.
Timeseries value data point id parameter as char*.
#define MCL_ASSERT_NOT_NULL(argument, return_variable)
mcl_error_t timeseries_value_validate(timeseries_value_t *timeseries_value)
Timeseries value value parameter as char*.
MCL_OUT_OF_MEMORY
MCL_INVALID_PARAMETER
#define MCL_DEBUG_LEAVE(...)