Plugins

From Open Babel

Jump to: navigation, search

Design3plugin.png

All plugins inherit from OBPlugin, this class has public GetType(), GetName() and GetDescription() methods and a protected SetInfo() method which can be called by friend class OBPluginFactory. OBPlugin doesn't have any other uses at the moment and no OBPlugin methods have to be re-implemented or called when creating plugins.

Real plugins inherit from an OBPluginInterface, which itself inherits from OBPlugin. These interfaces are the types of plugins, they have pure virtual functions to be implemented in the derived plugin class. OBMoleculeFormat, OBDescriptor, OBFingerprint, ... are all plugins interfaces. In the future, perception models will also be plugins with matching interfaces. (Note: there is no OBPluginInterface class, this is just to make the diagram more generic.)

A plugin will need to use the MAKE_FACTORY(Class, ClassFactory) macro to create a derived OBPluginFactory. The plugin will also need to declare a static instance of the derived OBPluginFactory with the type, name and description as parameters:

#include <openbabel/descriptor.h>

class MyDescriptor : public OBDescriptor
{
  public:
    double Predict (...) 
    {
      ...
      return ...;
    }
};

MAKE_FACTORY(MyDescriptor, MyDescriptorFactory)
MyDescriptorFactory myDescriptionFactory(OBPlugin::DescriptorType, "MyDescriptor", "description...")

Improvements compared to 2.2:

TODO:

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox