|
bool | operator() (const char *p1, const char *p2) const |
|
virtual | ~OBPlugin () |
|
virtual const char * | Description () |
|
virtual const char * | TypeID () |
|
virtual bool | Display (std::string &txt, const char *param, const char *ID=NULL) |
|
virtual OBPlugin * | MakeInstance (const std::vector< std::string > &) |
|
virtual void | Init () |
|
static OBPlugin * | GetPlugin (const char *Type, const char *ID) |
|
const char * | GetID () const |
|
static bool | ListAsVector (const char *PluginID, const char *param, std::vector< std::string > &vlist) |
|
static void | List (const char *PluginID, const char *param=NULL, std::ostream *os=&std::cout) |
|
static std::string | ListAsString (const char *PluginID, const char *param=NULL) |
|
static std::string | FirstLine (const char *txt) |
|
static PluginIterator | Begin (const char *PluginID) |
|
static PluginIterator | End (const char *PluginID) |
|
virtual PluginMapType & | GetMap () const =0 |
|
static void | LoadAllPlugins () |
|
static PluginMapType & | PluginMap () |
|
static PluginMapType & | GetTypeMap (const char *PluginID) |
|
static OBPlugin * | BaseFindType (PluginMapType &Map, const char *ID) |
|
std::vector< std::string > | EnableStaticPlugins () |
|
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 obabel -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: obabel -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.
virtual OBPlugin* MakeInstance |
( |
const std::vector< std::string > & |
| ) |
|
|
inlinevirtual |