Main MRPT website > C++ reference
MRPT logo

CSerializable.h File Reference

#include <mrpt/utils/CObject.h>
#include <mrpt/utils/CStream.h>
#include <mrpt/utils/safe_pointers.h>
Include dependency graph for CSerializable.h:

Go to the source code of this file.

Classes

class  mrpt::utils::CSerializable
 The virtual base class which provides a unified interface for all persistent objects in MRPT. More...
struct  mrpt::utils::TTypeName< T >
 A template to obtain the type of its argument as a string at compile time. More...
struct  mrpt::utils::TTypeName< std::pair< T1, T2 > >

Namespaces

namespace  mrpt
 

This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.


namespace  mrpt::utils
 

Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.


Defines

#define DEFINE_SERIALIZABLE(class_name)
 This declaration must be inserted in all CSerializable classes definition, within the class declaration.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_LINKAGE(class_name, _LINKAGE_)
 This declaration must be inserted in all CSerializable classes definition, before the class declaration.
#define DEFINE_SERIALIZABLE_PRE(class_name)   DEFINE_SERIALIZABLE_PRE_CUSTOM_LINKAGE(class_name, BASE_IMPEXP )
 This declaration must be inserted in all CSerializable classes definition, before the class declaration.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
 This declaration must be inserted in all CSerializable classes definition, before the class declaration.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
 This declaration must be inserted in all CSerializable classes definition, before the class declaration.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
 This must be inserted in all CSerializable classes implementation files:.
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)   DEFINE_VIRTUAL_MRPT_OBJECT(class_name)
 This declaration must be inserted in virtual CSerializable classes definition:.
#define IMPLEMENTS_VIRTUAL_SERIALIZABLE(class_name, base_class_name, NameSpace)
 This must be inserted as implementation of some required members for virtual CSerializable classes:.
Conversion of type to string at compile time

IMPORTANT: See also the implementation of Serialization for STL containers in mrpt/utils/stl_extensions.h



#define MRPT_DECLARE_TTYPENAME(_TYPE)
#define MRPT_DECLARE_TTYPENAME_PTR(_TYPE)
#define MRPT_DECLARE_TTYPENAME_CONTAINER(_CONTAINER)
#define MRPT_DECLARE_TTYPENAME_MAP_FOR_VECTOR(_CONT)   template<> struct TTypeName <_CONT> : TTypeName<std::vector<_CONT::value_type> > { };
#define MRPT_DECLARE_TTYPENAME_CONTAINER_ASSOC(_CONTAINER)

Functions

Non-streaming serialization functions



std::string BASE_IMPEXP mrpt::utils::ObjectToString (const CSerializable *o)
 Used to pass MRPT objects into a CORBA-like object (strings).
void BASE_IMPEXP mrpt::utils::StringToObject (const std::string &str, CSerializablePtr &obj)
 Used to pass CORBA-like objects (strings) into a MRPT object.
void BASE_IMPEXP mrpt::utils::ObjectToOctetVector (const CSerializable *o, vector_byte &out_vector)
 Converts (serializes) an MRPT object into an array of bytes.
void BASE_IMPEXP mrpt::utils::OctetVectorToObject (const vector_byte &in_data, CSerializablePtr &obj)
 Converts back (de-serializes) a sequence of binary data into a MRPT object, without prior information about the object's class.
void BASE_IMPEXP mrpt::utils::ObjectToRawString (const CSerializable *o, std::string &out_str)
 Converts (serializes) an MRPT object into an array of bytes within a std::string, without codifying to avoid NULL characters.
void BASE_IMPEXP mrpt::utils::RawStringToObject (const std::string &in_str, CSerializablePtr &obj)
 Converts back (de-serializes) a sequence of binary data within a std::string into a MRPT object, without prior information about the object's class.

Define Documentation

#define DEFINE_SERIALIZABLE ( class_name   ) 
Value:
DEFINE_MRPT_OBJECT(class_name) \
                protected: \
                        void  writeToStream(mrpt::utils::CStream &out, int *getVersion) const;\
                        void  readFromStream(mrpt::utils::CStream &in, int version);

This declaration must be inserted in all CSerializable classes definition, within the class declaration.

Definition at line 236 of file CSerializable.h.

#define DEFINE_SERIALIZABLE_PRE ( class_name   )     DEFINE_SERIALIZABLE_PRE_CUSTOM_LINKAGE(class_name, BASE_IMPEXP )

