Home You are here: Home > Support > Reference v1.0

Change language: German

Persistence / Streaming

To be able to store and load the data of classes derived from exom::XmObject, persistence is a core feature of the framework. To enable high performance and low usage of system resources loading and storing will be done by streaming object data.

The serialisation format and the interface for using it are independent. This enable changing the serialisation format without chaning the application code. The serialisation format supported by the exom core is XML. A binary format will be added in future.

The common serialisation and deserialisation of a class derived from XmObject will be done by its implementaion of exom::XmObject::manage().

// --- XmObject ---
void   MyClass::manage (XmMan& m)
    m.manObj (subObject);
    m.manInt32 (myInt, myns.ATM_MY_INT);

Extended deserialisation

If it is necessary to change error handling and allow additional initialization during deserialisation the framework provide exom::XmSeriExt. To enable extended deserialisation, a class have to replace the default serialisation handler by returning another handler in exom::XmObject::GetSeriExt().

class MyClass : public XmObject,
                public XmSeriExt
    // --- XmObject ---
    XmSeriExt&  GetSeriExt ()               { return *this; }
    // --- XmSeriExt ---
    void        OnPostReadObj   (XmManSeriRead& sr)
        // do something additional

Alternatively it is possible to implement exom::XmSeriExt in a separate class and return its reference in exom::XmObject::GetSeriExt().

Using serialisation/deserialisation

To serialize a class instance derived from XmObject you need a serializer (derived from exom::XmManSeriWrite) and an out-stream (derived from exom::XmStreamOut). So serialisation in XML will be done by:

    XmStreamOutFile outFile ("myFile");
    XmManSeriWriteXml seri;
    seri.WriteXmlObj (myClass, outFile);

For deserialisation a deserializer (derived from exom::XmManSeriRead) and an in-stream (derived from exom::XmStreamIn) are necessary. Deserialisation form the XML file will be done by:

    XmStreamInFile inFile ("myFile");
    XmManSeriReadXml deSeri (SF_DEFAULT);
    deSeri.ReadXmlObj (myClass, inFile);

Generation of array items

During deserialisation it may be necessary to read container items. Since containers in the exom framework are implemented by exom::XmArray its interface function exom::XmArray::AppendNewItem() is used for generation of array items. Typical XmArray implementations encapsulate this for you, like exom::TXmObjectVector and exom::TXmObjectList are doing.

Copyright © 2006 Praetz Software Development - www.exomware.com