Open Babel:

Plugins are a way of extending OpenBabel without having to alter any of the existing code. They may be built as shared libraries (DLLs with an extension .obf or .so files in a specified location) and distributed separately, but plugin classes can also be in the main code. In both cases they are discovered at startup when a global instance of the plugin class is instantiated. It iss registered by its constructor and is added to a static record of all the plugins of its particular type that are currently loaded.

There are two levels of plugin. The top layer (at the time of writing) are: formats descriptors fingerprints forcefields charges ops loaders but additional types can be added without disturbing the main API. At runtime babel -L will list the top level of plugins. They typically are abstract classes with virtual functions that define an interface for that type. Classes derived from these are the second layer of plugins, and can be listed at runtime like, for instance: babel -L formats cml where formats is the top level of plugin and cml is the id of a derived class of this type.

The top level of plugins will usually have their interfaces declared in header files compiled with the main API. The second level of plugin will typically not be known to the API at compile time, usually will not have a header file and must be accessed indirectly, to allow for the possibility that they may not be loaded:

       OBOp* pOp = OBOp::FindType("gen3D");
       if(!pOp)
         ...report error
       pOp->Do(mol);

This retrieves the global instance of the plugin. This is usually adequate but making a new instance may be appropriate in some cases.

Instances of some plugin classes can be constructed at startup from information in a text file and used in the same way as those defined in code. See OBDefine. This is appropriate for some classes that differ only by the datafile or SMARTS strings they use.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines