next up previous contents index
Next: The GRAPE XDR Archiving Up: Projects Previous: The Rotate Init-Method

A Standard Main Program

 

All class and method declarations were removed from the main program, the Rot2d instance is created in "rotate-add" and the editor is created in "rotate-init" -- there is almost nothing left to do for the main program. The only thing that has to be done now is to declare the new project:

#include <grape.h>


/*
 * All functions used in the project list have to be declared.
 */
void *project_rotate_setup();


/*
 * List of user defined programs. Each entry consists of the
 * projects name, the name of the setup method, the pointer
 * to this method and a `hidden' flag. If the hidden flag is
 * not zero then the project will not be in the manager's
 * project list. The list has to be terminated by a null entry.
 */
static PRTYPE my_projects[] = {
  { "rotate", "rotate-setup", project_rotate_setup, 0 },

  { NULL, NULL, NULL, 0 }
};


int main()
{
  MANAGER *mgr;
  SCENE *scene;

  /*
   * Add all user defined projects to the system.
   */
  g_project_include(my_projects);

  /*
   * Get the manager and create a scene for handling.
   */
  mgr = (MANAGER *)GRAPE(Manager, "get-stdmgr")();
  scene = (SCENE *)GRAPE(Scene, "new-instance")("main");

  /*
   * Start the manager...
   */
  GRAPE(mgr, "handle")(scene);

  return 0;
}

A project list is used even though there is just one project at the moment, but when a new project is created is only has to be added to the list to make it available. Instead of a Rot2d instance a scene is created and given to the manager, the Rot2d instance will be created by adding the Rotate project from the manager's project list. Alternatively we could call

g_project_add("rotate");
before starting the manager, then the project would be added automatically.

All files for this demo project can be found in the directory demo/rot2d/project of the GRAPE distribution, most files are identical to the basic version presented in section 5.5.

This main program can be used as a model when projects are used for all applications. The user only needs one executable and all application are always available with a mouse click.



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.