DP3
Public Member Functions | Static Public Member Functions | Friends | List of all members
dp3::blob::BlobHeader Class Reference

Standard header for a blob. More...

#include <BlobHeader.h>

Public Member Functions

 BlobHeader (int version=0, unsigned int level=0)
 Construct for the given name and version. More...
 
bool checkMagicValue () const
 
dp3::common::DataFormat getDataFormat () const
 Get the data format. More...
 
unsigned int getHeaderLength () const
 Get the length of the total header (thus including objecttype). More...
 
uint64_t getLength () const
 Get the length of the blob. Data will be converted if needed. More...
 
unsigned int getNameLength () const
 Get the name length. More...
 
int getVersion () const
 Get the version. Data will be converted if needed. More...
 
unsigned int lengthOffset () const
 Get the offset of the length. More...
 
bool mustConvert () const
 
void setLength (uint64_t length)
 Set the length of the blob. More...
 
void setLocalDataFormat ()
 Set the data format to local. Useful after data is converted in place. More...
 

Static Public Member Functions

static uint32_t bobMagicValue ()
 Get the begin-of-blob magic value. More...
 
static uint32_t eobMagicValue ()
 Get the end-of-blob magic value. More...
 

Friends

class BlobIStream
 
class BlobOStream
 

Detailed Description

Standard header for a blob.

Blob stands for binary large object. The LOFAR Common software provides classes to serialize one or more objects into a blob and to de-serialize the blob to objects. To be sure that a blob is interpreted in the correct way, each object in it will be preceeded by a header. The header contains the following information:

This class is meant for handling blobs in a static and in a dynamic way. Handling blobs in a dynamic way is done by means of the BlobOStream and BlobIStream classes. A blob can be created statically by putting a BlobHeader object ahead of the data. This mode will be used in the CEPFrame environment. For this mode the class is templated with the length of the name as the template parameter. For example:

class SomeClass {
BlobHeader<9> itsHeader;
dcomplex itsData[10][20];
};
SomeClass::SomeClass() : itsHeader("SomeClass", 1)
{ itsHeader.setLength (sizeof(SomeClass)); }
std::complex< double > dcomplex
Definition: Simulator.h:63

Because blobs can be created on one machine and retrieved on another, care has to be taken that data type sizes and alignment are the same everywhere. For this reason standard data types are defined in LofarTypedefs.h. Data in a CEPFrame DataPacket should be declared such that longer data types are declared first. In this way alignment should never be a problem. Care has been taken that a BlobHeader object does not disturb alignment. So it is always aligned on a double boundary and its length is always a multiple of 8.

Constructor & Destructor Documentation

◆ BlobHeader()

dp3::blob::BlobHeader::BlobHeader ( int  version = 0,
unsigned int  level = 0 
)

Construct for the given name and version.

Member Function Documentation

◆ bobMagicValue()

static uint32_t dp3::blob::BlobHeader::bobMagicValue ( )
inlinestatic

Get the begin-of-blob magic value.

◆ checkMagicValue()

bool dp3::blob::BlobHeader::checkMagicValue ( ) const
inline

◆ eobMagicValue()

static uint32_t dp3::blob::BlobHeader::eobMagicValue ( )
inlinestatic

Get the end-of-blob magic value.

◆ getDataFormat()

dp3::common::DataFormat dp3::blob::BlobHeader::getDataFormat ( ) const
inline

Get the data format.

◆ getHeaderLength()

unsigned int dp3::blob::BlobHeader::getHeaderLength ( ) const
inline

Get the length of the total header (thus including objecttype).

◆ getLength()

uint64_t dp3::blob::BlobHeader::getLength ( ) const
inline

Get the length of the blob. Data will be converted if needed.

◆ getNameLength()

unsigned int dp3::blob::BlobHeader::getNameLength ( ) const
inline

Get the name length.

◆ getVersion()

int dp3::blob::BlobHeader::getVersion ( ) const
inline

Get the version. Data will be converted if needed.

◆ lengthOffset()

unsigned int dp3::blob::BlobHeader::lengthOffset ( ) const
inline

Get the offset of the length.

◆ mustConvert()

bool dp3::blob::BlobHeader::mustConvert ( ) const
inline

Test if the data format in the header mismatches the data format of this machine, thus if data have to be converted.

◆ setLength()

void dp3::blob::BlobHeader::setLength ( uint64_t  length)
inline

Set the length of the blob.

◆ setLocalDataFormat()

void dp3::blob::BlobHeader::setLocalDataFormat ( )

Set the data format to local. Useful after data is converted in place.

Friends And Related Function Documentation

◆ BlobIStream

friend class BlobIStream
friend

◆ BlobOStream

friend class BlobOStream
friend

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