00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
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)=='_')
00056 continue;
00057 OBOp* pOp = dynamic_cast<OBOp*>(itr->second);
00058 if(pOp && pOp->WorksWith(pOb))
00059 {
00060 s += "--";
00061 s += itr->first;
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;
00084 }
00085 return true;
00086 }
00087 };
00088
00131 }
00132
00133 #endif
00134