Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
Public Member Functions | List of all members
hazelcast::client::serialization::Serializer< Serializable > Class Template Referenceabstract

Base class for custom serialization. More...

#include <Serializer.h>

+ Inheritance diagram for hazelcast::client::serialization::Serializer< Serializable >:

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...
 

Detailed Description

template<typename Serializable>
class hazelcast::client::serialization::Serializer< Serializable >

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());

Member Function Documentation

template<typename Serializable>
virtual void hazelcast::client::serialization::Serializer< Serializable >::read ( ObjectDataInput in,
Serializable &  object 
)
pure virtual

Reads object from objectDataInputStream.

Parameters
inObjectDataInput stream that object will read from
objectread object
template<typename Serializable>
virtual void hazelcast::client::serialization::Serializer< Serializable >::write ( ObjectDataOutput out,
const Serializable &  object 
)
pure virtual

This method writes object to ObjectDataOutput.

Parameters
outObjectDataOutput stream that object will be written to
objectthat will be written to out

The documentation for this class was generated from the following file: