VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
vrs::DataPieceEnum< EnumType, StorageType > Class Template Reference

DataPieceValue specialization class to store enums more conveniently and safely. More...

#include <DataPieceValue.h>

Inheritance diagram for vrs::DataPieceEnum< EnumType, StorageType >:
vrs::DataPieceValue< StorageType > vrs::DataPiece

Public Member Functions

 DataPieceEnum (const string &label)
 
 DataPieceEnum (const string &label, EnumType defaultValue)
 
EnumType get () const
 
bool get (EnumType &e) const
 
bool set (const EnumType e)
 
EnumType getDefault () const
 
bool getDefault (EnumType &outDefault) const
 
void setDefault (const EnumType defaultValue)
 
- Public Member Functions inherited from vrs::DataPieceValue< StorageType >
 DataPieceValue (const string &label)
 
 DataPieceValue (const string &label, StorageType defaultValue)
 
 DataPieceValue (const MakerBundle &bundle)
 
const string & getElementTypeName () const override
 
size_t getVariableSize () const override
 
size_t collectVariableData (int8_t *, size_t) override
 
StorageType get () const
 
bool get (StorageType &outValue) const
 
bool set (const StorageType &value)
 
StorageType getDefault () const
 
bool getDefault (StorageType &outDefault) const
 
void setDefault (const StorageType &defaultValue)
 
bool getProperty (const string &propertyName, StorageType &outValue) const
 
void setProperty (const string &propertyName, StorageType value)
 
bool getMin (StorageType &outMin) const
 
bool getMax (StorageType &outMax) const
 
bool getMinIncrement (StorageType &outMinIncrement) const
 
bool getMaxIncrement (StorageType &outMaxIncrement) const
 
void setMin (StorageType min)
 
void setMax (StorageType max)
 
void setRange (StorageType min, StorageType max)
 
void setMinIncrement (StorageType minIncrement)
 
void setMaxIncrement (StorageType maxIncrement)
 
void setIncrement (StorageType minIncrement, StorageType maxIncrement)
 
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
 
unique_ptr< DataPiececlone () const override
 
- 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
 
virtual bool stageCurrentValue ()
 

Additional Inherited Members

- Protected Member Functions inherited from vrs::DataPieceValue< StorageType >
bool stageFrom (const DataPiece *) 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)
 
- 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 EnumType, typename StorageType>
class vrs::DataPieceEnum< EnumType, StorageType >

DataPieceValue specialization class to store enums more conveniently and safely.

This DataPiece type is very light layer on top of DataPieceValue. DataPieceEnum provides automatic casting between an enum type and an explicit POD type. DataPieceEnum is safer to use, because it gives explicit control over the numeric type used to store the enum in the file format.

ATTENTION! STORING ENUM VALUES IS RISKY!

Constructor & Destructor Documentation

◆ DataPieceEnum() [1/2]

template<typename EnumType , typename StorageType >
vrs::DataPieceEnum< EnumType, StorageType >::DataPieceEnum ( const string &  label)
inlineexplicit
Parameters
labelName for the DataPiece.

◆ DataPieceEnum() [2/2]

template<typename EnumType , typename StorageType >
vrs::DataPieceEnum< EnumType, StorageType >::DataPieceEnum ( const string &  label,
EnumType  defaultValue 
)
inline
Parameters
labelName for the DataPiece.
defaultValueDefault value for the DataPiece.

Member Function Documentation

◆ get() [1/2]

template<typename EnumType , typename StorageType >
EnumType vrs::DataPieceEnum< EnumType, StorageType >::get ( ) const
inline

Get the value in enum form. If the value isn't available, returns the default value.

Returns
The value as an enum.

◆ get() [2/2]

template<typename EnumType , typename StorageType >
bool vrs::DataPieceEnum< EnumType, StorageType >::get ( EnumType &  e) const
inline

Get the value in enum form, with test for availability.

Parameters
eA reference to the enum to get.
Returns
True if the value was set. If the value wasn't available, returns false.

◆ getDefault() [1/2]

template<typename EnumType , typename StorageType >
EnumType vrs::DataPieceEnum< EnumType, StorageType >::getDefault ( ) const
inline

Get default value.

Returns
Default value if one was specified, or default value for the enum.

◆ getDefault() [2/2]

template<typename EnumType , typename StorageType >
bool vrs::DataPieceEnum< EnumType, StorageType >::getDefault ( EnumType &  outDefault) const
inline

Get default value.

Parameters
referenceReference to the variable to set.
Returns
True if the value was set to an explicitly specified default value.

◆ set()

template<typename EnumType , typename StorageType >
bool vrs::DataPieceEnum< EnumType, StorageType >::set ( const EnumType  e)
inline

Set value in enum form.

Parameters
valueValue to set the DataPiece to.
Returns
False if the DataLayout is mapped, but this DataPiece is not mapped.

◆ setDefault()

template<typename EnumType , typename StorageType >
void vrs::DataPieceEnum< EnumType, StorageType >::setDefault ( const EnumType  defaultValue)
inline

Explicitly specify a default value.

Parameters
defaultValueValue to use as default.

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