Go to the documentation of this file.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 class OBConversion;
00031
00032
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
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*>& ){ 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
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;
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;
00091 }
00092 return true;
00093 }
00094 };
00095
00138 }
00139
00140 #endif
00141