Code Architecture
 
GAMGI source code is in the src directory, distributed over the sub-directories engine, gtk, mesa, math, chem, phys, io, expat and global. The code in the gtk directory (TODO) is in turn partially distributed over sub-directories text, atom, bond, light, layer, etc., one for each object class.

Each directory has a makefile, listing all the local source files. These makefiles are then included in the global makefiles, in the src directory.

Each directory has a common header .h file, containing all the relevant type definitions, enumerations, macros, plus library headers that are relevant for that section of the code. This information should be included in the common header files only (library headers which are needed only once, are included directly in that specific source file, to reduce compilation time). The common header files are then included in the .c source files everytime that information is needed.

Every .c file has a corresponding .h file, containing: 1) full declarations (including argument names) of all the functions in the source file, including local (commented) functions; 2) a rationale describing the mains aspects of the control flow. Local functions are classified as static and start with the prefix static_. Global functions start with the name of the file containing them.

All files start with the prefix gamgi_ and for each directory in the file path after the src directory a new prefix is added, with the name of the directory. Thus a file (and the external functions inside) in the directory src/engine must have a prefix gamgi_engine. With this naming conventions it is easy to: 1) distinguish static and external Gamgi functions; 2) distinguish Gamgi and library functions; 3) to identify where is the file that contains a given Gamgi external function.

To understand GAMGI control flow, the first file to check is /src/global/gamgi_global_main.c, where GAMGI starts and ends. To understand GAMGI data flow, the first file to check is /src/engine/gamgi_engine.h, which contains the primary data types and definitions.

GAMGI has one global variable, called gamgi, declared in gamgi_global.h. This header file is then included everytime gamgi is needed. This declaration is actually redundant, as the gamgi address (TODO) can be acessed as the parent object for all the windows objects, but it makes code slightly simpler.

Home