The GRAPE kernel consists of a set of functions which handle the message passing, i.e. invoke the appropriate function for the desired method on an instance or class.The main function will be invoked by
where obj is a pointer to the object which should receive the message given by a simple string. This string defines the name of the method. This GRAPE command supplies a pointer to the appropriate function which implements the method. The method will be executed if a parameter list (which might be empty) is supplied. Therefore a typical grape command looks like thisGRAPE(obj, message)
With an empty parameter list -- don't forget the empty parenthesis -- it should look like thisGRAPE(obj, message)(parm1, parm2, ...)
The structure of the message string defines the precedence to search for the corresponding function. No option given starts searching in the class of obj. If the message has a leading "=", the method is searched in the actual method's class. A leading "^" commences search in the superclass of the actual method class, multiple "^"'s can be used to skip superclasses. Additionally it is possible to use G_CAST_CLASS(obj, class) as object, then the search starts in class class. This should be preferred to using multiple "^"'s because it is easier to read and independent from changes in the class hierarchy.GRAPE(obj, message)()
implementing a new method all sub- and superclasses should be searched for methods with the same name. The new method should have the same parameter structure as these already existing equally named methods, this helps avoiding problems with inheritance.
There are two kinds of methods that can be used interactively. So called ``display methods'' are used to update the graphic window (see section 4.3.2), they should be marked by the suffix "-disp". The standard display method is called "display", it works on nearly every existing geometric object and should be implemented for every new geometry class (see section 5.4.6). Methods that can be send interactively to an object (e.g. a numerics method that can be started by a button press) should have the suffix "-send". Both types of methods obviously must be parameterless, parameters for them can for example be provided by rulers (see sections 5.4.6 and 5.5.5).
Now, what happens when you call GRAPE(obj, message)? Let message be the non-prefixed method "name", obj an instance of class Dummy. Then
There some points about the GRAPE call you should be aware of:
Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.