next up previous
Next: Locating Object on Up: UC++: The Language Previous: Restriction on Activatable

Marshallers

 

It is currently necessary to write your own marshallers for non-built in types. For example for type polygon these are written as follows (see also the polygon example):

/* in the header file */

class Polygon {
friend UCPP_OutputMessage& operator<<(UCPP_OutputMessage &M,const Polygon&);
friend UCPP_InputMessage& operator>>(UCPP_InputMessage &M, Polygon&);
public:
  int lowX, lowY, highX, highY;
};

/* and in a .cc file */

UCPP_OutputMessage& operator<<(UCPP_OutputMessage & M,const Polygon& P)
{
  M << P.lowX << P.lowY << P.highX << P.highY;
  return M;
}

UCPP_InputMessage& operator>>(UCPP_InputMessage &M, Polygon& P)
{
  M >> P.low.x >> P.low.y >> P.high.x >> P.high.y;
  return M;
}

Thus the marshallers and unmarshallers are defined in terms of marshallers for builtin tyeps, which are all pre-defined.

In due course UC++ will generate default marshallers for user defined classes automatically, see Section 6.2.3



send comments or suggestions to J.Poole@cs.ucl.ac.uk

Click here for more information on UCL-CS.