cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
cmnDeSerializer Class Reference

De-serialization utility class.This class allows to deserialize objects previously serialized using cmnSerializer. More...

#include <cmnDeSerializer.h>

Inheritance diagram for cmnDeSerializer:
cmnGenericObject

Public Types

typedef long long int TypeId
 

Public Member Functions

 cmnDeSerializer (std::istream &inputStream)
 
 ~cmnDeSerializer ()
 
void Reset (void)
 
cmnGenericObjectDeSerialize (const bool serializeObject=true)
 
template<class _elementType >
void DeSerialize (_elementType &object, const bool serializeObject=true)
 
- Public Member Functions inherited from cmnGenericObject
virtual ~cmnGenericObject (void)
 
virtual const
cmnClassServicesBase
Services (void) const =0
 
bool ReconstructFrom (const cmnGenericObject &other)
 
std::string ToString (void) const
 
virtual void ToStream (std::ostream &outputStream) const
 
virtual void ToStreamRaw (std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
 
virtual bool FromStreamRaw (std::istream &inputStream, const char delimiter= ' ')
 
virtual void SerializeRaw (std::ostream &outputStream) const
 
virtual void DeSerializeRaw (std::istream &inputStream)
 
virtual cmnLogger::StreamBufTypeGetLogMultiplexer (void) const
 
virtual size_t ScalarNumber (void) const
 
virtual bool ScalarNumberIsFixed (void) const
 
virtual double Scalar (const size_t CMN_UNUSED(index)) const throw (std::out_of_range)
 
virtual std::string ScalarDescription (const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const
 

Detailed Description

De-serialization utility class.

This class allows to deserialize objects previously serialized using cmnSerializer.

As each object serialized is identified by a unique class identifer defined at runtime (address of the object cmnClassServices), this class maintains a table of equivalence between the remote class identifiers and local class identifiers. This class can be used to read both the class information and objects in any order as long as the class information for a specific object has been received before the object itself.

See Also
cmnSerializer cmnGenericObject

Member Typedef Documentation

typedef long long int cmnDeSerializer::TypeId

Type used to identify objects over the network. It uses the services pointer but as the sender or receiver could be a 32 or 64 bits OS, we use a data type that can handle both.

Constructor & Destructor Documentation

cmnDeSerializer::cmnDeSerializer ( std::istream &  inputStream)

Constructor.

Parameters
inputStreamany stream derived from std::istream. The output stream must be created with the open flag std::istream::binary.
cmnDeSerializer::~cmnDeSerializer ( )

Destructor

Member Function Documentation

cmnGenericObject* cmnDeSerializer::DeSerialize ( const bool  serializeObject = true)

De-serialize an object from the input stream. This method will create an object dynamically therefore the class of the object serialized must have been registered using the flag CMN_DYNAMIC_CREATION (see cmnClassServices and cmnClassRegister). This also requires to provide a default constructor for the given class.

This method will deserialize one object only. If the stream contains some class identifiers (pair of class name, remote class identifer) it will read them all until an object is found.

Parameters
serializeObjectIf true, object content is serialized. If false, only class services is serialized and object content is not serialized. True by default.
Note
As this method relies on cmnDeSerializeRaw, it might throw an exception.
template<class _elementType >
void cmnDeSerializer::DeSerialize ( _elementType &  object,
const bool  serializeObject = true 
)
inline

De-serialize an object from the input stream. This method will replace the object content by the data read from the input stream. There is no dynamic creation involved.

This method will deserialize one object only. If the stream contains some class identifiers (pair of class name, remote class identifer) it will read them all until an object is found.

Note
As this method relies on cmnDeSerializeRaw, it might throw an exception.
void cmnDeSerializer::Reset ( void  )

Reset the list of types already received.


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