CARMA C++
|
Abstract Class used to allow object to serialize themselves into a byte array. More...
#include <carma/util/Serializable.h>
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 Attributes | |
static int32_t | version_ |
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.
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.
|
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.
|
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.
|
protectedpure virtual |
Return size in bytes of object.
Implemented in carma::correlator::lib::CorrelatorHeader, carma::correlator::lib::CorrelatorSideband, carma::correlator::lib::CorrelatorBaseline, carma::correlator::lib::CorrelatorBand, carma::correlator::lib::CorrelatorStats, and carma::correlator::lib::CorrelatorData.
|
protectedpure virtual |
Called by serialize().
Must be implemented by concrete classes.
Implemented in carma::correlator::lib::CorrelatorHeader, carma::correlator::lib::CorrelatorSideband, carma::correlator::lib::CorrelatorData, carma::correlator::lib::CorrelatorBaseline, carma::correlator::lib::CorrelatorBand, and carma::correlator::lib::CorrelatorStats.
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.