• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files

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.sourceforge.net/>
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 
00031 // Class introduction below
00032 class OBAPI OBOp : public OBPlugin
00033 {
00034   MAKE_PLUGIN(OBOp);
00035 
00036 public:
00037   typedef const std::map<std::string, std::string> OpMap ;
00038 
00040   virtual const char* TypeID(){ return "ops"; }
00041 
00043   virtual bool Do(OBBase* pOb, OpMap* pOptions=NULL, const char* OptionText=NULL)=0;
00044 
00046   virtual bool WorksWith(OBBase* pOb)const=0;
00047 
00049   static std::string OpOptions(OBBase* pOb)
00050   {
00051     std::string s;
00052     OBPlugin::PluginIterator itr;
00053     for(itr=OBPlugin::Begin("ops");itr!=OBPlugin::End("ops");++itr)
00054     {
00055       if(*(itr->first)=='_')//ignore ops with IDs that begin with '_'
00056         continue;
00057       OBOp* pOp = dynamic_cast<OBOp*>(itr->second);
00058       if(pOp && pOp->WorksWith(pOb))
00059       {
00060         s += "--";
00061         s += itr->first; //ID
00062         s += ' ';
00063         s += OBPlugin::FirstLine(pOp->Description()) + '\n';
00064       }
00065     }
00066     s += '\n';
00067     return s;
00068   }
00069 
00075   static bool DoOps(OBBase* pOb, OpMap* pOptions)
00076   {
00077     OpMap::const_iterator itr;
00078     for(itr=pOptions->begin();itr!=pOptions->end();++itr)
00079     {
00080       OBOp* pOp = FindType(itr->first.c_str());
00081       if(pOp)
00082         if(!pOp->Do(pOb, pOptions, itr->second.c_str()))
00083           return false; //Op has decided molecule should not be output
00084     }
00085     return true;
00086   }
00087 };
00088 
00131 }//namespace
00132 
00133 #endif
00134 

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

Documentation copyright © 1998-2007, the Open Babel Developers.
Open Babel is hosted by: SourceForge Logo
Generated on Thu Jul 3 14:30:34 2008 by doxygen 1.5.6.