CARMA C++
carma::util::Serializable Class Referenceabstract

Abstract Class used to allow object to serialize themselves into a byte array. More...

#include <carma/util/Serializable.h>

Inheritance diagram for carma::util::Serializable:
carma::correlator::lib::CorrelatorBand carma::correlator::lib::CorrelatorBaseline carma::correlator::lib::CorrelatorData carma::correlator::lib::CorrelatorHeader carma::correlator::lib::CorrelatorSideband carma::correlator::lib::CorrelatorStats carma::correlator::lib::CorrelatorDataTestSl carma::correlator::lib::CorrelatorDataTestSZA carma::correlator::lib::CorrelatorDataTestWb

Public Member Functions

void deserial (const char *byteArray, int byteArraySize)
 Call to initiate the reconstruction of the object from the byte Array. More...
 
void deserial (const ::std::vector< char > &byteVec)
 
void deserial (const ByteBuffer &byteBuffer)
 
int getTotalSerialBytes () const
 
void serialIntoByteArray (char *byteArray, int byteArraySize, int *totalSerialBytes) const
 
void serialIntoByteBuffer (ByteBuffer &byteBuffer) const
 
void serialIntoByteVec (::std::vector< char > &byteVec) const
 Write objects data members into a byte vector. More...
 
void serialize (char *const byteArray, int *const offset) const
 Write objects data members into a byte array. More...
 

Protected Member Functions

virtual void deserializeSwapVer0 (const char *byteArray, int *offset, int byteArraySize)=0
 Called to continue the reconstruction of member objects from the byte Array. More...
 
virtual void deserializeSwapVer1 (const char *byteArray, int *offset, int byteArraySize)=0
 
virtual void deserializeVer0 (const char *byteArray, int *offset, int byteArraySize)=0
 Called to continue the reconstruction of member objects from the byte Array. More...
 
virtual void deserializeVer1 (const char *byteArray, int *offset, int byteArraySize)=0
 
virtual int getSizeInBytes () const =0
 Return size in bytes of object. More...
 
virtual void mySerialize (char *byteArray, int *offset) const =0
 Called by serialize(). More...
 

Static Protected Member Functions

static int32_t getVersion ()
 
template<typename T >
static void pack (const ::std::vector< T > &tmpv, char *byteArray, int *offset)
 
template<typename T >
static void pack (const T tmp, char *byteArray, int *offset)
 
template<typename T >
static void unpack (T &val, const char *byteArray, int *offset, int byteArraySize)
 
template<typename T >
static void unpack (::std::vector< T > &tmpv, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (char &val, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (bool &val, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (short &val, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (int &val, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (long &val, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (float &val, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (double &val, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (::std::complex< float > &tmpv, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (::std::vector< short > &tmpv, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (::std::vector< int > &tmpv, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (::std::vector< float > &tmpv, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (::std::vector< ::std::complex< float > > &tmpv, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (unsigned int &tmpv, const char *byteArray, int *offset, int byteArraySize)
 
static void unpackSwap (carma::correlator::lib::Polarization &val, const char *byteArray, int *offset, int byteArraySize)
 

Static Protected Attributes

static int32_t version_
 

Detailed Description

Abstract Class used to allow object to serialize themselves into a byte array.

This class uses the 'reader makes right' paradigm in which the writer of the data will write in its native endianess and the reader determines if it needs to swap bytes. This allows high efficiency when writer and reader are of the same architecture. The first byte of the packed array indicates the endianess of the writer(true for little endian and false for big-endian).

Definition at line 32 of file Serializable.h.

Member Function Documentation

void carma::util::Serializable::deserial ( const char *  byteArray,
int  byteArraySize 
)

Call to initiate the reconstruction of the object from the byte Array.

Subclasses should use the unpack() methods to reconstruct data.

Definition at line 533 of file Serializable.h.

virtual void carma::util::Serializable::deserializeSwapVer0 ( const char *  byteArray,
int *  offset,
int  byteArraySize 
)
protectedpure virtual

Called to continue the reconstruction of member objects from the byte Array.

This method SHOULD swap bytes when reconstructing object. Subclasses should use the unpackSwap() methods to reconstruct data. All classes implementing Serializable.h must define this. The version number goes hand in hand with version= in the inline serialIntoByteVec() method.

Implemented in carma::correlator::lib::CorrelatorHeader, carma::correlator::lib::CorrelatorSideband, carma::correlator::lib::CorrelatorData, carma::correlator::lib::CorrelatorBand, carma::correlator::lib::CorrelatorBaseline, and carma::correlator::lib::CorrelatorStats.

virtual void carma::util::Serializable::deserializeVer0 ( const char *  byteArray,
int *  offset,
int  byteArraySize 
)
protectedpure virtual

Called to continue the reconstruction of member objects from the byte Array.

This method should NOT swap bytes when reconstructing object. Subclasses should use the unpack() methods to reconstruct data. All classes implementing Serializable.h must define this. The version number goes hand in hand with version= in the serialIntoByteVec() method.

Implemented in carma::correlator::lib::CorrelatorHeader, carma::correlator::lib::CorrelatorSideband, carma::correlator::lib::CorrelatorData, carma::correlator::lib::CorrelatorBand, carma::correlator::lib::CorrelatorBaseline, and carma::correlator::lib::CorrelatorStats.

virtual void carma::util::Serializable::mySerialize ( char *  byteArray,
int *  offset 
) const
protectedpure virtual
void carma::util::Serializable::serialIntoByteVec ( ::std::vector< char > &  byteVec) const

Write objects data members into a byte vector.

The vector will be resized as needed for you. Use this method on the top most object.

Definition at line 587 of file Serializable.h.

void carma::util::Serializable::serialize ( char *const  byteArray,
int *const  offset 
) const

Write objects data members into a byte array.

Definition at line 660 of file Serializable.h.


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