CFEL - ASG Software Suite  2.5.0
CASS
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cass::SerializerBackend Class Reference

A serializer. More...

#include <serializer.hpp>

+ Inheritance diagram for cass::SerializerBackend:

Public Member Functions

 SerializerBackend ()
 constructor More...
 
void flush ()
 flush the stream More...
 
std::ostream & writeToStream (const char *data, std::streamsize n)
 write data to the stream More...
 
std::istream & readFromStream (char *data, std::streamsize n)
 read data from the stream More...
 
template<typename Type >
void add (const Type &value)
 add arbitrary value to the stream More...
 
template<typename Type >
Type retrieve ()
 read arbitrary value from stream More...
 
void startChecksumGroupForRead ()
 control checksum calculation for the next values added More...
 
bool endChecksumGroupForRead ()
 
void startChecksumGroupForWrite ()
 control checksum for writing to stream More...
 
void endChecksumGroupForWrite ()
 

Protected Member Functions

void addToOutChecksum (const char *data, std::streamsize len)
 fletcher16 algorithm for 8 bit input More...
 
void addToInChecksum (const char *data, std::streamsize len)
 fletcher16 algorithm for 8 bit input More...
 

Protected Attributes

std::iostream * _stream
 the string to serialize the objects to (buffer) More...
 
uint16_t r_sum1
 sum 1 for reading More...
 
uint16_t r_sum2
 sum 2 for reading More...
 
uint16_t w_sum1
 sum 1 for writing More...
 
uint16_t w_sum2
 sum 2 for writing More...
 
bool _checkSumGroupStartedForRead
 flag to enable getting parts to a checksum More...
 
bool _checkSumGroupStartedForWrite
 flag to enable adding parts to a checksum More...
 

Detailed Description

A serializer.

base class that will serialize / de serialize Serializable classes to an iostream This is an interface that should not be instantiated (can be made pure virtual once virtual methods are introduced).

Author
Lutz Foucar
Stephan Kassemeyer

Definition at line 45 of file serializer.hpp.

Constructor & Destructor Documentation

cass::SerializerBackend::SerializerBackend ( )
inline

constructor

Definition at line 49 of file serializer.hpp.

Member Function Documentation

template<typename Type >
void cass::SerializerBackend::add ( const Type &  value)
inline
void cass::SerializerBackend::addToInChecksum ( const char *  data,
std::streamsize  len 
)
inlineprotected

fletcher16 algorithm for 8 bit input

Parameters
datathe data to add to the fletcher algorithm
lenthe size of the data to be added to the fletcher algorithm
Author
Stephan Kassemeyer

Definition at line 205 of file serializer.hpp.

References r_sum1, and r_sum2.

Referenced by readFromStream().

void cass::SerializerBackend::addToOutChecksum ( const char *  data,
std::streamsize  len 
)
inlineprotected

fletcher16 algorithm for 8 bit input

Parameters
datathe data to add to the fletcher algorithm
lenthe size of the data to be added to the fletcher algorithm
Author
Stephan Kassemeyer

Definition at line 184 of file serializer.hpp.

References w_sum1, and w_sum2.

Referenced by writeToStream().

bool cass::SerializerBackend::endChecksumGroupForRead ( )
inline

finalize checksum:

Definition at line 112 of file serializer.hpp.

References _checkSumGroupStartedForRead, r_sum1, and r_sum2.

Referenced by cass::IdList::deserialize(), and jocassview::IdList::deserialize().

void cass::SerializerBackend::endChecksumGroupForWrite ( )
inline

finalize checksum:

Definition at line 141 of file serializer.hpp.

References _checkSumGroupStartedForWrite, add(), w_sum1, and w_sum2.

Referenced by jocassview::IdList::serialize(), and cass::IdList::serialize().

void cass::SerializerBackend::flush ( )
inline

flush the stream

Definition at line 63 of file serializer.hpp.

References _stream.

std::istream& cass::SerializerBackend::readFromStream ( char *  data,
std::streamsize  n 
)
inline

read data from the stream

Returns
reference to the in stream
Parameters
datathe data to write
nsize of the data

Definition at line 83 of file serializer.hpp.

References _checkSumGroupStartedForRead, _stream, and addToInChecksum().

Referenced by retrieve().

template<typename Type >
Type cass::SerializerBackend::retrieve ( )
inline
void cass::SerializerBackend::startChecksumGroupForRead ( )
inline

control checksum calculation for the next values added

usage: add...; add...; startChecksumGroupforRead(); add...; add...; if (!endChecksumGroupForRead()) error();

Definition at line 106 of file serializer.hpp.

References _checkSumGroupStartedForRead, r_sum1, and r_sum2.

Referenced by cass::IdList::deserialize(), and jocassview::IdList::deserialize().

void cass::SerializerBackend::startChecksumGroupForWrite ( )
inline

control checksum for writing to stream

usage: retrieve...; retrieve...; startChecksumGroupforWrite(); retrieve...; retrieve...; endChecksumGroupForWrite();

Definition at line 135 of file serializer.hpp.

References _checkSumGroupStartedForWrite, w_sum1, and w_sum2.

Referenced by jocassview::IdList::serialize(), and cass::IdList::serialize().

std::ostream& cass::SerializerBackend::writeToStream ( const char *  data,
std::streamsize  n 
)
inline

write data to the stream

Returns
reference to the out stream
Parameters
datathe data to write
nsize of the data

Definition at line 71 of file serializer.hpp.

References _checkSumGroupStartedForWrite, _stream, and addToOutChecksum().

Referenced by add().

Member Data Documentation

bool cass::SerializerBackend::_checkSumGroupStartedForRead
protected

flag to enable getting parts to a checksum

Definition at line 236 of file serializer.hpp.

Referenced by endChecksumGroupForRead(), readFromStream(), and startChecksumGroupForRead().

bool cass::SerializerBackend::_checkSumGroupStartedForWrite
protected

flag to enable adding parts to a checksum

Definition at line 239 of file serializer.hpp.

Referenced by endChecksumGroupForWrite(), startChecksumGroupForWrite(), and writeToStream().

std::iostream* cass::SerializerBackend::_stream
protected
uint16_t cass::SerializerBackend::r_sum1
protected

sum 1 for reading

Definition at line 224 of file serializer.hpp.

Referenced by addToInChecksum(), endChecksumGroupForRead(), and startChecksumGroupForRead().

uint16_t cass::SerializerBackend::r_sum2
protected

sum 2 for reading

Definition at line 227 of file serializer.hpp.

Referenced by addToInChecksum(), endChecksumGroupForRead(), and startChecksumGroupForRead().

uint16_t cass::SerializerBackend::w_sum1
protected

sum 1 for writing

Definition at line 230 of file serializer.hpp.

Referenced by addToOutChecksum(), endChecksumGroupForWrite(), and startChecksumGroupForWrite().

uint16_t cass::SerializerBackend::w_sum2
protected

sum 2 for writing

Definition at line 233 of file serializer.hpp.

Referenced by addToOutChecksum(), endChecksumGroupForWrite(), and startChecksumGroupForWrite().


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