OBOp Class Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes
OBOp Class Reference

`#include <openbabel/op.h>`

Inheritance diagram for OBOp:
[legend]

List of all members.

## 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 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

## Detailed Description

Operations to modify molecules before output.

Since:
  version 2.2

Classes derived from OBOp implement options for the babel 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 babel -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:

- OpOptions(OBBase* pOb, OpMap* pOptions) returns a string describing each of the derivated classes relevant to objects of the class of the OBBase parameter, for use in the help text and to set checkboxes in the GUI;
- DoOps(OBBase* pOb) applies each option whose ID is listed in the Opmap parameter to the object (ususally an OBMol) in the OBBase parameter.

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 clas with ID gen3D to your mol

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

## Member Typedef Documentation

typedef const std::map<std::string, std::string> OpMap

## Member Function Documentation

virtual const char* TypeID | ( |  | ) | `[inline, virtual]`

Provides the name of this kind of plugin. Use -L "ops" to list from commandline.

Reimplemented from OBPlugin.

virtual bool Do | ( | OBBase * | pOb,
|  | const char * | OptionText = `NULL`,
|  | OpMap * | pOptions = `NULL`,
|  | OBConversion * | pConv = `NULL`
| ) |  | `[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().

virtual bool WorksWith | ( | OBBase * | pOb | ) | const`[pure virtual]`

Returns:
  true if this op is designed to work with the class of pOb, e.g. OBMol

Implemented in OpTransform.

Referenced by OBOp::OpOptions().

virtual bool ProcessVec | ( | std::vector< OBBase * > & |  | ) | `[inline, virtual]`

Do something with an array of objects. Used a a callback routine in OpSort, etc.

static std::string OpOptions | ( | OBBase * | pOb | ) | `[inline, static]`

Returns:
  string describing options, for display with -H and to make checkboxes in GUI

static bool DoOps | ( | OBBase * | pOb,
|  | OpMap * | pOptions,
|  | OBConversion * | pConv
| ) |  | `[inline, static]`

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)

Returns:
  false indicating object should not be output, if any Do() returns false

The documentation for this class was generated from the following file:

- op.h

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines