AppDynamics IoT C++ SDK
AppDynamics IoT C++ library contains code that facilitates capturing availability, usage, network performance and errors of an IoT Application.
custom_event.hpp File Reference
#include "beacon.hpp"

Go to the source code of this file.

Functions

appd_iot_error_code_t appd_iot_copy_event_data (data_t *destdata, appd_iot_data_t *srcdata, int srcdata_count)
 Copies User Defined Event Data to SDK Defined Event Data. More...
 
appd_iot_error_code_t appd_iot_clear_event_data (data_t *data)
 Clear event data. More...
 

Function Documentation

◆ appd_iot_copy_event_data()

appd_iot_error_code_t appd_iot_copy_event_data ( data_t destdata,
appd_iot_data_t srcdata,
int  srcdata_count 
)

Copies User Defined Event Data to SDK Defined Event Data.

Parameters
destdatacontains event data to be copied to
srcdatacontains event data to be copied from
srcdata_countcontains number of key-value pairs in user defined event data
Returns
appd_iot_error_code_t indicating function execution status
111 {
112  if (destdata == NULL)
113  {
114  appd_iot_log(APPD_IOT_LOG_ERROR, "Destination Data Pointer in NULL");
115  return APPD_IOT_ERR_INTERNAL;
116  }
117 
118  if (srcdata == NULL)
119  {
120  appd_iot_log(APPD_IOT_LOG_ERROR, "Source Data Pointer is NULL");
121  return APPD_IOT_ERR_NULL_PTR;
122  }
123 
124  for (int i = 0; i < srcdata_count; i++)
125  {
126  if ((srcdata + i) == NULL)
127  {
128  appd_iot_log(APPD_IOT_LOG_ERROR, "Event Data at Index:%d is NULL", i);
129  return APPD_IOT_ERR_NULL_PTR;
130  }
131 
132  if (srcdata[i].key == NULL)
133  {
134  appd_iot_log(APPD_IOT_LOG_ERROR, "Event <Key> at Index:%d is NULL", i);
135  return APPD_IOT_ERR_NULL_PTR;
136  }
137 
138  std::string key = appd_iot_remove_character(srcdata[i].key, '|');
139 
140  switch (srcdata[i].value_type)
141  {
142  case APPD_IOT_INTEGER:
143  {
144  destdata->integermap[key] = srcdata[i].intval;
145  break;
146  }
147 
148  case APPD_IOT_DOUBLE:
149  {
150  destdata->doublemap[key] = srcdata[i].doubleval;
151  break;
152  }
153 
154  case APPD_IOT_BOOLEAN:
155  {
156  destdata->boolmap[key] = srcdata[i].boolval;
157  break;
158  }
159 
160  case APPD_IOT_STRING:
161  {
162  if (srcdata[i].strval != NULL)
163  {
164  destdata->stringmap[key] = srcdata[i].strval;
165  }
166  else
167  {
168  appd_iot_log(APPD_IOT_LOG_WARN, "String Value is NULL for key %s", srcdata[i].key);
169  }
170 
171  break;
172  }
173 
174  case APPD_IOT_DATETIME:
175  {
176  destdata->datetimemap[key] = srcdata[i].datetimeval;
177  break;
178  }
179 
180  default:
181  {
182  appd_iot_log(APPD_IOT_LOG_ERROR, "Skip Adding event field:%s due to invalid data type:%d",
183  srcdata[i].key, srcdata[i].value_type);
184  break;
185  }
186  }
187 
188  appd_iot_log(APPD_IOT_LOG_INFO, "Added Key :%s with value type:%d", key.c_str(), srcdata[i].value_type);
189  }
190 
191  return APPD_IOT_SUCCESS;
192 }
int64_t datetimeval
Definition: appd_iot_def.h:213
Definition: appd_iot_def.h:44
void appd_iot_log(appd_iot_log_level_t log_level, const char *format,...)
Reads log message, appends log header and triggers log write callback function.
Definition: log.cpp:89
bool boolval
Definition: appd_iot_def.h:210
Definition: appd_iot_def.h:101
Definition: appd_iot_def.h:192
double doubleval
Definition: appd_iot_def.h:212
std::map< std::string, bool > boolmap
Definition: beacon.hpp:34
std::map< std::string, std::string > stringmap
Definition: beacon.hpp:31
Definition: appd_iot_def.h:194
Definition: appd_iot_def.h:103
const char * strval
Definition: appd_iot_def.h:209
std::map< std::string, int64_t > integermap
Definition: beacon.hpp:32
Definition: appd_iot_def.h:188
std::map< std::string, int64_t > datetimemap
Definition: beacon.hpp:35
Definition: appd_iot_def.h:190
appd_iot_data_types_t value_type
Definition: appd_iot_def.h:215
int64_t intval
Definition: appd_iot_def.h:211
Definition: appd_iot_def.h:196
std::string appd_iot_remove_character(const char *input, char c)
Removes a given character from the input string.
Definition: utils.cpp:27
std::map< std::string, double > doublemap
Definition: beacon.hpp:33
Definition: appd_iot_def.h:30
Definition: appd_iot_def.h:99
Definition: appd_iot_def.h:46

◆ appd_iot_clear_event_data()

appd_iot_error_code_t appd_iot_clear_event_data ( data_t data)

Clear event data.

Parameters
datathat needs to be cleared
Returns
appd_iot_error_code_t indicating function execution status
92 {
93  data->stringmap.clear();
94  data->integermap.clear();
95  data->boolmap.clear();
96  data->datetimemap.clear();
97  data->doublemap.clear();
98 
99  return APPD_IOT_SUCCESS;
100 }
std::map< std::string, bool > boolmap
Definition: beacon.hpp:34
std::map< std::string, std::string > stringmap
Definition: beacon.hpp:31
std::map< std::string, int64_t > integermap
Definition: beacon.hpp:32
std::map< std::string, int64_t > datetimemap
Definition: beacon.hpp:35
std::map< std::string, double > doublemap
Definition: beacon.hpp:33
Definition: appd_iot_def.h:30