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

Fixed size array of POD values. More...

#include <DataPieceArray.h>

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

Public Member Functions

 DataPieceArray (const string &label, size_t count)
 
template<size_t n>
 DataPieceArray (const string &label, size_t count, const T(&defaultValues)[n])
 
 DataPieceArray (const MakerBundle &bundle)
 
size_t getArraySize () const
 Get the size of the array.
 
const string & getElementTypeName () const override
 
size_t getVariableSize () const override
 
size_t collectVariableData (int8_t *, size_t) override
 
bool get (T *outValues, size_t count) const
 
bool get (T &outValue, size_t index) const
 
bool get (vector< T > &outValues) const
 
bool set (const T *values, size_t count)
 
bool set (const T &value, size_t index)
 
template<size_t n>
bool set (const T(&arr)[n])
 
bool set (const vector< T > &values)
 
const vector< T > & getDefault () const
 
void setDefault (const T *defaultValues, size_t count)
 
template<size_t n>
void setDefault (const T(&arr)[n])
 
void setDefault (const vector< T > &values)
 
void setProperty (const string &propertyName, T value)
 
bool getProperty (const string &propertyName, T &outValue) const
 
void setMin (T min)
 
void setMax (T max)
 
void setRange (T min, T max)
 
bool getMin (T &outMin) const
 
bool getMax (T &outMax) const
 
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 ()
 

Protected Member Functions

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)
 

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::DataPieceArray< T >

Fixed size array of POD values.

Array of type T and fixed size. The array is stored in DataLayout's fixed size buffer. The size of the array is defined at construction and may not change.

Constructor & Destructor Documentation

◆ DataPieceArray() [1/3]

template<typename T >
vrs::DataPieceArray< T >::DataPieceArray ( const string &  label,
size_t  count 
)
inline
Parameters
labelName for the DataPiece.
countNumber of elements in the fixes size-array.

◆ DataPieceArray() [2/3]

template<typename T >
template<size_t n>
vrs::DataPieceArray< T >::DataPieceArray ( const string &  label,
size_t  count,
const T(&)  defaultValues[n] 
)
inline
Parameters
labelName for the DataPiece.
countNumber of elements in the fixes size-array.
defaultValuesStatic array of default values.

◆ DataPieceArray() [3/3]

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

Member Function Documentation

◆ clone()

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

Clone data piece.

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

Implements vrs::DataPiece.

◆ collectVariableData()

template<typename T >
size_t vrs::DataPieceArray< T >::collectVariableData ( int8_t *  ,
size_t   
)
inlineoverridevirtual

Copy staged variable-size data to a specific location. [doesn't apply].

Implements vrs::DataPiece.

◆ get() [1/3]

template<typename T >
bool vrs::DataPieceArray< T >::get ( T &  outValue,
size_t  index 
) const
inline

get specific value in the array, by index.

Parameters
outValueReference to a value to set.
indexValue requested.
Returns
True if an actual data value was read. False, if a default value was used, or T's default constructor.

◆ get() [2/3]

template<typename T >
bool vrs::DataPieceArray< T >::get ( T *  outValues,
size_t  count 
) const
inline

copy a given number of values to a given location. If not enough values are available, default values are written. If not enough default values are available, T's default constructor is used to fill-in.

Parameters
outValuesPointer where to write the data.
countNumber of values requested.
Returns
True if the requested number of actual data values were copied, even if there were more values available than requested. Return false in all other cases.

◆ get() [3/3]

template<typename T >
bool vrs::DataPieceArray< T >::get ( vector< T > &  outValues) const
inline

Get values or default values.

Parameters
outValuesVector to set.
Returns
True if actual data values were set, false if default values were read.

◆ getDefault()

template<typename T >
const vector< T > & vrs::DataPieceArray< T >::getDefault ( ) const
inline

Get the array's default values.

Returns
Default values. The vector is empty if no default values were set.

◆ getElementTypeName()

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

Get the name of the element type <T>.

Implements vrs::DataPiece.

◆ getMax()

template<typename T >
bool vrs::DataPieceArray< T >::getMax ( T &  outMax) const
inline

Get maximum value for each element of the array.

Parameters
outMaxReference to set to the maximum valid value.
Returns
True if there is maximum value & outMax was set.

◆ getMin()

template<typename T >
bool vrs::DataPieceArray< T >::getMin ( T &  outMin) const
inline

Get minimum value for each element of the array.

Parameters
outMinReference to set to the minimum valid value.
Returns
True if there is minimum value & outMin was set.

◆ getProperty()

template<typename T >
bool vrs::DataPieceArray< T >::getProperty ( const string &  propertyName,
T &  outValue 
) const
inline

Get a property

Parameters
propertyNameName of the property.
outValueReference to a value to set.
Returns
True if the property exists and outValue was set, false otherwise.

◆ getVariableSize()

template<typename T >
size_t vrs::DataPieceArray< T >::getVariableSize ( ) const
inlineoverridevirtual

Get variable-size. 0 here, since this is a fixed size DataPiece. [doesn't apply].

Implements vrs::DataPiece.

◆ isAvailable()

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

Tell if a DataPiece value is available.

Returns
True if the value is available, false if the DataPiece could not be mapped.

Implements vrs::DataPiece.

◆ isSame()

template<typename T >
bool vrs::DataPieceArray< 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::DataPieceArray< 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()

template<typename T >
void vrs::DataPieceArray< 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::DataPieceArray< 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.

◆ set() [1/4]

template<typename T >
bool vrs::DataPieceArray< T >::set ( const T &  value,
size_t  index 
)
inline

Set one value of the array.

Parameters
valueReference to the value to write.
indexIndex of the array element to set.
Returns
True if the array was large enough, and the value could be written. Note: does not touch the other array values.

◆ set() [2/4]

template<typename T >
bool vrs::DataPieceArray< T >::set ( const T *  values,
size_t  count 
)
inline

Set array values.

Parameters
valuespointer to values to write.
countNumber of values to write.
Returns
True if values were written. Note: if more values are given than the size of the array, fewer values will be written, but the method still returns true. If not enough values are given to set the whole array, T's default constructor is used to init the remaining values.

◆ set() [3/4]

template<typename T >
template<size_t n>
bool vrs::DataPieceArray< T >::set ( const T(&)  arr[n])
inline

Set array values.

Parameters
arrC-style array.
Returns
True if values were written. Note: if more values are given than the size of the array, fewer values will be written, but the method still returns true. If not enough values are given to set the whole array, T's default constructor is used to init the remaining values.

◆ set() [4/4]

template<typename T >
bool vrs::DataPieceArray< T >::set ( const vector< T > &  values)
inline

Set array values.

Parameters
valuesVector of values to write.
Returns
True if values were written. Note: if more values are given than the size of the array, fewer values will be written, but the method still returns true. If not enough values are given to set the whole array, T's default constructor is used to init the remaining values.

◆ setDefault() [1/3]

template<typename T >
void vrs::DataPieceArray< T >::setDefault ( const T *  defaultValues,
size_t  count 
)
inline

Set the array's default values.

Parameters
defaultValuesPointer to the first default value.
countNumber of default values to use. Note: if fewer default values are passed that the size of the array, T's default constructor is used to have the exact count of default values.

◆ setDefault() [2/3]

template<typename T >
template<size_t n>
void vrs::DataPieceArray< T >::setDefault ( const T(&)  arr[n])
inline

Set the array's default values.

Parameters
arrC-style array ot default values. Note: if fewer default values are passed that the size of the array, T's default constructor is used to have the exact count of default values.

◆ setDefault() [3/3]

template<typename T >
void vrs::DataPieceArray< T >::setDefault ( const vector< T > &  values)
inline

Set the array's default values.

Parameters
defaultValuesVector of default values. Note: if fewer default values are passed that the size of the array, T's default constructor is used to have the exact count of default values.

◆ setMax()

template<typename T >
void vrs::DataPieceArray< T >::setMax ( max)
inline

Set the maximum valid value for each element of the array.

Parameters
maxMaximum valid value. Note: max checking is a sanity check operation only. Nothing prevents users of the API to set the values of the array any way they want.

◆ setMin()

template<typename T >
void vrs::DataPieceArray< T >::setMin ( min)
inline

Set the minimum valid value for each element of the array.

Parameters
minMinimum valid value. Note: min checking is a sanity check operation only. Nothing prevents users of the API to set the values of the array any way they want.

◆ setProperty()

template<typename T >
void vrs::DataPieceArray< T >::setProperty ( const string &  propertyName,
value 
)
inline

Set a property.

Parameters
propertyNameName of the property.
valueValue of the property.

◆ setRange()

template<typename T >
void vrs::DataPieceArray< T >::setRange ( min,
max 
)
inline

Set the min & max valid values for each element of the array.

Parameters
minMinimum valid value.
maxMaximum valid value. Note: min/max checking is a sanity check operation only. Nothing prevents users of the API to set the values of the array any way they want.

◆ stageFrom()

template<typename T >
bool vrs::DataPieceArray< 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: