Fledge
An open source edge computing platform for industrial users
ReadingSet Class Reference

Reading set class. More...

#include <reading_set.h>

Inheritance diagram for ReadingSet:

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 Readingoperator[] (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*.
 
ReadingremoveReading (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 &)
 
ReadingSetoperator= (ReadingSet const &)
 

Protected Attributes

unsigned long m_count
 
std::vector< Reading * > m_readings
 
unsigned long m_last_id
 

Detailed Description

Reading set class.

A specialised container for a set of readings that allows creation from a JSON document.

Constructor & Destructor Documentation

◆ ReadingSet() [1/2]

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.

Parameters
jsonThe JSON document (as string) with readings data

◆ ReadingSet() [2/2]

ReadingSet::ReadingSet ( const std::vector< Reading *> *  readings)

Construct a reading set from a vector<Reading *> pointer NOTE: readings are copied into m_readings.

Parameters
readingsThe vector<Reading *> pointer of readings to be copied into m_readings vector

Member Function Documentation

◆ append() [1/3]

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

Parameters
readingsA ReadingSet to append to the current ReadingSet

◆ append() [2/3]

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

Parameters
readingsA ReadingSet to append to the current ReadingSet

◆ append() [3/3]

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.

Parameters
readingsA vector of Reading pointers to append to the ReadingSet

◆ copy()

bool ReadingSet::copy ( const ReadingSet src)

Deep copy a set of readings to this reading set.

Parameters
srcThe reading set to copy
Returns
bool True if the reading set was copied

◆ getReadingId()

unsigned long ReadingSet::getReadingId ( uint32_t  pos)

Return the ID of the nth reading in the reading set.

Parameters
posThe position of the reading to return the ID for

The documentation for this class was generated from the following files: