With the utility functions presented in the last section writing an "xdr" method for our class Rot2d from section 5.3.5 is no problem:
We just write version, the superclass and all instance variables. Of course we have to add the "xdr" method to the project's method list before we can use it.ROT2D *rot2d_xdr(XDR *xdrp) { ROT2D *self; int ver = 1; self = (ROT2D *)START_METHOD(G_INSTANCE); ASSURE(self, "", END_METHOD(NULL)); if(!g_xdr_version(xdrp, &ver) || !g_xdr_superclass(xdrp, (INSTANCE *)self) || !g_xdr_instance(xdrp, (INSTANCE **)&self->curve) || !g_xdr_instance(xdrp, (INSTANCE **)&self->axis) || ! xdr_double(xdrp, &self->angle) || ! xdr_int(xdrp, &self->discr) || ! xdr_int(xdrp, &self->current)) END_METHOD(NULL); END_METHOD(self); }
Now you can try out what happens if an "xdr" method or a class is missing. Start the program, add the rotate project, create a rotational surface and write it to a file using the button in the manag menu. Now exit the program, start it again and read the file back in using the button without adding the rotate project. You get just a Triang2d instance without axis and curve, since the Rot2d class and its "xdr" method were missing the data for this class was skipped and only the superclass data was read.
Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.