Open Babel: op.h Source File

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

- File List
- File Members

# op.h

Go to the documentation of this file.

    00001 /**********************************************************************
    00002 op.h - plugin options or operations
    00003
    00004 Copyright (C) 2007 by Chris Morley
    00005
    00006 This file is part of the Open Babel project.
    00007 For more information, see <http://openbabel.org/>
    00008
    00009 This program is free software; you can redistribute it and/or modify
    00010 it under the terms of the GNU General Public License as published by
    00011 the Free Software Foundation version 2 of the License.
    00012
    00013 This program is distributed in the hope that it will be useful, but
    00014 WITHOUT ANY WARRANTY; without even the implied warranty of
    00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00016 General Public License for more details.
    00017 ***********************************************************************/
    00018
    00019 #ifndef OB_OP_H
    00020 #define OB_OP_H
    00021
    00022 #include <openbabel/babelconfig.h>
    00023 #include <string>
    00024 #include <map>
    00025 #include <openbabel/plugin.h>
    00026 #include <openbabel/base.h>
    00027
    00028 namespace OpenBabel
    00029 {
    00030   class OBConversion; //used only as a pointer
    00031
    00032 // Class introduction below
    00033 class OBAPI OBOp : public OBPlugin
    00034 {
    00035   MAKE_PLUGIN(OBOp);
    00036
    00037 public:
    00038   typedef const std::map<std::string, std::string> OpMap ;
    00039
    00041   virtual const char* TypeID(){ return "ops"; }
    00042
    00044   //NOTE: the parameters were changed in r3532
    00045   virtual bool Do(OBBase* pOb, const char* OptionText=NULL, OpMap* pOptions=NULL, OBConversion* pConv=NULL)=0;
    00046
    00048   virtual bool WorksWith(OBBase* pOb)const=0;
    00049
    00051   virtual bool ProcessVec(std::vector<OBBase*>& /* vec */){ return false; }
    00052
    00054   static std::string OpOptions(OBBase* pOb)
    00055   {
    00056     std::string s;
    00057     OBPlugin::PluginIterator itr;
    00058     for(itr=OBPlugin::Begin("ops");itr!=OBPlugin::End("ops");++itr)
    00059     {
    00060       OBOp* pOp = dynamic_cast<OBOp*>(itr->second);
    00061        //ignore ops with IDs that begin with '_' or have "not displayed in GUI" in their first line of description
    00062       if(*(itr->first)=='_'
    00063         || OBPlugin::FirstLine(pOp->Description()).find("not displayed in GUI")!=std::string::npos)
    00064         continue;
    00065       if(pOp && pOp->WorksWith(pOb))
    00066       {
    00067         s += "--";
    00068         s += itr->first; //ID
    00069         s += ' ';
    00070         s += OBPlugin::FirstLine(pOp->Description()) + '\n';
    00071       }
    00072     }
    00073     s += '\n';
    00074     return s;
    00075   }
    00076
    00082   static bool DoOps(OBBase* pOb, OpMap* pOptions, OBConversion* pConv)
    00083   {
    00084     OpMap::const_iterator itr;
    00085     for(itr=pOptions->begin();itr!=pOptions->end();++itr)
    00086     {
    00087       OBOp* pOp = FindType(itr->first.c_str());
    00088       if(pOp)
    00089         if(!pOp->Do(pOb, itr->second.c_str(), pOptions, pConv))
    00090           return false; //Op has decided molecule should not be output
    00091     }
    00092     return true;
    00093   }
    00094 };
    00095
    00138 }//namespace
    00139
    00140 #endif
    00141

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

This file is part of the documentation for Open Babel, version 2.3.

Documentation copyright © 1998-2007, the Open Babel Developers.
Open Babel is hosted by:
Generated on Mon Oct 25 2010 11:55:11 by 1.7.2.