Version 1 (modified by 14 years ago) ( diff ) | ,
---|
Structure of the code
Here, we try to explain the general structure of the code, which hopefully helps you to more easily whether stuff is already there or not.
NOTE: Usually, there is a single class defined per file and the file is called the same way as the class (maybe without capital letters). I.e. see the header file of the class for information about its member functions and what they can do.
Classes
World
The World is the most important class. It is a singleton and is the container for all atoms. Atoms are created and destroyed by the World only. The World observes the atoms and is notified of changes. In turn the World notifies Parsers that they have to store updated information. Molecules are created and destroyed by the World only.
Atom
An Atom is the basic unit of the code, it contains a Vector as position and velocity information, mass and an element reference. Also it has bonding information, created by the bondgraph or during parsing, to which others atoms it is connected. Atoms have a unique id by which they can be referenced.
Creation
molecule * World::getInstance().createAtom()
Annihilation
World::getInstance().destroyAtom(atom *)
Molecule
Molecules are containers for subsets of atoms that are connected by bonds.
Creation
molecule * World::getInstance().createMolecule()
Annihilation
World::getInstance().destroyMolecule(molecule *)
Vector
Vectors and matrices and essential for all manipulations on atoms, as everything is about their position in the simulation domain. Hence, all vector and matrix operations are present (i.e. adding, subtracting, scaling, rotating, ...)
logger
All output is not done via std::cout or std::cerr but via logger and errorlogger classes, that can be used like this
DoLog(?) && (Log() << Verbose(?) << "blabla");
where "blabla" can be anything you want, also: "<< *Walker << " at position " << Walker->x <<" (i.e. concatenated stream operations). Note that ? has to be replaced by a number marking the urgency of the message, where 0 is absolutely urgent, while 9 is absolutely not (depending on the verbosity level the user has specified).
Note that the errorlogger is for errors and warnings only and has the same way of calling, just replace "Log" with "eLog" everywhere(!).
Others
- element and periodentafel - contain elements
- bondgraph - contains information on how to deduce bonding structure, can be loaded from a distance table from file
- tesselation - creates surface meshes of molecules, used for distance checks and so on
- gslvector, gslmatrix, linearsystemofequations - inclusion of GSL matrix solving system for arbitrary matrices and vectors.
- vector, line, plane, space - geometrical objects whose intersection can be sought.
File structure
So far, there is still a lot of files to be found directly under the src folder. However, there also some subfolders which contain encapsulated mechanisms oder general patterns
- Actions: Every function that interacts with the user is a class derived from an action and resides herein along with classes containing those actions or information and how to use them,
- Descriptors: Descriptors identifty subsets of atoms, elements, molecules by id, by type, by name.
- Exceptions: Exceptions are thrown when something goes unexpectedly wrong such as vectors being linearly dependent or when a value is below a MYEPSILON threshold
- Helpers: Herein are contained stuff such as ASSERTs, that make the code fail when something goes wrong that should absolutely not, or the MemDebugger.
- Parser: Parsers do all the input and output stuff, reading atoms from files and writing them to files.
- Patterns: Patterns are general concepts of object-oriented programming, such as singletons, cachables, observables. They are very important and their use is imperative!
- UIElements: These contain all user interaction elements such as windows, dialogs, queries and the containing factory for each of the three user interfaces.
- unittests: Herein all component or unit tests are gathered that check a certain functionality of the code.