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:
-
A magic value is used to indicate the start of an object.
-
The length defines the total size of the object in the blob (including the header). It may not always be possible to store the length. In that case the length is 0.
-
The version defines the object version. Because blobs can be persistent (e.g. in a database), it makes it possible to handle older instances of a class.
-
The name defines the object type. In principle it is the name of the class. Functions in TypeNames.h can be used to generate the name of a templated class.
-
The name length gives the actual length of the name.
-
The reserved name length can be somewhat more in order to achieve that the data thereafter is aligned on 8-byte boundary.
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;
};
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.