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

Container of data pointers, to tell where to write data when reading a record. More...

#include <DataReference.h>

Public Member Functions

 DataReference (void *data1=nullptr, uint32_t size1=0, void *data2=nullptr, uint32_t size2=0)
 
template<class T >
 DataReference (vector< T > &vectorT, void *data=nullptr, uint32_t size=0)
 
template<class T , class U >
 DataReference (vector< T > &vectorT, vector< U > &vectorU)
 
template<class T , class U >
 DataReference (T &object, vector< U > &vectorU)
 
template<class T >
 DataReference (T &object, void *data=nullptr, uint32_t size=0)
 
void useRawData (void *data1, uint32_t size1, void *data2=nullptr, uint32_t size2=0)
 
template<class T >
void useVector (vector< T > &vectorT, void *data=nullptr, uint32_t size=0)
 
template<class T >
void useObject (T &object, void *data=nullptr, uint32_t size=0)
 
template<class T , class U >
void useVectors (vector< T > &vectorT, vector< U > &vectorU)
 
template<class T , class U >
void useObjects (T &object1, U &object2)
 
uint32_t getSize () const
 
void copyTo (void *destination) const
 
int readFrom (FileHandler &file, uint32_t &outReadSize)
 
void * getDataPtr1 () const
 
uint32_t getDataSize1 () const
 
void * getDataPtr2 () const
 
uint32_t getDataSize2 () const
 

Detailed Description

Container of data pointers, to tell where to write data when reading a record.

This is essentially a wrapper for two pairs of pointers to a buffer and the size of that buffer, both of which may be null.

Examples:

Reference a single pointer/length:

uint8_t buffer[kBufferLength]; DataReference dataReference(buffer, kBufferLength);

Reference the content of a POD struct:

struct { int value; double otherValue; } someStruct; DataReference dataReference(someStruct);

Reference the content of a struct and a pointer+length:

uint8_t buffer[kBufferLength]; struct { int value; double otherValue; } someStruct; DataReference dataReference(someStruct, buffer, kBufferLength);

Constructor & Destructor Documentation

◆ DataReference() [1/5]

vrs::DataReference::DataReference ( void *  data1 = nullptr,
uint32_t  size1 = 0,
void *  data2 = nullptr,
uint32_t  size2 = 0 
)
inlineexplicit
Parameters
data1Pointer to first block of bytes.
size1Size of first block of bytes.
data2Pointer to second block of bytes.
size2Size of second block of bytes.

◆ DataReference() [2/5]

template<class T >
vrs::DataReference::DataReference ( vector< T > &  vectorT,
void *  data = nullptr,
uint32_t  size = 0 
)
inlineexplicit
Parameters
vectorTVector of POD objects of type T to read.
dataPointer to second block of bytes.
sizeSize of second block of bytes.

◆ DataReference() [3/5]

template<class T , class U >
vrs::DataReference::DataReference ( vector< T > &  vectorT,
vector< U > &  vectorU 
)
inline
Parameters
vectorTVector of POD objects of type T to read.
vectorUVector of POD objects of type U to read.

◆ DataReference() [4/5]

template<class T , class U >
vrs::DataReference::DataReference ( T &  object,
vector< U > &  vectorU 
)
inline
Parameters
objectPOD object to read.
vectorUVector of POD objects of type U to read.

◆ DataReference() [5/5]

template<class T >
vrs::DataReference::DataReference ( T &  object,
void *  data = nullptr,
uint32_t  size = 0 
)
inlineexplicit
Parameters
objectPOD object to read.
dataPointer to second block of bytes.
sizeSize of second block of bytes.

Member Function Documentation

◆ copyTo()

void vrs::DataReference::copyTo ( void *  destination) const

Copy referenced data to a specific location, in one stream of bytes. The destination buffer must be large enough for the entire data.

Parameters
destinationPointer where to write everything.

◆ getDataPtr1()

void * vrs::DataReference::getDataPtr1 ( ) const
inline

Get pointer to first chunk of data. Might be nullptr.

Returns
Pointer to first chunk of data.

◆ getDataPtr2()

void * vrs::DataReference::getDataPtr2 ( ) const
inline

Get pointer to second chunk of data. Might be nullptr.

Returns
Pointer to second chunk of data.

◆ getDataSize1()

uint32_t vrs::DataReference::getDataSize1 ( ) const
inline

Get size in bytes of the fist chunk of data. Might be 0.

Returns
Number of bytes.

◆ getDataSize2()

uint32_t vrs::DataReference::getDataSize2 ( ) const
inline

Get size in bytes of the second chunk of data. Might be 0.

Returns
Number of bytes.

◆ getSize()

uint32_t vrs::DataReference::getSize ( ) const
inline
Returns
Number of bytes referenced, in total.

◆ readFrom()

int vrs::DataReference::readFrom ( FileHandler file,
uint32_t &  outReadSize 
)

Fill the referenced data from a file (uncompressed).

Parameters
fileOpen file to read from.
outReadSizeNumber of bytes actually read. Might be less than the size of the DataReference, if an error occurred.
Returns
0 if no error happened, and enough data was read. Otherwise, set to a file system error.

◆ useObject()

template<class T >
void vrs::DataReference::useObject ( T &  object,
void *  data = nullptr,
uint32_t  size = 0 
)
inline
Parameters
objectPOD object to read.
dataPointer to second block of bytes.
sizeSize of second block of bytes.

◆ useObjects()

template<class T , class U >
void vrs::DataReference::useObjects ( T &  object1,
U &  object2 
)
inline
Parameters
object1First POD object to read.
object2Second POD object to read.

◆ useRawData()

void vrs::DataReference::useRawData ( void *  data1,
uint32_t  size1,
void *  data2 = nullptr,
uint32_t  size2 = 0 
)
Parameters
data1Pointer to first block of bytes.
size1Size of first block of bytes.
data2Pointer to second block of bytes.
size2Size of second block of bytes.

◆ useVector()

template<class T >
void vrs::DataReference::useVector ( vector< T > &  vectorT,
void *  data = nullptr,
uint32_t  size = 0 
)
inline
Parameters
vectorTVector of POD objects of type T to read.
dataPointer to second block of bytes.
sizeSize of second block of bytes.

◆ useVectors()

template<class T , class U >
void vrs::DataReference::useVectors ( vector< T > &  vectorT,
vector< U > &  vectorU 
)
inline
Parameters
vectorTVector of POD objects of type T to read.
vectorUVector of POD objects of type U to read.

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