next up previous contents index
Next: The "universal" Method Up: Methods for Debugging Previous: Debugging Instances

The Methods "get-info" and "follow"

 

If you have worked with the GRAPE manager before or read section 4.3.5.3 about the hierarchy management in GRAPE you may have asked yourself, how the information list you get when you click on the current instance is created, and how the instances around the current instances are determined. This is done by the following two methods.

   GRAPE(inst, "get-info")(list)
INSTANCE * inst
XLIST * list
The method can add as many strings containing information about the instance as wanted to the given list by calling the method "add-to-list" on list with a string as parameter, but first it should call "get-info" on the superclass to collect the information about it in the list.

For our Rot2d example we only add the rotation angle and the discretization to the list, all information about curve and axis can be obtain by changing the current instance of the manager (see below).

ROT2D *rot2d_get_info(XLIST *list)
{
  ROT2D *self;
  char str[MAX_STRLEN];

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

  /*
   * Most of the work is done by the superclass method. It puts
   * information about the name, class, refcount, number of points
   * and so on into the list.
   */
  GRAPE(self, "^get-info")(list);

  /*
   * Just add the angle and the discretization to the list. We
   * also could display information about axis and curve but
   * the user can get this information by changing the object
   * to axis or curve and then clicking on it.
   */
  sprintf(str, "angle: %f", self->angle);
  GRAPE(list, "add-to-list")(str);
  sprintf(str, "discr: %d", self->discr);
  GRAPE(list, "add-to-list")(str);

  END_METHOD(self);
}

The environment around the current instance of the manager is determined by the method

   GRAPE(inst, "follow")(obj, pop_push)
INSTANCE * inst
INSTANCE * obj[3][3]
char pop_push[3][3]
Each entry in the three by three arrays represents one of the three by three objects in the manager. First "follow" must be called on the superclass to initialize the arrays, then instance variables of inst can be put in the obj array. For each instance that is put into the array a character has to be put into the pop_push array, available are:
' '
No instance, this is the default set by Root "follow".
'd'
Go down: the current instance has to move left.
'n'
Like next_scene: the current instance has to move up.
'p'
Instance is pushed, pop it to go there.
'c'
Next element in a doubly linked list like timesteps. Since this instance will show the current instance in its "follow", don't push the current instance.

Don't worry if you don't understand this, it's really a bit complicated. Just look at the example for class Rot2d, this might help to understand how the method works.

ROT2D *rot2d_follow(INSTANCE *inst[3][3], char pop_push[3][3])
{
  ROT2D *self;

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

  /*
   * The inst and pop_push arrays define which objects will be
   * shown in the manager if a Rot2d instance is the current
   * object (there are three by three instances possible).
   * In this case the superclass method just initializes the
   * array with zeros, it does not provide its own environment.
   */
  GRAPE(self, "^follow")(inst, pop_push);

  /*
   * If we have axis and/or curve we want is to be shown top right
   * and right of the Rot2d instance. The `d' stands for `down',
   * this means that the Rot2d instance is moved to the left if
   * we click on the axis or curve.
   */
  if(self->axis) {
    inst[0][2] = (INSTANCE *)self->axis;
    pop_push[0][2] = 'd';
  }
  if(self->curve) {
    inst[1][2] = (INSTANCE *)self->curve;
    pop_push[1][2] = 'd';
  }

  END_METHOD(self);
}

next up previous contents index
Next: The "universal" Method Up: Methods for Debugging Previous: Debugging Instances

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.