Changes between Version 5 and Version 6 of Documentation/Serialization
- Timestamp:
- Feb 4, 2010, 6:43:27 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Documentation/Serialization
v5 v6 96 96 }}} 97 97 98 The 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 101 X.isSerializer() 102 X.isDeserializer() 103 }}} 98 104 105 When 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 108 X && Payload(); 109 }}} 99 110 100 101 if (X.isDeserializer()) 111 You 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 {{{ 113 void PingPong::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk) { 114 PingPongMessage* pingmsg = msg.getMessage()->convert<PingPongMessage> (); 115 ... 116 } 117 }}} 102 118 103 119