![]() |
Fledge
An open source edge computing platform for industrial users
|
#include <reading_set.h>
Public Member Functions | |
ReadingSet () | |
Construct an empty reading set. | |
ReadingSet (const std::string &json) | |
Construct a reading set from a JSON document returned from the Fledge storage service query or notification. More... | |
ReadingSet (const std::vector< Reading *> *readings) | |
Construct a reading set from a vector<Reading *> pointer NOTE: readings are copied into m_readings. More... | |
virtual | ~ReadingSet () |
Destructor for a result set. | |
unsigned long | getCount () const |
const Reading * | operator[] (const unsigned int idx) |
const std::vector< Reading * > & | getAllReadings () const |
std::vector< Reading * > * | getAllReadingsPtr () |
std::vector< Reading * > * | moveAllReadings () |
Remove readings from the vector and return a reference to new vector containing readings*. | |
Reading * | removeReading (unsigned long id) |
Remove reading from vector based on index and return its pointer. | |
unsigned long | getLastId () const |
unsigned long | getReadingId (uint32_t pos) |
Return the ID of the nth reading in the reading set. More... | |
void | append (ReadingSet *) |
Append the readings in a second reading set to this reading set. More... | |
void | append (ReadingSet &) |
Append the readings in a second reading set to this reading set. More... | |
void | append (std::vector< Reading *> &) |
Append a set of readings to this reading set. More... | |
void | removeAll () |
Remove all readings from the reading set and delete the memory After this call the reading set exists but contains no readings. | |
void | clear () |
Remove the readings from the vector without deleting them. | |
bool | copy (const ReadingSet &src) |
Deep copy a set of readings to this reading set. More... | |
Protected Member Functions | |
ReadingSet (const ReadingSet &) | |
ReadingSet & | operator= (ReadingSet const &) |
Protected Attributes | |
unsigned long | m_count |
std::vector< Reading * > | m_readings |
unsigned long | m_last_id |
Reading set class.
A specialised container for a set of readings that allows creation from a JSON document.
ReadingSet::ReadingSet | ( | const std::string & | json | ) |
Construct a reading set from a JSON document returned from the Fledge storage service query or notification.
The JSON is parsed using the in-situ RapidJSON parser in order to reduce overhead on what is most likely a large JSON document.
WARNING: Although the string passed in is defiend as const this call is destructive to this string and the conntents of the string should not be used after making this call.
json | The JSON document (as string) with readings data |
ReadingSet::ReadingSet | ( | const std::vector< Reading *> * | readings | ) |
Construct a reading set from a vector<Reading *> pointer NOTE: readings are copied into m_readings.
readings | The vector<Reading *> pointer of readings to be copied into m_readings vector |
void ReadingSet::append | ( | ReadingSet * | readings | ) |
Append the readings in a second reading set to this reading set.
The readings are removed from the original reading set
readings | A ReadingSet to append to the current ReadingSet |
void ReadingSet::append | ( | ReadingSet & | readings | ) |
Append the readings in a second reading set to this reading set.
The readings are removed from the original reading set
readings | A ReadingSet to append to the current ReadingSet |
void ReadingSet::append | ( | std::vector< Reading *> & | readings | ) |
Append a set of readings to this reading set.
The readings are not copied, but rather moved from the vector, with the resulting vector havign the values removed on return.
It is assumed the readings in the vector have been created with the new operator.
readings | A vector of Reading pointers to append to the ReadingSet |
bool ReadingSet::copy | ( | const ReadingSet & | src | ) |
Deep copy a set of readings to this reading set.
src | The reading set to copy |
unsigned long ReadingSet::getReadingId | ( | uint32_t | pos | ) |
Return the ID of the nth reading in the reading set.
pos | The position of the reading to return the ID for |