66 const std::string err =
68 std::string(
" : class does not support schema based serialization");
76 const std::string err =
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, NS) \ 153 DEFINE_MRPT_OBJECT(class_name, NS) \ 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; \ 166 #define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace) \ 167 IMPLEMENTS_MRPT_OBJECT(class_name, base, NameSpace) 171 #define DEFINE_VIRTUAL_SERIALIZABLE(class_name) \ 172 DEFINE_VIRTUAL_MRPT_OBJECT(class_name) 177 #define IMPLEMENTS_VIRTUAL_SERIALIZABLE(class_name, base_class, NS) \ 178 IMPLEMENTS_VIRTUAL_MRPT_OBJECT(class_name, base_class, NS) 180 #define IMPLEMENTS_VIRTUAL_SERIALIZABLE_NS_PREFIX(class_name, base_class, NS) \ 181 IMPLEMENTS_VIRTUAL_MRPT_OBJECT_NS_PREFIX(class_name, base_class, NS) 185 #define DECLARE_MEX_CONVERSION \ 189 mxArray* writeToMatlab() const override; \ 194 #define DECLARE_MEXPLUS_FROM(complete_type) \ 197 template <typename T> \ 198 mxArray* from(const T& value); \ 200 mxArray* from(const complete_type& value); \ 203 #define IMPLEMENTS_MEXPLUS_FROM(complete_type) \ 207 mxArray* from(const complete_type& var) \ 209 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.
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...
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.
mrpt::vision::TStereoCalibResults out
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. ...