ESA JPIP server  0.1
data::BaseStream< StreamClass, StreamOperator > Class Template Reference

This template is used as the base for the input/output stream classes. More...

#include <serialize.h>

Collaboration diagram for data::BaseStream< StreamClass, StreamOperator >:

Public Member Functions

 BaseStream ()
 Initializes the status to false. More...
 
StreamClass & Open (const char *file_name)
 Opens a file for serialization. More...
 
StreamClass & Open (const char *file_name, const char *access)
 Opens a file for serialization. More...
 
StreamClass & Close ()
 Closes the file of the serialization and finish the serialization. More...
 
StreamClass & SerializeBytes (void *ptr, int num_bytes)
 Serializes a number of bytes. More...
 
template<typename T >
StreamClass & operator& (T &var)
 This operator overloading is the key of the serialization mechanism. More...
 
bool result () const
 Returns the internal serialization status. More...
 
 operator bool () const
 Return the internal serialization status. More...
 
virtual ~BaseStream ()
 The destructor automatically closes the file-. More...
 

Protected Attributes

File file_
 File used for the serialization. More...
 
bool result_
 Internal current status of the serialization. More...
 

Detailed Description

template<typename StreamClass, typename StreamOperator>
class data::BaseStream< StreamClass, StreamOperator >

This template is used as the base for the input/output stream classes.

Contains the basic functionality for the serialization with files, composed by a file object and an internal status. This status is updated with each operation and, in a sequence of serialization, this is stopped just after this status is set to false.

In order to have a type serializable, it must comply with one of these requirements: i) to have implemented a "serializer" with the class Serializer, or ii) to have defined a member method called SerializeWith.

The first option is useful for the basic types (int, float, etc.) and for those classes already defined and that can not be modified. The second option is more elegant for those classes that can be modified specifically for serialization.

The SerializeWith method must be defined as follows:

template<typename T> T& SerializeWith(T& stream) { return (stream & member1 & member2 & ...); }

See also
Serializer
InputStream
OutputStream

Constructor & Destructor Documentation

template<typename StreamClass, typename StreamOperator>
data::BaseStream< StreamClass, StreamOperator >::BaseStream ( )
inline

Initializes the status to false.

template<typename StreamClass, typename StreamOperator>
virtual data::BaseStream< StreamClass, StreamOperator >::~BaseStream ( )
inlinevirtual

The destructor automatically closes the file-.

Member Function Documentation

template<typename StreamClass, typename StreamOperator>
StreamClass& data::BaseStream< StreamClass, StreamOperator >::Close ( )
inline

Closes the file of the serialization and finish the serialization.

template<typename StreamClass, typename StreamOperator>
StreamClass& data::BaseStream< StreamClass, StreamOperator >::Open ( const char *  file_name)
inline

Opens a file for serialization.

Parameters
file_namePath name of the file to open.
Returns
*this.

Here is the caller graph for this function:

template<typename StreamClass, typename StreamOperator>
StreamClass& data::BaseStream< StreamClass, StreamOperator >::Open ( const char *  file_name,
const char *  access 
)
inline

Opens a file for serialization.

Parameters
file_namePath name of the file to open.
accessAccess mode to use to open the file.
Returns
*this.
template<typename StreamClass, typename StreamOperator>
data::BaseStream< StreamClass, StreamOperator >::operator bool ( ) const
inline

Return the internal serialization status.

template<typename StreamClass, typename StreamOperator>
template<typename T >
StreamClass& data::BaseStream< StreamClass, StreamOperator >::operator& ( T &  var)
inline

This operator overloading is the key of the serialization mechanism.

template<typename StreamClass, typename StreamOperator>
bool data::BaseStream< StreamClass, StreamOperator >::result ( ) const
inline

Returns the internal serialization status.

template<typename StreamClass, typename StreamOperator>
StreamClass& data::BaseStream< StreamClass, StreamOperator >::SerializeBytes ( void *  ptr,
int  num_bytes 
)
inline

Serializes a number of bytes.

Depending on the stream operator in the template, this serialization is either a read or a write operation.

Parameters
ptrPointer to the buffer.
num_bytesNumber of bytes.
Returns
*this.

Here is the caller graph for this function:

Member Data Documentation

template<typename StreamClass, typename StreamOperator>
File data::BaseStream< StreamClass, StreamOperator >::file_
protected

File used for the serialization.

template<typename StreamClass, typename StreamOperator>
bool data::BaseStream< StreamClass, StreamOperator >::result_
protected

Internal current status of the serialization.


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