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

Vector of type T and variable size. More...

#include <DataPieceVector.h>

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

Public Member Functions

 DataPieceVector (const string &label)
 
 DataPieceVector (const MakerBundle &bundle)
 
const string & getElementTypeName () const override
 
size_t getVariableSize () const override
 
size_t collectVariableData (int8_t *data, size_t bufferSize) override
 
const vector< T > & stagedValues () const
 
vector< T > & stagedValues ()
 
void stage (const vector< T > &values)
 
void stage (vector< T > &&values)
 
void stage (const T *values, size_t count)
 
template<size_t n>
void stage (const T(&arr)[n])
 
bool get (vector< T > &outValues) const
 
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 setDefault (vector< 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 stage (const string *values, size_t count)
 
size_t getVariableSize () const
 
size_t collectVariableData (int8_t *data, size_t bufferSize)
 
bool get (vector< string > &outValues) const
 
void print (ostream &out, const string &indent) const
 
void printCompact (ostream &out, const string &indent) const
 
void stage (const string *values, size_t count)
 
size_t getVariableSize () const
 
size_t collectVariableData (int8_t *data, size_t bufferSize)
 
void setDefault (const string *defaultValues, size_t count)=delete
 
bool get (vector< string > &outValues) const
 
void print (ostream &out, const string &indent) const
 
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::DataPieceVector< T >

Vector of type T and variable size.

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

Constructor & Destructor Documentation

◆ DataPieceVector() [1/2]

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

◆ DataPieceVector() [2/2]

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

Member Function Documentation

◆ clone()

template<typename T >
unique_ptr< DataPiece > vrs::DataPieceVector< 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() [1/3]

size_t vrs::DataPieceVector< string >::collectVariableData ( int8_t *  data,
size_t  bufferSize 
)
virtual

Copy the staged variable-size to a location.

Parameters
dataPointer where to copy the variable-size data.
bufferSizeMax number of bytes to copy.
Returns
Number of bytes actually copied.

Implements vrs::DataPiece.

◆ collectVariableData() [2/3]

size_t vrs::DataPieceVector< string >::collectVariableData ( int8_t *  data,
size_t  bufferSize 
)
virtual

Copy the staged variable-size to a location.

Parameters
dataPointer where to copy the variable-size data.
bufferSizeMax number of bytes to copy.
Returns
Number of bytes actually copied.

Implements vrs::DataPiece.

◆ collectVariableData() [3/3]

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

Copy the staged vector 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::DataPieceVector< T >::get ( vector< T > &  outValues) const
inline

Get read values or default values in a vector.

Parameters
outValuesReference to a vector<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 vector< T > & vrs::DataPieceVector< 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::DataPieceVector< T >::getElementTypeName ( ) const
inlineoverridevirtual

Get the name of the element type <T>.

Implements vrs::DataPiece.

◆ getVariableSize() [1/3]

size_t vrs::DataPieceVector< string >::getVariableSize ( ) const
virtual

Get the size of variable-size DataPiece staged value.

Returns
0 for fixed-size DataPieces, otherwise, the number of bytes required to store the variable-size staged value.

Implements vrs::DataPiece.

◆ getVariableSize() [2/3]

size_t vrs::DataPieceVector< string >::getVariableSize ( ) const
virtual

Get the size of variable-size DataPiece staged value.

Returns
0 for fixed-size DataPieces, otherwise, the number of bytes required to store the variable-size staged value.

Implements vrs::DataPiece.

◆ getVariableSize() [3/3]

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

Get the size of the staged vector, if any.

Returns
Number of bytes to store the staged vector.

Implements vrs::DataPiece.

◆ isAvailable()

template<typename T >
bool vrs::DataPieceVector< 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::DataPieceVector< 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() [1/3]

void vrs::DataPieceVector< string >::print ( ostream &  out,
const string &  indent 
) const
virtual

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.

◆ print() [2/3]

void vrs::DataPieceVector< string >::print ( ostream &  out,
const string &  indent 
) const
virtual

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.

◆ print() [3/3]

template<typename T >
void vrs::DataPieceVector< 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/3]

void vrs::DataPieceVector< 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/3]

void vrs::DataPieceVector< 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() [3/3]

template<typename T >
void vrs::DataPieceVector< 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::DataPieceVector< 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/4]

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

Set the default values.

Parameters
defaultValuesPointer to the default values.
countNumber of default values.

◆ setDefault() [2/4]

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

Set the default values using a C-style fixed size array.

Parameters
arrC-style fixed size array of default values.

◆ setDefault() [3/4]

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

Set default values using a vector.

Parameters
valuesVector of values to use a default.

◆ setDefault() [4/4]

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

Set default values using a vector.

Parameters
valuesVector of values to use a default.

◆ stage() [1/4]

template<typename T >
void vrs::DataPieceVector< T >::stage ( const T *  values,
size_t  count 
)
inline

Stage an array values.

Parameters
arrC-style array.
countnumber of values to stage

◆ stage() [2/4]

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

Stage an array of values.

Parameters
arrC-style array.

◆ stage() [3/4]

template<typename T >
void vrs::DataPieceVector< T >::stage ( const vector< 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() [4/4]

template<typename T >
void vrs::DataPieceVector< T >::stage ( vector< 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::DataPieceVector< 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 >
vector< T > & vrs::DataPieceVector< T >::stagedValues ( )
inline

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

Returns
A reference to the staged vector<T>.

◆ stagedValues() [2/2]

template<typename T >
const vector< T > & vrs::DataPieceVector< T >::stagedValues ( ) const
inline

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

Returns
A const reference to the staged vector<T>.

◆ stageFrom()

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