We will introduce Serialization using the PingPong sample provided by Ariba. You will find the following code in PingPongMessage.h:
The message format for communication between Ariba PingPong instances is defined in the class PingPongMessage. It inherits from the Message class and uses the macro VSERIALIZEABLE; to declare this class as being able to serialize and deserialize itself. Note, that each such class must provide a default constructor that takes no arguments. The PingPongMessage defines two properties id and name that it wants to communicate to a remote instance.
As you can see above, CLASSNAME is in the case of the PingPong sample the complate namespace with the class name ariba::application::pingpong::PingPongMessage. Furthermore the variables that are meant for serialization are combined to the X using the && operator. This operator is invoked both when serializing and when deserializing. Therefore, this is the only special code handling required.
Note the T() macro that is used for serialization of std::string objects. The following special handlers are provided:
(De-)Serializes a string. If no length is given, the string is serialized zero-terminated. If a length is given the length must be serialized and taken care of separately.
It is always best to use types that have a specified length, e.g. uint8_t, uint16_t, ... etc. If you are serializing through a inherited type where the serialization is provided in the base class, use the & operator before. Such a case is e.g. the NodeID class:
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
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
Sometimes, it is necessary to transfer a complete vector of objects through a message. The following code is taken from the NodeListingReply.h file of the OneHop? overlay in Ariba.
In this message we want to transfer a vector that holds combinations of NodeID and EndpointDescriptor?. Also note, that we store pointers to EndpointDescriptors?:
In case of serialization the actual length len will be stored in the serialization, in case of deserialization the len that has been set to the size of the vector will be overwritten with the value stored in the message. Next, in case we are performing a deserialization, we resize the vector according to the size stored in the message:
The following points are of importance: First, note the & before descriptors[i].first. This is required as the actual serialization code of the NodeID class remains in a base class. Second, we use the VO macro to deserialize through a pointer. In case of deserialization, this will directly create a new EndpointDescriptor object through the new operator.
Also Thursday, the Senate Judiciary Committee authorized - but did not issue - subpoenas to Gonzales and to the custodian of records at the Executive Office of the President for all administration documents on the legality of the program. The panel approved giving Chairman Patrick Leahy, D-Vt., authority to issue the subpoenas, 13-3, with Republican Sens. Arlen Specter of Pennsylvania, Orrin Hatch of Utah and Chuck Grassley of Iowa voting with the Democrats.
The White House made no move to comply. "It's important for Congress to understand that the information the committee is requesting is highly classified and not information we can make available," said Bush assified and not
The White House made no move to comply. "It's important for Congress to understand that the information the committee is requesting is highly classified and not information we can make available," said Bush
The White House made no move to comply. "It's important for Congress to understand that the information the committee is requesting is highly classified and not information we can make available," said Bush assified and not information we can make available," said Bush
The White House made no move to comply. "It's important for Congress to understand that the information the committee is requesting ongres
The White House made no move to comply. "It's important for Congress to understand that the information the committee is requesting is highly classified and not information we can make available," said Bush assified
The White House made no move to comply. "It's important for Congress to understand that the information the committee is requesting