MRPT  1.9.9
CSerializable.h File Reference
#include <mrpt/rtti/CObject.h>
#include <mrpt/serialization/serialization_frwds.h>
#include <cstdint>
Include dependency graph for CSerializable.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mrpt::serialization::CSerializable
 The virtual base class which provides a unified interface for all persistent objects in MRPT. More...
 

Namespaces

 mrpt::serialization
 

Macros

#define DEFINE_SCHEMA_SERIALIZABLE()
 This declaration must be inserted in all CSerializable classes definition, within the class declaration. More...
 
#define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version)
 For use inside all serializeTo(CSchemeArchiveBase) methods. More...
 
#define SCHEMA_DESERIALIZE_DATATYPE_VERSION()
 For use inside serializeFrom(CSchemeArchiveBase) methods. More...
 
#define DEFINE_SERIALIZABLE(class_name)
 This declaration must be inserted in all CSerializable classes definition, within the class declaration. More...
 
#define IMPLEMENTS_SERIALIZABLE_NS_PREFIX(class_name, base, NameSpace)   IMPLEMENTS_MRPT_OBJECT_NS_PREFIX(class_name, base, NameSpace)
 To be added to all CSerializable-classes implementation files. More...
 
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)   IMPLEMENTS_MRPT_OBJECT(class_name, base, NameSpace)
 To be added to all CSerializable-classes implementation files. More...
 
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)   DEFINE_VIRTUAL_MRPT_OBJECT(class_name)
 This declaration must be inserted in virtual CSerializable classes definition: More...
 
#define IMPLEMENTS_VIRTUAL_SERIALIZABLE(class_name, base_class, NS)   IMPLEMENTS_VIRTUAL_MRPT_OBJECT(class_name, base_class, NS)
 This must be inserted as implementation of some required members for virtual CSerializable classes: More...
 
#define IMPLEMENTS_VIRTUAL_SERIALIZABLE_NS_PREFIX(class_name, base_class, NS)   IMPLEMENTS_VIRTUAL_MRPT_OBJECT_NS_PREFIX(class_name, base_class, NS)
 
#define DECLARE_MEX_CONVERSION
 This must be inserted if a custom conversion method for MEX API is implemented in the class. More...
 
#define DECLARE_MEXPLUS_FROM(complete_type)
 This must be inserted if a custom conversion method for MEX API is implemented in the class. More...
 
#define IMPLEMENTS_MEXPLUS_FROM(complete_type)
 

Typedefs

using mxArray = struct mxArray_tag
 Forward declaration for mxArray (avoid #including as much as possible to speed up compiling) More...
 

Functions

void mrpt::serialization::ObjectToOctetVector (const CSerializable *o, std::vector< uint8_t > &out_vector)
 Converts (serializes) an MRPT object into an array of bytes. More...
 
void mrpt::serialization::OctetVectorToObject (const std::vector< uint8_t > &in_data, CSerializable::Ptr &obj)
 Converts back (de-serializes) a sequence of binary data into a MRPT object, without prior information about the object's class. More...
 

Macro Definition Documentation

◆ DECLARE_MEX_CONVERSION

#define DECLARE_MEX_CONVERSION
Value:
/*! @name Virtual methods for MRPT-MEX conversion */ \
/*! @{ */ \
public: \
mxArray* writeToMatlab() const override; \
/*! @} */

This must be inserted if a custom conversion method for MEX API is implemented in the class.

Definition at line 193 of file CSerializable.h.

◆ DECLARE_MEXPLUS_FROM

#define DECLARE_MEXPLUS_FROM (   complete_type)
Value:
namespace mexplus \
{ \
template <typename T> \
mxArray* from(const T& value); \
template <> \
mxArray* from(const complete_type& value); \
}
GLsizei const GLfloat * value
Definition: glext.h:4134

This must be inserted if a custom conversion method for MEX API is implemented in the class.

Definition at line 202 of file CSerializable.h.

◆ DEFINE_SCHEMA_SERIALIZABLE

#define DEFINE_SCHEMA_SERIALIZABLE ( )
Value:
protected: \
/*! @name CSerializable virtual methods for schema based archives*/ \
/*! @{ */ \
void serializeTo(mrpt::serialization::CSchemeArchiveBase& out) \
const override; \
void serializeFrom(mrpt::serialization::CSchemeArchiveBase& in) override; \
/*! @} */
Virtual base class for "schematic archives" (JSON, XML,...)
GLuint in
Definition: glext.h:7391

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

Definition at line 121 of file CSerializable.h.

◆ DEFINE_SERIALIZABLE

#define DEFINE_SERIALIZABLE (   class_name)
Value:
DEFINE_MRPT_OBJECT(class_name) \
protected: \
/*! @name CSerializable virtual methods */ \
/*! @{ */ \
uint8_t serializeGetVersion() const override; \
void serializeTo(mrpt::serialization::CArchive& out) const override; \
void serializeFrom( \
mrpt::serialization::CArchive& in, uint8_t serial_version) override; \
/*! @} */
unsigned char uint8_t
Definition: rptypes.h:44
#define DEFINE_MRPT_OBJECT(class_name)
This declaration must be inserted in all CObject classes definition, within the class declaration...
Definition: CObject.h:207
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
GLuint in
Definition: glext.h:7391

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

Definition at line 152 of file CSerializable.h.

◆ DEFINE_VIRTUAL_SERIALIZABLE

#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 179 of file CSerializable.h.

◆ IMPLEMENTS_MEXPLUS_FROM

#define IMPLEMENTS_MEXPLUS_FROM (   complete_type)
Value:
namespace mexplus \
{ \
template <> \
mxArray* from(const complete_type& var) \
{ \
return var.writeToMatlab(); \
} \
}

Definition at line 211 of file CSerializable.h.

◆ IMPLEMENTS_SERIALIZABLE

#define IMPLEMENTS_SERIALIZABLE (   class_name,
  base,
  NameSpace 
)    IMPLEMENTS_MRPT_OBJECT(class_name, base, NameSpace)

