VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
vrs::ManualDataLayout Class Reference

Specialized DataLayout for programmatic DataLayout generation. More...

#include <DataLayout.h>

Inheritance diagram for vrs::ManualDataLayout:
vrs::DataLayout

Public Member Functions

 ManualDataLayout (const string &json)
 
 ManualDataLayout ()
 For manual construction using "add()": don't forget to call endLayout() when you're done.
 
 ManualDataLayout (const DataLayout &layout)
 
DataPiece * add (unique_ptr< DataPiece > dataPiece)
 
void endLayout ()
 End the construction of the DataLayout. Do not call add() after calling this method.
 
- Public Member Functions inherited from vrs::DataLayout
 DataLayout (const DataLayout &)=delete
 
 DataLayout (const DataLayout &&)=delete
 
DataLayout & operator= (const DataLayout &)=delete
 
DataLayout & operator= (const DataLayout &&)=delete
 
ContentBlock getContentBlock () const
 
vector< int8_t > & getFixedData ()
 
vector< int8_t > & getVarData ()
 
size_t getFixedDataSizeNeeded () const
 
void initDataPiecesToDefaultValue ()
 
size_t getVarDataSizeFromIndex () const
 
size_t getVarDataSizeNeeded () const
 
void collectVariableDataAndUpdateIndex ()
 
void collectVariableDataAndUpdateIndex (void *destination)
 
void getRawData (vector< int8_t > &outRawData) const
 
void stageCurrentValues ()
 
bool copyClonedDataPieceValues (const DataLayout &originalLayout)
 
size_t copyDataPieceValuesFromMappedLayout (const DataLayout &mappedLayout)
 
bool mapLayout (DataLayout &targetLayout)
 
bool isMapped () const
 
bool hasAllRequiredPieces () const
 
void requireAllPieces ()
 Mark all the fields of the layout as required.
 
void printLayout (ostream &out, const string &indent="") const
 
void printLayoutCompact (ostream &out, const string &indent="") const
 
string asJson (JsonFormatProfile profile) const
 
string asJson (const JsonFormatProfileSpec &profile=JsonFormatProfileSpec()) const
 
string getListOfPiecesSpec () const
 Get a text list of fields, types & names, one per line. Useful for tests.
 
bool isSame (const DataLayout &otherLayout) const
 
template<class T >
const DataPieceValue< T > * findDataPieceValue (const string &label) const
 
template<class T >
DataPieceValue< T > * findDataPieceValue (const string &label)
 
template<class T >
const DataPieceArray< T > * findDataPieceArray (const string &label, size_t arraySize) const
 
template<class T >
DataPieceArray< T > * findDataPieceArray (const string &label, size_t arraySize)
 
template<class T >
const DataPieceVector< T > * findDataPieceVector (const string &label) const
 
template<class T >
DataPieceVector< T > * findDataPieceVector (const string &label)
 
template<class T >
const DataPieceStringMap< T > * findDataPieceStringMap (const string &label) const
 
template<class T >
DataPieceStringMap< T > * findDataPieceStringMap (const string &label)
 
const DataPieceString * findDataPieceString (const string &label) const
 
DataPieceString * findDataPieceString (const string &label)
 
void forEachDataPiece (const std::function< void(const DataPiece *)> &, DataPieceType type=DataPieceType::Undefined) const
 
void forEachDataPiece (const std::function< void(DataPiece *)> &, DataPieceType type=DataPieceType::Undefined)
 Same as above, but as a non-const version.
 
bool isVarDataIndexValid () const
 
size_t getDeclaredFixedDataPiecesCount () const
 
size_t getDeclaredVarDataPiecesCount () const
 
size_t getAvailableFixedDataPiecesCount () const
 
size_t getAvailableVarDataPiecesCount () const
 

Additional Inherited Members

- Static Public Member Functions inherited from vrs::DataLayout
static unique_ptr< DataLayout > makeFromJson (const string &json)
 
- Static Public Attributes inherited from vrs::DataLayout
static const size_t kNotFound = numeric_limits<size_t>::max()
 Special OffsetAndLength offset value marking that a piece of data isn't available.
 
static const size_t kVariableSize = numeric_limits<size_t>::max() - 1
 Special value used for a DataPiece size, telling that that DataPiece has a variable size.
 
- Protected Member Functions inherited from vrs::DataLayout
template<class T >
T * getFixedData (size_t offset, size_t size)
 
const IndexEntry * getVarSizeIndex () const
 
IndexEntry * getVarSizeIndex ()
 
template<class T >
T * getVarData (size_t varPieceIndex, size_t &outCount)
 
DataPiece * getPieceByIndex (size_t pieceIndex)
 Get a piece by index, fixed size pieces first, then variable size pieces.
 
template<class T >
T * getMappedPiece (size_t pieceIndex) const
 Get a typed piece by index in the mapped datalayout, exclusively.
 
void initLayout ()
 
void serialize (JsonWrapper &rj, const JsonFormatProfileSpec &profile) const
 
- Static Protected Member Functions inherited from vrs::DataLayout
static DataPiece * findMatch (DataPiece *piece, const vector< DataPiece * > &pieces, size_t &start)
 
static bool mapPieces (const vector< DataPiece * > &searchPieces, const vector< DataPiece * > &givenPieces)
 
static size_t copyMappedValues (const vector< DataPiece * > &pieces, const vector< DataPiece * > &mappedPieces)
 
- Protected Attributes inherited from vrs::DataLayout
vector< DataPiece * > fixedSizePieces_
 Ordered fixed-size DataPieces.
 
vector< DataPiece * > varSizePieces_
 Ordered variable-size DataPieces.
 
vector< int8_t > fixedData_
 Buffer to hold fixed-size pieces, and the index of var size pieces (if any).
 
size_t fixedDataSizeNeeded_ {}
 Byte count for all the fixed size pieces + var size index.
 
vector< int8_t > varData_
 Buffer holding variable-size pieces, after they've been collected, or read from disk.
 
bool hasAllRequiredPieces_ {true}
 Tells all the required pieces have been mapped successfully.
 
DataLayout * mappedDataLayout_ {}
 DataLayout this layout has been mapped to, if any.
 

Detailed Description

Specialized DataLayout for programmatic DataLayout generation.

Helper class to build a DataLayout manually, piece-by-piece. Make sure to call endLayout as soon as you're no longer adding pieces, to release a global lock.

Constructor & Destructor Documentation

◆ ManualDataLayout() [1/2]

vrs::ManualDataLayout::ManualDataLayout ( const string &  json)
explicit

Build a DataLayout from a json definition. This is how VRS rebuilds DataLayout objects when reading a file.

◆ ManualDataLayout() [2/2]

vrs::ManualDataLayout::ManualDataLayout ( const DataLayout &  layout)
explicit

For manual construction, based on an existing layout, cloning all the pieces. Add more pieces using "add()", but don't forget to call endLayout() when you're done.

Member Function Documentation

◆ add()

DataPiece * vrs::ManualDataLayout::add ( unique_ptr< DataPiece >  dataPiece)

Transfer ownership a constructed DataPiece for the ManualDataLayout object to hold. This ensures that all the DataPiece objects of a DataLayout will be deleted when the DataLayout object they belong to is deleted.

Parameters
dataPiecethe DataPiece object to give the DataLayout.
Returns
A straight pointer to the DataPiece object, for convenience. Do not call delete on it!

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