Changes between Version 5 and Version 6 of Documentation/Serialization


Ignore:
Timestamp:
Feb 4, 2010, 6:43:27 PM (15 years ago)
Author:
Christoph Mayer
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/Serialization

    v5 v6  
    9696}}}
    9797
     98The code which is between {{{sznBeginDefault}}} and {{{sznEnd}}} is called for serialization and for deserialization. Sometimes it is necessary to distinguish between the two for special handling. Therefore, you can use the functions
     99{{{
     100#!cpp
     101X.isSerializer()
     102X.isDeserializer()
     103}}}
    98104
     105When you want to have several message classes, you require one contained class where to can store which inner class is carried. This is, because messages don't carry there type with them. This means you always must know what kind of message you are delivered. Therefore, make a container class where you store the specific type stored. Make sure that your base class serializer always triggers serialization of the encapsulated class through
     106{{{
     107#!cpp
     108X && Payload();
     109}}}
    99110
    100 
    101 if (X.isDeserializer())
     111You will find the following code in the !PingPong sample that shows how to convert the incoming message to your format and invoke the deserializer:
     112{{{
     113void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) {
     114    PingPongMessage* pingmsg = msg.getMessage()->convert<PingPongMessage> ();
     115    ...
     116}       
     117}}}
    102118
    103119