To be added to all CSerializable-classes implementation files.

This version registers the class name with the NameSpace prefix.

See also
IMPLEMENTS_SERIALIZABLE_NS_PREFIX

Definition at line 174 of file CSerializable.h.

◆ IMPLEMENTS_SERIALIZABLE_NS_PREFIX

#define IMPLEMENTS_SERIALIZABLE_NS_PREFIX (   class_name,
  base,
  NameSpace 
)    IMPLEMENTS_MRPT_OBJECT_NS_PREFIX(class_name, base, NameSpace)

To be added to all CSerializable-classes implementation files.

This version registers the class name with the NameSpace prefix.

See also
IMPLEMENTS_SERIALIZABLE

Definition at line 167 of file CSerializable.h.

◆ IMPLEMENTS_VIRTUAL_SERIALIZABLE

#define IMPLEMENTS_VIRTUAL_SERIALIZABLE (   class_name,
  base_class,
  NS 
)    IMPLEMENTS_VIRTUAL_MRPT_OBJECT(class_name, base_class, NS)

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

Definition at line 185 of file CSerializable.h.

◆ IMPLEMENTS_VIRTUAL_SERIALIZABLE_NS_PREFIX

#define IMPLEMENTS_VIRTUAL_SERIALIZABLE_NS_PREFIX (   class_name,
  base_class,
  NS 
)    IMPLEMENTS_VIRTUAL_MRPT_OBJECT_NS_PREFIX(class_name, base_class, NS)

Definition at line 188 of file CSerializable.h.

◆ SCHEMA_DESERIALIZE_DATATYPE_VERSION

#define SCHEMA_DESERIALIZE_DATATYPE_VERSION ( )
Value:
version = static_cast<int>(in["version"]); \
const std::string read_typename{static_cast<std::string>(in["datatype"])}; \
const std::string expected_typename{this->GetRuntimeClass()->className}; \
if (expected_typename != read_typename) \
{ \
THROW_EXCEPTION(mrpt::format( \
"Schema deserializing class `%s` but expected `%s`", \
read_typename.c_str(), expected_typename.c_str())); \
}
GLsizei const GLchar ** string
Definition: glext.h:4116
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
GLuint in
Definition: glext.h:7391

For use inside serializeFrom(CSchemeArchiveBase) methods.

Definition at line 139 of file CSerializable.h.

Referenced by mrpt::opengl::CCylinder::serializeFrom(), and mrpt::opengl::CPointCloud::serializeFrom().

◆ SCHEMA_SERIALIZE_DATATYPE_VERSION

#define SCHEMA_SERIALIZE_DATATYPE_VERSION (   ser_version)
Value:
do \
{ \
out["datatype"] = std::string(this->GetRuntimeClass()->className); \
out["version"] = ser_version; \
} while (false)
GLsizei const GLchar ** string
Definition: glext.h:4116

For use inside all serializeTo(CSchemeArchiveBase) methods.

Definition at line 131 of file CSerializable.h.

Referenced by mrpt::opengl::CCylinder::serializeTo(), and mrpt::opengl::CPointCloud::serializeTo().

Typedef Documentation

◆ mxArray

using mxArray = struct mxArray_tag

Forward declaration for mxArray (avoid #including as much as possible to speed up compiling)

Definition at line 18 of file CSerializable.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019