next up previous contents index
Next: g_xdr_instance Up: The GRAPE XDR Archiving Previous: Arrays

XDR Methods

 

Basically instances are handled like structures, but instead of a function a method called "xdr" is used. "xdr" methods exist for all geometry and hierarchy classes, for a complete list see the index.

The Scene "xdr" method is an example how the basic functions can be used to write/read an instance:

SCENE *scene_xdr(XDR *xdrp)
{
  SCENE *self;
  int ver = 1;

  self = (SCENE *)START_METHOD(G_INSTANCE);
  ASSURE(self, "", END_METHOD(NULL));

  if(!g_xdr_version(xdrp, &ver) ||
     !g_xdr_instance(xdrp, (INSTANCE **)&self->next_scene) ||
     !g_xdr_instance(xdrp, (INSTANCE **)&self->object) ||
     !g_xdr_matrix44(xdrp, self->object_trans) ||
     !  xdr_int(xdrp, &self->matrix_flag) ||
     !g_xdr_string(xdrp, &self->method_name) ||
     !g_xdr_instance(xdrp, (INSTANCE **)&self->suprop))
    END_METHOD(NULL);

  END_METHOD(self);
}
You should ignore the g_xdr_version function at the moment, version control is explained in section 5.7.4.

The matrix information is handled with g_xdr_matrix44 and xdr_int, the Scene method name with g_xdr_string. A NULL self->method_name pointer is handled automatically by the g_xdr_string function, if necessary memory for self->method_name is allocated on reading.

Again the XDR calls are combined, this time with ! and || which has (almost) the same effect as the && in the structure example above.





SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.