9 #ifndef CSERIALIZABLE_H 10 #define CSERIALIZABLE_H 138 #define DEFINE_SERIALIZABLE_CUSTOM_LINKAGE(class_name, _VOID_LINKAGE_, _STATIC_LINKAGE_, _VIRTUAL_LINKAGE_ ) \ 139 DEFINE_MRPT_OBJECT_CUSTOM_LINKAGE(class_name, _STATIC_LINKAGE_, _VIRTUAL_LINKAGE_ ) \ 143 _VOID_LINKAGE_ writeToStream(mrpt::utils::CStream &out, int *getVersion) const MRPT_OVERRIDE;\ 144 _VOID_LINKAGE_ readFromStream(mrpt::utils::CStream &in, int version) MRPT_OVERRIDE; \ 148 #define DEFINE_SERIALIZABLE(class_name) \ 149 DEFINE_SERIALIZABLE_CUSTOM_LINKAGE(class_name, void , static ,virtual ) 153 #define DEFINE_SERIALIZABLE_PRE_CUSTOM_LINKAGE(class_name,_LINKAGE_) \ 154 DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2(class_name, mrpt::utils::CSerializable, _LINKAGE_ class_name) \ 155 _LINKAGE_ ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, class_name##Ptr &pObj); 157 #define DEFINE_SERIALIZABLE_POST_CUSTOM_LINKAGE(class_name,_LINKAGE_) \ 158 DEFINE_MRPT_OBJECT_POST_CUSTOM_BASE_LINKAGE2(class_name, mrpt::utils::CSerializable, _LINKAGE_ class_name) 162 #define DEFINE_SERIALIZABLE_PRE(class_name) \ 163 DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2(class_name, mrpt::utils::CSerializable, BASE_IMPEXP class_name) \ 164 BASE_IMPEXP ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, class_name##Ptr &pObj); 166 #define DEFINE_SERIALIZABLE_POST(class_name) \ 167 DEFINE_MRPT_OBJECT_POST_CUSTOM_BASE_LINKAGE2(class_name, mrpt::utils::CSerializable, BASE_IMPEXP class_name) 171 #define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_ ) \ 172 DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE2(class_name, base_name, _LINKAGE_ class_name) \ 173 _LINKAGE_ ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, class_name##Ptr &pObj); 175 #define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_ ) \ 176 DEFINE_MRPT_OBJECT_POST_CUSTOM_BASE_LINKAGE2(class_name, base_name, _LINKAGE_ class_name) 179 #define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name) \ 180 DEFINE_MRPT_OBJECT_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, BASE_IMPEXP ) \ 181 BASE_IMPEXP ::mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, class_name##Ptr &pObj); 183 #define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name) \ 184 DEFINE_MRPT_OBJECT_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, BASE_IMPEXP ) \ 187 #define IMPLEMENTS_SERIALIZABLE(class_name, base,NameSpace) \ 188 IMPLEMENTS_MRPT_OBJECT(class_name, base,NameSpace) \ 189 mrpt::utils::CStream& NameSpace::operator>>(mrpt::utils::CStream& in, NameSpace::class_name##Ptr &pObj) \ 190 { pObj = NameSpace::class_name##Ptr(in.ReadObject()); return in; } 193 #define DEFINE_VIRTUAL_SERIALIZABLE(class_name) \ 194 DEFINE_VIRTUAL_MRPT_OBJECT(class_name) 199 #define IMPLEMENTS_VIRTUAL_SERIALIZABLE(class_name, base_class_name,NameSpace) \ 200 IMPLEMENTS_VIRTUAL_MRPT_OBJECT(class_name, base_class_name,NameSpace) \ 201 mrpt::utils::CStream& NameSpace::operator>>(mrpt::utils::CStream& in, class_name##Ptr &pObj) \ 202 { pObj = class_name##Ptr( in.ReadObject() ); return in; } 206 #define DECLARE_MEX_CONVERSION \ 210 virtual mxArray* writeToMatlab() const; \ 213 #define DECLARE_MEX_CONVERSION //Empty 218 #define DECLARE_MEXPLUS_FROM( complete_type ) \ 221 template <typename T> \ 222 mxArray* from(const T& value); \ 224 mxArray* from(const complete_type& value); \ 227 #define IMPLEMENTS_MEXPLUS_FROM( complete_type ) \ 231 mxArray* from(const complete_type& var) \ 233 return var.writeToMatlab(); \ 237 #define DECLARE_MEXPLUS_FROM(complete_type) //Empty 238 #define IMPLEMENTS_MEXPLUS_FROM(complete_type) //Empty void BASE_IMPEXP OctetVectorToObject(const vector_byte &in_data, CSerializablePtr &obj)
Converts back (de-serializes) a sequence of binary data into a MRPT object, without prior information...
std::vector< uint8_t > vector_byte
The virtual base class which provides a unified interface for all persistent objects in MRPT...
#define DEFINE_VIRTUAL_MRPT_OBJECT(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
#define DEFINE_MRPT_OBJECT_POST(class_name)
GLsizei GLsizei GLuint * obj
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
void BASE_IMPEXP ObjectToOctetVector(const CSerializable *o, vector_byte &out_vector)
Converts (serializes) an MRPT object into an array of bytes.
void BASE_IMPEXP 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...
GLsizei const GLchar ** string
#define DEFINE_MRPT_OBJECT_PRE(class_name)
This declaration must be inserted in all CObject classes definition, before the class declaration...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
virtual mxArray * writeToMatlab() const
Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class.
void BASE_IMPEXP ObjectToRawString(const CSerializable *o, std::string &out_str)
Converts (serializes) an MRPT object into an array of bytes within a std::string, without codifying t...
std::string BASE_IMPEXP ObjectToString(const CSerializable *o)
Used to pass MRPT objects into a CORBA-like object (strings).
The virtual base class of all MRPT classes with a unified RTTI system.
void BASE_IMPEXP StringToObject(const std::string &str, CSerializablePtr &obj)
Used to pass CORBA-like objects (strings) into a MRPT object.
struct mxArray_tag mxArray
Forward declaration for mxArray (avoid #including as much as possible to speed up compiling) ...