Base class for custom serialization. More...
#include <Serializer.h>
Public Member Functions | |
virtual | ~Serializer () |
Destructor. | |
virtual void | write (ObjectDataOutput &out, const Serializable &object)=0 |
This method writes object to ObjectDataOutput. More... | |
virtual void | read (ObjectDataInput &in, Serializable &object)=0 |
Reads object from objectDataInputStream. More... | |
Public Member Functions inherited from hazelcast::client::serialization::SerializerBase | |
virtual | ~SerializerBase () |
Destructor. | |
virtual int | getTypeId () const =0 |
unique type id for this serializer. More... | |
Base class for custom serialization.
If your all classes that needs to be serialized inherited from same class you can use an implementation like following
class MyCustomSerializer : public serialization::Serializer<ExampleBaseClass> { public: void write(serialization::ObjectDataOutput & out, const ExampleBaseClass& object); void read(serialization::ObjectDataInput & in, ExampleBaseClass& object); int getTypeId() const; }; } Or if they are not inherited from same base class you can use a serializer class like following with templates. template<typename T> class MyCustomSerializer : public serialization::Serializer<T> { public: void write(serialization::ObjectDataOutput & out, const T& object) {
..... }
void read(serialization::ObjectDataInput & in, T& object) { ..... }
int getTypeId() const { .. } };
User than can register serializer via SerializationConfig as follows clientConfig.getSerializationConfig().registerSerializer(new MyCustomSerializer());
|
pure virtual |
Reads object from objectDataInputStream.
in | ObjectDataInput stream that object will read from |
object | read object |
|
pure virtual |
This method writes object to ObjectDataOutput.
out | ObjectDataOutput stream that object will be written to |
object | that will be written to out |