All classes, methods and items of a projects are added by the method
How does a project know that it is in use? Everytime the method "use" is called the project's use count is increased. If the use count is zero the project isn't in use, then the classes, methods and items have to be added and the init-method is called. When "unuse" (see below) is called the use count is decreased and if it is zero all the objects added by "use" are removed after the exit-method has been called. The projects the project depends upon are "(un)use"d every time the methods are called to correct their use counter.
The init-method should do initializations for the project that cannot be done in the setup-method. For example if you have to call some method defined in the project before the project can be used, this is the place to do it, because when the init-method is called all classes and methods of the project are available. This method is called every time the project wasn't in use and is used again, therefore if some action has only to be taken once then a static flag has to be used.
An example is the init-method of our demo project in section 5.6.6.4 where the method "get-editor" is called to create the user-interface. Items that should be managed by the project cannot be added to the manager with "add-inter" or "add-inter-for-opt" directly, but they have to be added to the project with
The method
The add-method is called everytime the project is "add"ed. It can be used to create an object (or hierachy of objects) that should be included in the data hierarchy by the project. The object is declared to the project with
This method is used by the add-method of our demo project to add a Rot2d instance to the data hierarchy (see section 5.6.6.3).
When projects are created with g_project_include the project pointer is not available and therefore "use" and "add" cannot be called directly. Nevertheless the methods can be called with the functions
PROJECT * g_project_use(char * name, int batch);because project names are unique. The project pointer is returned by the functions to indicate that they were successful, if they return NULL something has failed, perhaps there was no project name.
PROJECT * g_project_add(char * name);
Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.