This declaration must be inserted in all CSerializable classes definition, before the class declaration.

Definition at line 251 of file CSerializable.h.

#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE ( class_name,
base_name   ) 
Value:

This declaration must be inserted in all CSerializable classes definition, before the class declaration.

Definition at line 263 of file CSerializable.h.

#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE ( class_name,
base_name,
_LINKAGE_   ) 
Value:
DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2(class_name, base_name, _LINKAGE_ class_name) \
                        _LINKAGE_ ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, class_name##Ptr &pObj);

This declaration must be inserted in all CSerializable classes definition, before the class declaration.

Definition at line 256 of file CSerializable.h.

#define DEFINE_SERIALIZABLE_PRE_CUSTOM_LINKAGE ( class_name,
_LINKAGE_   ) 
Value:
DEFINE_MRPT_OBJECT_PRE_CUSTOM_LINKAGE2(class_name,_LINKAGE_ class_name) \
                        _LINKAGE_ ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, class_name##Ptr &pObj);

This declaration must be inserted in all CSerializable classes definition, before the class declaration.

Definition at line 244 of file CSerializable.h.

#define DEFINE_VIRTUAL_SERIALIZABLE ( class_name   )     DEFINE_VIRTUAL_MRPT_OBJECT(class_name)

This declaration must be inserted in virtual CSerializable classes definition:.

Definition at line 276 of file CSerializable.h.

#define IMPLEMENTS_SERIALIZABLE ( class_name,
base,
NameSpace   ) 
Value:
IMPLEMENTS_MRPT_OBJECT(class_name, base,NameSpace) \
                        mrpt::utils::CStream& NameSpace::operator>>(mrpt::utils::CStream& in, NameSpace::class_name##Ptr &pObj) \
                        { pObj = NameSpace::class_name##Ptr( in.ReadObject() ); return in; }

This must be inserted in all CSerializable classes implementation files:.

Definition at line 269 of file CSerializable.h.

#define IMPLEMENTS_VIRTUAL_SERIALIZABLE ( class_name,
base_class_name,
NameSpace   ) 
Value:
IMPLEMENTS_VIRTUAL_MRPT_OBJECT(class_name, base_class_name,NameSpace) \
                        mrpt::utils::CStream& NameSpace::operator>>(mrpt::utils::CStream& in, class_name##Ptr &pObj) \
                        { pObj = class_name##Ptr( in.ReadObject() ); return in; }

This must be inserted as implementation of some required members for virtual CSerializable classes:.

Definition at line 282 of file CSerializable.h.

#define MRPT_DECLARE_TTYPENAME ( _TYPE   ) 
Value:
template<> struct TTypeName <_TYPE > { \
                                static std::string get() { return std::string(#_TYPE); } };

Definition at line 157 of file CSerializable.h.

#define MRPT_DECLARE_TTYPENAME_CONTAINER ( _CONTAINER   ) 
Value:
template< typename V > \
                        struct TTypeName <_CONTAINER<V> > { \
                                static std::string get() { \
                                        return std::string( #_CONTAINER )+std::string("<")+std::string( TTypeName<V>::get() ) + std::string(">"); \
                                } \
                        };

Definition at line 180 of file CSerializable.h.

#define MRPT_DECLARE_TTYPENAME_CONTAINER_ASSOC ( _CONTAINER   ) 
Value:
template< typename K, typename V > \
                        struct TTypeName <_CONTAINER<K,V> > { \
                                static std::string get() { \
                                        return std::string( #_CONTAINER )+std::string("<")+std::string( TTypeName<K>::get() )+ std::string(",")+std::string( TTypeName<V>::get() )+std::string(">"); \
                                } \
                        };

Definition at line 212 of file CSerializable.h.

#define MRPT_DECLARE_TTYPENAME_MAP_FOR_VECTOR ( _CONT   )     template<> struct TTypeName <_CONT> : TTypeName<std::vector<_CONT::value_type> > { };

Definition at line 194 of file CSerializable.h.

#define MRPT_DECLARE_TTYPENAME_PTR ( _TYPE   ) 
Value:
template<> struct TTypeName <_TYPE##Ptr> { \
                        static std::string get() { return TTypeName<_TYPE>::get(); }    };

Definition at line 161 of file CSerializable.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010