VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
vrs::DataPiece Class Referenceabstract

Abstract class representing a piece of information part of a DataLayout. More...

#include <DataPieces.h>

Inheritance diagram for vrs::DataPiece:
vrs::DataPieceArray< Matrix3Dd > vrs::DataPieceStringMap< string > vrs::DataPieceStringMap< Matrix4Dd > vrs::DataPieceValue< StorageType > vrs::DataPieceValue< uint8_t > vrs::DataPieceValue< uint32_t > vrs::DataPieceValue< ImageSpecType > vrs::DataPieceValue< ContentBlockSizeType > vrs::DataPieceValue< double > vrs::DataPieceValue< uint64_t > vrs::DataPieceValue< float > vrs::DataPieceValue< Point3Dd > vrs::DataPieceVector< float > vrs::DataPieceVector< vrs::MatrixND > vrs::DataPieceVector< Point3Df > vrs::DataPieceVector< string > vrs::DataPieceArray< T > vrs::DataPieceString vrs::DataPieceStringMap< T > vrs::DataPieceValue< T > vrs::DataPieceVector< T >

Classes

struct  MakerBundle
 

Public Member Functions

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 size_t getVariableSize () const =0
 
virtual size_t collectVariableData (int8_t *data, size_t bufferSize)=0
 
virtual const string & getElementTypeName () const =0
 
virtual bool isAvailable () const =0
 
virtual void print (ostream &out, const string &indent="") const =0
 
virtual void printCompact (ostream &out, const string &indent="") const =0
 
virtual void serialize (JsonWrapper &jsonWrapper, const JsonFormatProfileSpec &profile)
 
virtual bool stageCurrentValue ()
 
virtual unique_ptr< DataPiececlone () const =0
 Create a new DataPiece of the same type, with the same label.
 

Protected Member Functions

 DataPiece (const string &label, DataPieceType type, size_t size)
 
bool isMatch (const DataPiece &rhs) const
 Match signature only.
 
virtual bool isSame (const DataPiece *rhs) const
 Match signature & properties (default value, min/max, etc).
 
void setOffset (size_t offset)
 
virtual bool stageFrom (const DataPiece *original)=0
 Stage value from another piece known to be of the same type.
 

Protected Attributes

const string label_
 
const DataPieceType pieceType_
 
const size_t fixedSize_
 
size_t offset_
 
DataLayoutlayout_
 
map< string, string > tags_
 
bool required_
 

Static Protected Attributes

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.
 

Friends

class DataLayout
 

Detailed Description

Abstract class representing a piece of information part of a DataLayout.

DataPiece objects have a type (DataPieceType) and label (a text name), which together are enough to identify uniquely a DataPiece of a particular DataLayout. See DataLayout for more details.

Constructor & Destructor Documentation

◆ DataPiece()

vrs::DataPiece::DataPiece ( const string &  label,
DataPieceType  type,
size_t  size 
)
protected

Constructor, called by derived types exclusively.

Parameters
labelText name.
typeA DataPieceType.
sizeSize in bytes of the DataPiece, or the constant: DataLayout::kVariableSize.

Member Function Documentation

◆ clone()

virtual unique_ptr< DataPiece > vrs::DataPiece::clone ( ) const
pure virtual

◆ collectVariableData()

virtual size_t vrs::DataPiece::collectVariableData ( int8_t *  data,
size_t  bufferSize 
)
pure virtual

◆ getDataLayout()

const DataLayout & vrs::DataPiece::getDataLayout ( ) const
inline

Get the DataLayout owning this DataPiece.

Returns
The DataLayout.

◆ getDescription()

bool vrs::DataPiece::getDescription ( string &  outDescription) const
inline

Get the description of a DataPiece.

Parameters
outDescriptionReference to a string to set.
Returns
True, if the unit tag was found, and outDescription was set. False, otherwise.

◆ getElementTypeName()

virtual const string & vrs::DataPiece::getElementTypeName ( ) const
pure virtual

◆ getFixedSize()

size_t vrs::DataPiece::getFixedSize ( ) const
inline

Get the number of bytes needed to store the DataPiece's value.

Returns
A number of bytes, or DataLayout::kVariableSize.

◆ getLabel()

const string & vrs::DataPiece::getLabel ( ) const
inline

Get the text label of this DataPiece.

Returns
The label.

◆ getOffset()

