VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
vrs::DataPieceStringMap< T > Class Template Reference

DataPiece map container, with string keys and values of type T. More...

#include <DataPieceStringMap.h>

Inheritance diagram for vrs::DataPieceStringMap< T >:
vrs::DataPiece

Public Member Functions

 DataPieceStringMap (const string &label)
 
 DataPieceStringMap (const MakerBundle &bundle)
 
const string & getElementTypeName () const override
 
size_t getVariableSize () const override
 
size_t collectVariableData (int8_t *data, size_t bufferSize) override
 
const map< string, T > & stagedValues () const
 
map< string, T > & stagedValues ()
 
void stage (const map< string, T > &values)
 
void stage (map< string, T > &&values)
 
bool get (map< string, T > &outValues) const
 
const map< string, T > & getDefault () const
 
void setDefault (const map< string, T > &values)
 
void setDefault (map< string, T > &&values)
 
bool isAvailable () const override
 
void print (ostream &out, const string &indent) const override
 
void printCompact (ostream &out, const string &indent) const override
 
bool isSame (const DataPiece *rhs) const override
 
void serialize (JsonWrapper &jsonWrapper, const JsonFormatProfileSpec &profile) override
 
bool stageCurrentValue () override
 
unique_ptr< DataPiececlone () const override
 
void printCompact (ostream &out, const string &indent) const
 
- Public Member Functions inherited from vrs::DataPiece
const DataLayoutgetDataLayout () const
 
const string & getLabel () const
 
DataPieceType getPieceType () const
 
string getTypeName () const
 
size_t getOffset () const
 
bool hasFixedSize () const
 
size_t getFixedSize () const
 
bool getTag (const string &tagName, string &outTag) const
 
void setTag (const string &tagName, const string &tag)
 
bool getUnit (string &outUnit) const
 
void setUnit (const string &unit)
 
bool getDescription (string &outDescription) const
 
void setDescription (const string &description)
 
void setRequired (bool required=true)
 
bool isRequired () const
 

Protected Member Functions

bool stageFrom (const DataPiece *original) override
 Stage value from another piece known to be of the same type.
 
- Protected Member Functions inherited from vrs::DataPiece
 DataPiece (const string &label, DataPieceType type, size_t size)
 
bool isMatch (const DataPiece &rhs) const
 Match signature only.
 
void setOffset (size_t offset)
 

Additional Inherited Members

- Protected Attributes inherited from vrs::DataPiece
const string label_
 
const DataPieceType pieceType_
 
const size_t fixedSize_
 
size_t offset_
 
DataLayoutlayout_
 
map< string, string > tags_
 
bool required_
 
- Static Protected Attributes inherited from vrs::DataPiece
static const string kUnit = "unit"
 Special tag name to specify a unit of the DataPiece.
 
static const string kDescription = "description"
 Special tag name to specify a human readable description the DataPiece.
 
static const string kMinValue = "min"
 Special property name for the minimum value of the DataPiece.
 
static const string kMaxValue = "max"
 Special property name for the maximum value of the DataPiece.
 
static const string kMinIncrement = "min_increment"
 Special property name for the minimum increment of the DataPiece.
 
static const string kMaxIncrement = "max_increment"
 Special property name for the maximum increment of the DataPiece.
 

Detailed Description

template<typename T>
class vrs::DataPieceStringMap< T >

DataPiece map container, with string keys and values of type T.

Read values are extracted from the DataLayout's buffer, (VRS records reading/decoding). Staged values are stored in the map<string, T> member of this class (VRS record creation).

Constructor & Destructor Documentation

◆ DataPieceStringMap() [1/2]

template<typename T >
vrs::DataPieceStringMap< T >::DataPieceStringMap ( const string &  label)
inlineexplicit
Parameters
labelName for the DataPiece.

◆ DataPieceStringMap() [2/2]

template<typename T >
vrs::DataPieceStringMap< T >::DataPieceStringMap ( const MakerBundle bundle)
explicit
Parameters
bundleBundle to reconstruct a DataPieceStringMap from disk.

Member Function Documentation

◆ clone()

template<typename T >
unique_ptr< DataPiece > vrs::DataPieceStringMap< T >::clone ( ) const
inlineoverridevirtual

Clone data piece.

Returns
A clone of the data piece, with the same label and same type. All the other data piece properties (default and staged values) are not cloned.

Implements vrs::DataPiece.

◆ collectVariableData()

template<typename T >
size_t vrs::DataPieceStringMap< T >::collectVariableData ( int8_t *  data,
size_t  bufferSize 
)
overridevirtual

Copy the staged map to the location given.

Parameters
dataPointer where to write the staged values.
bufferSizeMax number of bytes to write.
Returns
Number of bytes written.

Implements vrs::DataPiece.

◆ get()

template<typename T >
bool vrs::DataPieceStringMap< T >::get ( map< string, T > &  outValues) const

Get read values or default values in a map.

Parameters
outValuesReference to a map<string, T> for the read or default values.
Returns
True if outValues was set from read values (maybe mapped), not default values.

