User-defined types

In the general case, to enable a user-defined type for transmission, it must derive from the abstract base class TPO::Message.

class TPO::Message {
  virtual void serialize(TPO::Message_data&) const = 0;}
  virtual void deserialize(TPO::Message_data&) = 0;}
TPO::Message defines the pure virtual methods serialize and deserialize which must be implemented by the user-defined class. The are responsible for sending and receving the user-defined type, repsectively. For both methods, the TPO++ library provides an argument of type TPO::Message_data which is used to marshall the objects data. TPO::Message_data provides insert() and extract() methods, which can be supplied all legal datatypes including containers and other user-defined types. serialize() calls repeatedly insert() to prepare the objects member for transmission, and, symmetrically, deserialize() uses extract() the receive the objects member data. An example may illustrate this:

// Dynamic user-defined object
class my_complex : public TPO::Message {
  my_complex() : im(0.0), re(0.0) {}

  void serialize(Message_data& m) const {
  void deserialize(Message_data& m) {
  double re;
  double im;

Patrick Heckeler 2007-05-31