68 std::string(
" : class does not support schema based serialization");
78 std::string(
" : class does not support schema based serialization");
105 const CSerializable* o, std::vector<uint8_t>& out_vector);
121 #define DEFINE_SCHEMA_SERIALIZABLE() \ 125 void serializeTo(mrpt::serialization::CSchemeArchiveBase& out) \ 127 void serializeFrom(mrpt::serialization::CSchemeArchiveBase& in) override; \ 131 #define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version) \ 134 out["datatype"] = std::string(this->GetRuntimeClass()->className); \ 135 out["version"] = ser_version; \ 139 #define SCHEMA_DESERIALIZE_DATATYPE_VERSION() \ 140 version = static_cast<int>(in["version"]); \ 141 const std::string read_typename{static_cast<std::string>(in["datatype"])}; \ 142 const std::string expected_typename{this->GetRuntimeClass()->className}; \ 143 if (expected_typename != read_typename) \ 145 THROW_EXCEPTION(mrpt::format( \ 146 "Schema deserializing class `%s` but expected `%s`", \ 147 read_typename.c_str(), expected_typename.c_str())); \ 152 #define DEFINE_SERIALIZABLE(class_name) \ 153 DEFINE_MRPT_OBJECT(class_name) \ 157 uint8_t serializeGetVersion() const override; \ 158 void serializeTo(mrpt::serialization::CArchive& out) const override; \ 159 void serializeFrom( \ 160 mrpt::serialization::CArchive& in, uint8_t serial_version) override; \ 167 #define IMPLEMENTS_SERIALIZABLE_NS_PREFIX(class_name, base, NameSpace) \ 168 IMPLEMENTS_MRPT_OBJECT_NS_PREFIX(class_name, base, NameSpace) 174 #define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace) \ 175 IMPLEMENTS_MRPT_OBJECT(class_name, base, NameSpace) 179 #define DEFINE_VIRTUAL_SERIALIZABLE(class_name) \ 180 DEFINE_VIRTUAL_MRPT_OBJECT(class_name) 185 #define IMPLEMENTS_VIRTUAL_SERIALIZABLE(class_name, base_class, NS) \ 186 IMPLEMENTS_VIRTUAL_MRPT_OBJECT(class_name, base_class, NS) 188 #define IMPLEMENTS_VIRTUAL_SERIALIZABLE_NS_PREFIX(class_name, base_class, NS) \ 189 IMPLEMENTS_VIRTUAL_MRPT_OBJECT_NS_PREFIX(class_name, base_class, NS) 193 #define DECLARE_MEX_CONVERSION \ 197 mxArray* writeToMatlab() const override; \ 202 #define DECLARE_MEXPLUS_FROM(complete_type) \ 205 template <typename T> \ 206 mxArray* from(const T& value); \ 208 mxArray* from(const complete_type& value); \ 211 #define IMPLEMENTS_MEXPLUS_FROM(complete_type) \ 215 mxArray* from(const complete_type& var) \ 217 return var.writeToMatlab(); \ virtual void serializeTo(CArchive &out) const =0
Pure virtual method for writing (serializing) to an abstract archive.
#define THROW_EXCEPTION(msg)
virtual void serializeFrom(CArchive &in, uint8_t serial_version)=0
Pure virtual method for reading (deserializing) from an abstract archive.
std::shared_ptr< CSerializable > Ptr
virtual void serializeTo(CSchemeArchiveBase &out) const
Virtual method for writing (serializing) to an abstract schema based archive.
void ObjectToOctetVector(const CSerializable *o, std::vector< uint8_t > &out_vector)
Converts (serializes) an MRPT object into an array of bytes.
#define DEFINE_VIRTUAL_MRPT_OBJECT(class_name)
This declaration must be inserted in virtual CObject classes definition:
Virtual base to provide a compiler-independent RTTI system.
GLsizei GLsizei GLuint * obj
Virtual base class for "schematic archives" (JSON, XML,...)
void 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...
GLsizei const GLchar ** string
struct mxArray_tag mxArray
Forward declaration for mxArray (avoid #including as much as possible to speed up compiling) ...
~CSerializable() override=default
Virtual base class for "archives": classes abstracting I/O streams.
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.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
virtual uint8_t serializeGetVersion() const =0
Must return the current versioning number of the object.
virtual const mrpt::rtti::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
virtual void serializeFrom(CSchemeArchiveBase &in)
Virtual method for reading (deserializing) from an abstract schema based archive. ...