size_t vrs::DataPiece::getOffset ( ) const
inline

Get the offset of the DataPiece in the DataLayout. For fixed-size DataPiece objects, it's the memory index in the fixed size data buffer. For variable-size DataPiece objects, it's the index of the variable DataPiece. For both: if the DataLayout was mapped to another, but this particular DataPiece could not be mapped in the target DataLayout, the offset value is set to DataLayout::kNotFound.

Returns
Offset value, or DataLayout::kNotFound if the DataPiece was not mapped.

◆ getPieceType()

DataPieceType vrs::DataPiece::getPieceType ( ) const
inline

Get the type of the DataPiece.

Returns
The DataPieceType.

◆ getTag()

bool vrs::DataPiece::getTag ( const string &  tagName,
string &  outTag 
) const

Get a DataPiece tag.

Parameters
tagNameName of the tag to retrieve.
outTagReference to a string to set.
Returns
True, if the tag was found, and outTag was set. False, otherwise.

◆ getTypeName()

string vrs::DataPiece::getTypeName ( ) const

Get the type name of the DataPiece.

Returns
PieceTypeName<DataType> e.g. "value<double>"

◆ getUnit()

bool vrs::DataPiece::getUnit ( string &  outUnit) const
inline

Get the unit of a DataPiece.

Parameters
outUnitReference to a string to set.
Returns
True, if the unit tag was found, and outUnit was set. False, otherwise.

◆ getVariableSize()

virtual size_t vrs::DataPiece::getVariableSize ( ) const
pure virtual

◆ hasFixedSize()

bool vrs::DataPiece::hasFixedSize ( ) const
inline

Tell if the DataPiece has a fixed-size.

Returns
True if the DataPiece needs the same memory space, no matter what the value is.

◆ isAvailable()

virtual bool vrs::DataPiece::isAvailable ( ) const
pure virtual

◆ isRequired()

bool vrs::DataPiece::isRequired ( ) const
inline

Tell if the DataPiece requires to be mapped for the mapping of the DataLayout to be considered successful.

Returns
True if the DataPiece must be mapped.

◆ isSame()

bool vrs::DataPiece::isSame ( const DataPiece rhs) const
protectedvirtual

◆ print()

virtual void vrs::DataPiece::print ( ostream &  out,
const string &  indent = "" 
) const
pure virtual

◆ printCompact()

virtual void vrs::DataPiece::printCompact ( ostream &  out,
const string &  indent = "" 
) const
pure virtual

◆ serialize()

void vrs::DataPiece::serialize ( JsonWrapper &  jsonWrapper,
const JsonFormatProfileSpec profile 
)
virtual

◆ setDescription()

void vrs::DataPiece::setDescription ( const string &  description)
inline

Set the description of a DataPiece.

Parameters
descriptionHuman readable description of the DataPiece.

◆ setRequired()

void vrs::DataPiece::setRequired ( bool  required = true)
inline

Specify if the DataPiece is required when mapping to another DataLayout.

Parameters
requiredTrue if mapping the DataPiece successfully is required.

◆ setTag()

void vrs::DataPiece::setTag ( const string &  tagName,
const string &  tag 
)
inline

Set a DataPiece tag.

Parameters
tagNameName of the tag to set.
tagValue of the tag.

◆ setUnit()

void vrs::DataPiece::setUnit ( const string &  unit)
inline

Set the unit of a DataPiece.

Parameters
unitUnit of the DataPiece (preferably, a SI unit like "m", or "ms").

◆ stageCurrentValue()

virtual bool vrs::DataPiece::stageCurrentValue ( )
inlinevirtual

Take the current value of the field, and stage it for writing during record creation. This operation does nothing for fixed size fields, which value & stage data are the same. For variable size fields, the value is read from the DataLayout's variable size data buffer, and staged as the value to write out.

Returns
True if the value is available and was staged.

Reimplemented in vrs::DataPieceString, vrs::DataPieceStringMap< T >, vrs::DataPieceStringMap< Matrix4Dd >, vrs::DataPieceStringMap< string >, vrs::DataPieceVector< T >, vrs::DataPieceVector< float >, vrs::DataPieceVector< Point3Df >, vrs::DataPieceVector< string >, and vrs::DataPieceVector< vrs::MatrixND >.

◆ stageFrom()

virtual bool vrs::DataPiece::stageFrom ( const DataPiece original)
protectedpure virtual

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