Code Structure of OpenBabel

From Open Babel

Jump to: navigation, search

Since version 2.0 OpenBabel has had a modular structure. Version 2.1 will probably have version the shown in the diagram, which is a bit more subdivided. Particularly for the use of OpenBabel as a chemical file format converter, it aims to:


Structure of OpenBabel


The separate parts of the OpenBabel program are:

It is possible to build each box in the diagram as a separate DLL or shared library and the restricted dependencies helps to limit the amount of recompilation. For the formats or the fingerprints built in this way it may be possible to use only those whose DLL or so files are present when the program starts. Several formats or fingerprints may be present in a single dynamic library.

Alternatively, and most commonly, the same source code can be built into a single executable. The restricted dependencies still provide easier progam maintainance.

This segregation means that a module can directly call code only in other modules connected to it by forward arrows. So some discipline is needed when adding new code, and sometimes non-obvious work-arounds are necessary. For instance, since the user interface doesn't know about the Chemical Core, if it were necessary to set any parameters in it, then this would have to be done through a pseudo format OBAPIInterface. (In version 2.0 this was also necessary for altering the warning level in the Error handling code.)

Sometimes one format needs to use code from another format, for example, rxnformat needs to read mol files with code from mdlformat. The calling format should not use the code directly but should do it through a OBConversion object configured with the appropriate helper format.

The objects passed between the modules in the diagram above are polymorphic OBBase pointers. This means that the conversion framework can be used by any object derived from OBBase (which essentially means anything - chemical or not). Most commonly these refer to OBMol objects, less commonly to OBReaction objects, but could be extended to anything else without needing to change any existing code.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox