OpenDaVINCI  4.16.0
odcore::serialization::Serializable Class Referenceabstract

#include <Serializable.h>

Inheritance diagram for odcore::serialization::Serializable:
Inheritance graph

Public Member Functions

virtual ~Serializable ()
 
virtual ostream & operator<< (ostream &out) const =0
 
virtual istream & operator>> (istream &in)=0
 

Detailed Description

This class is the interface for any serializable.

It can be used as follows:

class MyData : Serializable {
private:
int32_t m_data;
public:
ostream& operator<<(ostream &out) const {
SerializationFactory sf;
std::shared_ptr<Serializer> s = sf.getSerializer(out);
s->write(1, m_data);
return out;
}
istream& operator>>(istream &in) {
SerializationFactory sf;
std::shared_ptr<Deserializer> d = sf.getDeserializer(in);
d->read(1, m_data);
return in;
}
}

Constructor & Destructor Documentation

odcore::serialization::Serializable::~Serializable ( )
virtual

Member Function Documentation

virtual ostream& odcore::serialization::Serializable::operator<< ( ostream &  out) const
pure virtual

This method needs to be used to serialize data.

Parameters
outostream to serialize data to.
Returns
The ostream.

Implemented in odcore::data::image::CompressedImage, odcore::data::Container, and odcore::base::KeyValueConfiguration.

virtual istream& odcore::serialization::Serializable::operator>> ( istream &  in)
pure virtual

This method needs to be used to deserialize data.

Parameters
inistream to deserialize data from.
Returns
The istream.

Implemented in odcore::data::image::CompressedImage, odcore::data::Container, and odcore::base::KeyValueConfiguration.