◆ getDefault()

template<typename T >
const map< string, T > & vrs::DataPieceStringMap< T >::getDefault ( ) const
inline

Get the default value.

Returns
Default values. The vector might be empty if there are no defaults set.

◆ getElementTypeName()

template<typename T >
const string & vrs::DataPieceStringMap< T >::getElementTypeName ( ) const
inlineoverridevirtual

Get the name of the element type <T>.

Implements vrs::DataPiece.

◆ getVariableSize()

template<typename T >
size_t vrs::DataPieceStringMap< T >::getVariableSize ( ) const
overridevirtual

Get the size of the staged map, if any.

Returns
Number of bytes to store the staged map.

Implements vrs::DataPiece.

◆ isAvailable()

template<typename T >
bool vrs::DataPieceStringMap< T >::isAvailable ( ) const
inlineoverridevirtual

Tell if the DataPiece is available, directly or mapped successfully.

Returns
True if values can be read without using default values.

Implements vrs::DataPiece.

◆ isSame()

template<typename T >
bool vrs::DataPieceStringMap< T >::isSame ( const DataPiece rhs) const
overridevirtual

Compare two DataPiece objects for their equivalence. Note: the values are not compared, all the other properties are (type, name, tags, etc).

Parameters
rhsOther DataPiece to compare to.
Returns
True if the DataPiece objects are considered the same.

Reimplemented from vrs::DataPiece.

◆ print()

template<typename T >
void vrs::DataPieceStringMap< T >::print ( ostream &  out,
const string &  indent 
) const
overridevirtual

Print the DataPiece to the out stream, with many details, using indent text at the start of each line of output.

Parameters
outOutput stream to print to.
indentText to insert at the beginning of each output line, for indentation purposes.

Implements vrs::DataPiece.

◆ printCompact() [1/2]

void vrs::DataPieceStringMap< string >::printCompact ( ostream &  out,
const string &  indent 
) const
virtual

Print the DataPiece to the out stream in compact form, using indent text at the start of each line of output.

Parameters
outOutput stream to print to.
indentText to insert at the beginning of each output line, for indentation purposes.

Implements vrs::DataPiece.

◆ printCompact() [2/2]

template<typename T >
void vrs::DataPieceStringMap< T >::printCompact ( ostream &  out,
const string &  indent 
) const
overridevirtual

Print the DataPiece to the out stream in compact form, using indent text at the start of each line of output.

Parameters
outOutput stream to print to.
indentText to insert at the beginning of each output line, for indentation purposes.

Implements vrs::DataPiece.

◆ serialize()

template<typename T >
void vrs::DataPieceStringMap< T >::serialize ( JsonWrapper &  jsonWrapper,
const JsonFormatProfileSpec profile 
)
overridevirtual

Export the DataPiece as json, using a specific profile.

Parameters
jsonWrapperWrapper around a json type (to isolate any 3rd party library dependency).
profileProfile describing what information needs to be exported as json.

Reimplemented from vrs::DataPiece.

◆ setDefault() [1/2]

template<typename T >
void vrs::DataPieceStringMap< T >::setDefault ( const map< string, T > &  values)
inline

Set default values using a vector.

Parameters
valuesVector of values to use a default.

◆ setDefault() [2/2]

template<typename T >
void vrs::DataPieceStringMap< T >::setDefault ( map< string, T > &&  values)
inline

Set default values using a vector.

Parameters
valuesVector of values to use a default.

◆ stage() [1/2]

template<typename T >
void vrs::DataPieceStringMap< T >::stage ( const map< string, T > &  values)
inline

Stage values you wish to write to disk. Does not modify the read values!

Parameters
valuesValues to stage, to include them in the next record created.

◆ stage() [2/2]

template<typename T >
void vrs::DataPieceStringMap< T >::stage ( map< string, T > &&  values)
inline

Stage values you wish to write to disk. Does not modify the read values!

Parameters
valuesValues to stage, to include them in the next record created.

◆ stageCurrentValue()

template<typename T >
bool vrs::DataPieceStringMap< T >::stageCurrentValue ( )
inlineoverridevirtual

Take the current value of the field, and stage it for writing during record creation.

Returns
True if the value is available and was staged.

Reimplemented from vrs::DataPiece.

◆ stagedValues() [1/2]

template<typename T >
map< string, T > & vrs::DataPieceStringMap< T >::stagedValues ( )
inline

Set or modify the map of values you wish to write to disk. Does not modify the read values!

Returns
A reference to the staged map<string, T>.

◆ stagedValues() [2/2]

template<typename T >
const map< string, T > & vrs::DataPieceStringMap< T >::stagedValues ( ) const
inline

Read-only access to the map of values you wish to write to disk.

Returns
A const reference to the staged map<string, T>.

◆ stageFrom()

template<typename T >
bool vrs::DataPieceStringMap< T >::stageFrom ( const DataPiece original)
inlineoverrideprotectedvirtual

Stage value from another piece known to be of the same type.

Implements vrs::DataPiece.


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