#include <cel_serializable.h>
Public Member Functions | |
virtual void | serialize (Stream *inStream, size_t inLevel=0, Endian inEndian=endianBig)=0 |
virtual AutoPtr< Serializable > | duplicate () const =0 |
const Guid & | getClassId () const |
String | getClassName () const |
Public Member Functions inherited from Celartem::Referable | |
Referable () | |
void | addRef () const |
void | releaseRef () const |
size_t | getReferenceCount () const |
Additional Inherited Members | |
Static Public Member Functions inherited from Celartem::Referable | |
static void | dumpDbgAllRefCount () |
Serializable class is an interface that provides serialization and de-serialization feature.
To implement the serialization feature of your own class, all you have to do is to implement serialize, deserialize and duplicate methods. The implementation of serialize and deserialize is straightforward; but
the deserialize, method for the de-serialization is little bit more complicated, firstly you should implement a static method named deserialize that has the prototype shown below:
And then, you should register the class runtimely by using either of REGISTER_SERIALIZABLECLASS or REGISTER_SERIALIZABLECLASS2 macro.
|
pure virtual |
This method must be implemented by derived class. This method duplicates the instance.
Implemented in Celartem::SerializableData< T >, and Celartem::DataArray< T >.
const Guid& Celartem::Serializable::getClassId | ( | ) | const |
This method returns class Id (GUID) of the instance.
String Celartem::Serializable::getClassName | ( | ) | const |
This method returns class name of the instance.
Referenced by Celartem::DataStore::get().
|
pure virtual |
This method must be implemented by derived class. To implement the serialization feature of your own class, you should implement this method. All you have to do in the method is to write out the information of the instance to the specified stream that is needed when reproduce the instance in the memory.
inStream | The stream to which the instance information is written. |
inLevel | The serialization level. In the top level, this value is 0. |
inEndian | The endianness used to write the data. |
Implemented in Celartem::SerializableData< T >, and Celartem::DataArray< T >.