Open Babel
3.0
|
#include <openbabel/op.h>
Public Types | |
typedef const std::map< std::string, std::string > | OpMap |
typedef std::map< const char *, OBPlugin *, CharPtrLess > | PluginMapType |
typedef PluginMapType::const_iterator | PluginIterator |
Public Member Functions | |
virtual const char * | TypeID () |
virtual bool | Do (OBBase *pOb, const char *OptionText=NULL, OpMap *pOptions=NULL, OBConversion *pConv=NULL)=0 |
virtual bool | WorksWith (OBBase *pOb) const =0 |
virtual bool | ProcessVec (std::vector< OBBase *> &) |
virtual const char * | Description () |
virtual bool | Display (std::string &txt, const char *param, const char *ID=NULL) |
virtual OBPlugin * | MakeInstance (const std::vector< std::string > &) |
virtual void | Init () |
const char * | GetID () const |
virtual PluginMapType & | GetMap () const =0 |
Static Public Member Functions | |
static std::string | OpOptions (OBBase *pOb) |
static bool | DoOps (OBBase *pOb, OpMap *pOptions, OBConversion *pConv) |
static OBPlugin * | GetPlugin (const char *Type, const char *ID) |
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) |
static void | LoadAllPlugins () |
Static Protected Member Functions | |
static PluginMapType & | PluginMap () |
static PluginMapType & | GetTypeMap (const char *PluginID) |
static OBPlugin * | BaseFindType (PluginMapType &Map, const char *ID) |
Protected Attributes | |
const char * | _id |
Static Protected Attributes | |
static int | AllPluginsLoaded = 0 |
Operations to modify molecules before output.
Classes derived from OBOp implement options for the obabel program (for both its commandline and GUI interfaces). It is intended for options that carry out some modification on the molecule(or reaction) after it has been input, but before it is output. An example is the –center option implemented in the OpCenter class in ops.cpp, which is a duplicate of the built in -c option for centering coordinates.
The advantage of plugin classes is that no existing code has to be modified when a new class is added. You can list those that are present by obabel -L ops or from a menu item in the GUI.
Any OBOp derived class has to have a constructor, a function returning a short description, and a Do() function which does the work. It also needs a WorksWith() function which is always the same when operating on OBMol objects. (It is not made a default to reducecode dependencies.) A single global instance of the class needs to be instantiated to define the ID, by which the class is subsequently accessed.
OBOp works by two of its static functions being called from code in transform.cpp:
Options which need parameters are passed these (space delimited) in the text parameter of the Do() function. They can also access other general options specified on the command line by examining the the OpMap parameter.
To use an OBOp class from the API it is necessary to use an extra step in case it isn't present. So to apply the OBOp class with ID gen3D to your mol
typedef const std::map<std::string, std::string> OpMap |
|
inlinevirtual |
Provides the name of this kind of plugin. Use -L "ops" to list from commandline.
Reimplemented from OBPlugin.
|
pure virtual |
Required function that does the work. Normally return true, unless object is not to be output.
Implemented in OpTransform.
Referenced by OBOp::DoOps().
|
pure virtual |
Implemented in OpTransform.
Referenced by OBOp::OpOptions().
|
inlinevirtual |
Do something with an array of objects. Used a a callback routine in OpSort, etc.
|
inlinestatic |
|
inlinestatic |
Call Do() of all the OBOps whose ID is a key in the map. Called from DoTransformations(). The map has general options like -x or –multicharoption The key is the option name and the value, if any, is text which follows the option name. In some cases, there may be several parameters, space separated)