KPN Things Device SDK
SenMLRecordTemplate< T > Class Template Reference

#include <senml_record_t.h>

Inheritance diagram for SenMLRecordTemplate< T >:
SenMLRecord SenMLBase

Public Member Functions

 SenMLRecordTemplate (const char *name)
 
 SenMLRecordTemplate (const char *name, SenMLUnit unit)
 
 SenMLRecordTemplate (const char *name, SenMLUnit unit, T value)
 
 SenMLRecordTemplate (ThingsMLMeasurementIndex index)
 
 SenMLRecordTemplate (ThingsMLMeasurementIndex index, T value)
 
get ()
 
bool asSum ()
 
bool set (T value, double time=(double) NAN, bool asSum=false)
 
- Public Member Functions inherited from SenMLRecord
 SenMLRecord ()
 
 SenMLRecord (const char *name)
 
 SenMLRecord (ThingsMLMeasurementIndex index)
 
 SenMLRecord (const char *name, SenMLUnit unit)
 
double getTime ()
 
bool setTime (double value, bool absolute=true)
 
void setTimeDirect (double value)
 
const char * getName ()
 
ThingsMLMeasurementIndex getIndex ()
 
void setName (const char *name)
 
double getUpdateTime ()
 
bool setUpdateTime (double value, bool absolute=true)
 
SenMLUnit getUnit ()
 
void setUnit (SenMLUnit value)
 
virtual int fieldsToJson ()
 
virtual int fieldsToCbor ()
 
- Public Member Functions inherited from SenMLBase
 SenMLBase ()
 
 ~SenMLBase ()
 
SenMLBasegetNext ()
 
SenMLBasegetRoot ()
 
virtual void adjustToBaseTime (double prev, double time)
 
virtual int fieldsToJson ()=0
 
virtual int fieldsToCbor ()=0
 

Additional Inherited Members

- Protected Member Functions inherited from SenMLRecord
virtual int contentToJson ()
 
virtual int contentToCbor ()
 
virtual void adjustToBaseTime (double prev, double time)
 
virtual void actuate (const void *value, int dataLength, SenMLDataType dataType)
 
int getFieldLength ()
 
- Protected Member Functions inherited from SenMLBase
virtual int contentToJson ()=0
 
void setNext (SenMLBase *value)
 
void setPrev (SenMLBase *value)
 
SenMLBasegetPrev ()
 
virtual bool isPack ()
 
virtual int contentToCbor ()=0
 
virtual int getArrayLength ()
 
virtual int getFieldLength ()=0
 

Detailed Description

template<class T>
class SenMLRecordTemplate< T >

A template class that can be used to create new SenMLRecord types that store a value with a basic data type (no structs or classes). When you create a new class, you should always implement the following functions in order for the new class to operate correctly: fieldsToJson() and fieldsToCbor()

Constructor & Destructor Documentation

◆ SenMLRecordTemplate() [1/5]

template<class T >
SenMLRecordTemplate< T >::SenMLRecordTemplate ( const char *  name)
inline

◆ SenMLRecordTemplate() [2/5]

template<class T >
SenMLRecordTemplate< T >::SenMLRecordTemplate ( const char *  name,
SenMLUnit  unit 
)
inline

◆ SenMLRecordTemplate() [3/5]

template<class T >
SenMLRecordTemplate< T >::SenMLRecordTemplate ( const char *  name,
SenMLUnit  unit,
value 
)
inline

◆ SenMLRecordTemplate() [4/5]

template<class T >
SenMLRecordTemplate< T >::SenMLRecordTemplate ( ThingsMLMeasurementIndex  index)
inline

◆ SenMLRecordTemplate() [5/5]

template<class T >
SenMLRecordTemplate< T >::SenMLRecordTemplate ( ThingsMLMeasurementIndex  index,
value 
)
inline

Member Function Documentation

◆ asSum()

template<class T >
bool SenMLRecordTemplate< T >::asSum ( )
inline

Get if the value should be interpreted as a sum or regular value. These are exclusive: a SenMLRecord either has a sum or a value, but never both. Sum and value are always assigned with the function set().

Returns
: True when the value is interpreted as a sum, otherwise false.

◆ get()

template<class T >
T SenMLRecordTemplate< T >::get ( )
inline

Get the value assigned to this SenMLRecord. This function always returns the absolute value, also when the record is part of a pack that has a base value assigned.

Returns
: the value (including the base-value when applicable).

◆ set()

template<class T >
bool SenMLRecordTemplate< T >::set ( value,
double  time = (double)NAN,
bool  asSum = false 
)
inline

Assign a value to the SenMLRecord. You can optionally assign the time at which the measurement was taken and if it should be interpreted as a sum or regular value.

Parameters
valuethe value to store in the record
timeoptional (default = NAN, meaning not time info). The time at which the measurement was taken. This should always be the absolute time value which will be converted relative to the base time when applicable (if the root is a SenMLPack with baseTime) . If you want to set the time manually relative to the basetime of the root-pack, then use setTime() instead.
asSumwhen true, the value will be interpreted as a sum, otherwise as a regular value.
Returns
: true if the operation was succesful. See setTime() for more info when the operation can fail.

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