19 #include <databuffer.h> 20 #include <rapidjson/document.h> 21 #include "string_utils.h" 37 m_value.str =
new std::string(value);
61 m_value.a =
new std::vector<double>(values);
62 m_type = T_FLOAT_ARRAY;
71 m_type = isDict? T_DP_DICT : T_DP_LIST;
79 m_value.image =
new DPImage(value);
89 m_type = T_DATABUFFER;
98 m_value.image = value;
107 m_value.dataBuffer = value;
108 m_type = T_DATABUFFER;
116 m_value.a2d =
new std::vector< std::vector<double>* >;
117 for (
auto row : values)
119 std::vector<double> *nrow =
new std::vector<double>;
124 m_value.a2d->push_back(nrow);
126 m_type = T_2D_FLOAT_ARRAY;
155 m_value.str =
new std::string(value);
186 m_value.image =
new DPImage(value);
203 long toInt()
const {
return m_value.i; };
210 typedef enum DatapointTag
231 std::string getTypeStr()
const 235 case T_STRING:
return std::string(
"STRING");
236 case T_INTEGER:
return std::string(
"INTEGER");
237 case T_FLOAT:
return std::string(
"FLOAT");
238 case T_FLOAT_ARRAY:
return std::string(
"FLOAT_ARRAY");
239 case T_DP_DICT:
return std::string(
"DP_DICT");
240 case T_DP_LIST:
return std::string(
"DP_LIST");
241 case T_IMAGE:
return std::string(
"IMAGE");
242 case T_DATABUFFER:
return std::string(
"DATABUFFER");
243 case T_2D_FLOAT_ARRAY:
return std::string(
"2D_FLOAT_ARRAY");
244 default:
return std::string(
"INVALID");
277 return m_value.image;
285 return m_value.dataBuffer;
289 void deleteNestedDPV();
290 const std::string escape(
const std::string& str)
const;
295 std::vector<double>* a;
296 std::vector<Datapoint*>
300 std::vector< std::vector<double>* >
329 std::string rval =
"\"" + escape(m_name) +
"\":";
330 rval += m_value.toString();
371 std::vector<Datapoint*>* parseJson(
const std::string& json);
372 std::vector<Datapoint*>* recursiveJson(
const rapidjson::Value& document);
const DatapointValue getData() const
Return Datapoint value.
Definition: datapoint.h:354
~DatapointValue()
Destructor.
Definition: datapoint.cpp:183
Datapoint(const std::string &name, DatapointValue &value)
Construct with a data point value.
Definition: datapoint.h:315
Name and value pair used to represent a data value within an asset reading.
Definition: datapoint.h:310
DatapointValue(const long value)
Construct with an integer value.
Definition: datapoint.h:43
std::string toStringValue() const
Return string value without trailing/leading quotes.
Definition: datapoint.h:198
void setValue(long value)
Set the value of a datapoint, this may also cause the type to be changed.
Definition: datapoint.h:164
void setName(std::string name)
Rename the datapoint.
Definition: datapoint.h:346
long toInt() const
Return long value.
Definition: datapoint.h:203
dataTagType getType() const
Return the Tag type.
Definition: datapoint.h:226
void setValue(std::string value)
Set the value of a datapoint, this may also cause the type to be changed.
Definition: datapoint.h:149
DatapointValue(const std::vector< std::vector< double > *> &values)
Construct with a 2 dimentional array of floating point values.
Definition: datapoint.h:114
DataBuffer * getDataBuffer()
Return the DataBuffer.
Definition: datapoint.h:283
const std::string getName() const
Return the Datapoint name.
Definition: datapoint.h:338
void setValue(double value)
Set the value of a datapoint, this may also cause the type to be changed.
Definition: datapoint.h:175
DatapointValue(const std::string &value)
Construct with a string.
Definition: datapoint.h:35
std::vector< std::vector< double > *> *& getDp2DArr()
Return 2D array of float.
Definition: datapoint.h:267
DatapointValue & operator=(const DatapointValue &rhs)
Assignment Operator.
Definition: datapoint.cpp:247
DatapointValue(DataBuffer *value)
Construct with a DataBuffer.
Definition: datapoint.h:105
Buffer type for storage of arbitrary buffers of data within a datapoint.
Definition: databuffer.h:19
DatapointValue(DPImage *value)
Construct with an Image Pointer, the image becomes owned by the datapointValue.
Definition: datapoint.h:96
DPImage * getImage()
Return the Image.
Definition: datapoint.h:275
double toDouble() const
Return double value.
Definition: datapoint.h:207
Class to hold an actual reading value.
Definition: datapoint.h:30
Simple Image class that will be used within data points to store image data.
Definition: dpimage.h:21
DatapointValue(const DataBuffer &value)
Construct with a DataBuffer.
Definition: datapoint.h:86
DatapointValue & getData()
Return reference to Datapoint value.
Definition: datapoint.h:362
DatapointValue(const std::vector< double > &values)
Construct with an array of floating point values.
Definition: datapoint.h:59
void setValue(const DPImage &value)
Set the value of a datapoint to be an image.
Definition: datapoint.h:184
std::string toJSONProperty()
Return asset reading data point as a JSON property that can be included within a JSON document...
Definition: datapoint.h:327
std::vector< Datapoint * > *& getDpVec()
Return array of datapoints.
Definition: datapoint.h:251
std::string toString() const
Return the value as a string.
Definition: datapoint.cpp:27
DatapointValue(const DPImage &value)
Construct with an Image.
Definition: datapoint.h:77
DatapointValue(const double value)
Construct with a floating point value.
Definition: datapoint.h:51
std::vector< double > *& getDpArr()
Return array of float.
Definition: datapoint.h:259
DatapointValue(std::vector< Datapoint *> *&values, bool isDict)
Construct with an array of Datapoints.
Definition: datapoint.h:68