ERC CISST - cisst software

cmnSerializer Class Reference
[Common Tools]

#include <cmnSerializer.h>

Inheritance diagram for cmnSerializer:

Inheritance graph
[legend]
Collaboration diagram for cmnSerializer:

Collaboration graph
[legend]
List of all members.

Detailed Description

Serialization utility class.

This class allows to serialize objects of different types (all derived from cmnGenericObject) as well as the information required to deserialize them (see cmnDeSerializer) to and from an STL output stream.

The result is a sequence of class informations (i.e. class name as a string and unique identifier) and objects. Each object is sent preceeded by its unique class identifier and class information is preceeded by a 0. This allows cmnDeSerializer to determine what is currently deserialized.

The unique identifer used is the address of the object cmnClassServices associated to each class.

When an object needs to be serialized, the method Serialize will first verify that the class information (name and identifier) has already been serialized. If this is not the case, it will serialize the class information and then the object itself.

See also:
cmnDeSerializer cmnGenericObject

Definition at line 122 of file cmnSerializer.h.

Public Types

Public Member Functions


Member Typedef Documentation

typedef unsigned long long int cmnSerializer::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.

Definition at line 130 of file cmnSerializer.h.


Constructor & Destructor Documentation

cmnSerializer::cmnSerializer ( std::ostream &  outputStream  ) 

Constructor.

Parameters:
outputStream any stream derived from std::ostream. The output stream must be created with the open flag std::ostream::binary.


Member Function Documentation

void cmnSerializer::Serialize ( const cmnGenericObject object,
const bool  serializeObject = true 
)

Serialize an object. This method will first verify that the information (cmnClassServices) related to the class of the object has been serialized using SerializeServices. Once this is done, it will serialize the class identifier (pointer on the class information, see cmnClassServices and cmnClassRegister) and finally call the object's method SerializeRaw.

Parameters:
object An object of a class derived from cmnGenericObject. The class of the object must have the virtual method SerializeRaw re-defined to properly serialize the content of the object.
serializeObject If 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 cmnSerializeRaw, it might throw an exception.

Referenced by mtsProxySerializer::Serialize().

void cmnSerializer::SerializeServices ( const cmnClassServicesBase servicesPointer  ) 

Serialize the class information if needed. This method will write the class name (as an STL string) and the type identifier used on the serialization end to the output stream. The type identifier used is the address of the class services object (cmnClassServices). To avoid sending the same information multiple times, this class (cmnSerializer) maintains a list of the class identifier already sent.

It is important to note that a regular user doesn't need to use this method as the Serialize method performs this task. It is provided for advanced users who need or want to serialize all the class information first and then serialize their objects. This can be used to avoid time delays while serializing and de-serializing objects.

Parameters:
servicesPointer Pointer on object cmnClassServices. Use cmnClassRegister::FindClassServices, className::Services() or object.Services() to retrieve the correct pointer.
Note:
As this method relies on cmnSerializeRaw, it might throw an exception.


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu