00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OB_PLUGIN_H
00020 #define OB_PLUGIN_H
00021
00022 #include <openbabel/babelconfig.h>
00023 #include <string>
00024 #include <iostream>
00025 #include <vector>
00026 #include <map>
00027 #include <sstream>
00028 #include <cstring>
00029
00030 #ifndef OBERROR
00031 #define OBERROR
00032 #endif
00033
00034 namespace OpenBabel
00035 {
00038
00040 struct OBERROR CharPtrLess : public std::binary_function<const char*,const char*, bool>
00041 {
00042 bool operator()(const char* p1,const char* p2) const
00043 { return strcasecmp(p1,p2)<0; }
00044 };
00045
00051 class OBERROR OBPlugin
00052 {
00053 public:
00054
00055
00056
00057
00058 typedef std::map<const char*, OBPlugin*, CharPtrLess> PluginMapType;
00059 typedef PluginMapType::const_iterator PluginIterator;
00060
00062 virtual ~OBPlugin(){};
00063
00065 virtual const char* Description() { return NULL;} ;
00066
00068 virtual const char* TypeID(){ return "plugins"; }
00069
00075 virtual bool Display(std::string&txt, const char* param, const char* ID=NULL);
00076
00081 virtual OBPlugin* MakeInstance(const std::vector<std::string>&){return NULL;}
00082
00085 virtual void Init(){};
00086
00089 static OBPlugin* GetPlugin(const char* Type, const char* ID);
00090
00092 const char* GetID()const{return _id;};
00093
00097 static bool ListAsVector(const char* PluginID, const char* param, std::vector<std::string>& vlist);
00098
00100 static void List(const char* PluginID, const char* param=NULL, std::ostream* os=&std::cout);
00101
00103 static std::string ListAsString(const char* PluginID, const char* param=NULL);
00104
00106 static std::string FirstLine(const char* txt);
00107
00110 static PluginIterator Begin(const char* PluginID)
00111 {
00112 if( !strcmp(PluginID, "plugins") || GetTypeMap(PluginID)!=PluginMap())
00113 return GetTypeMap(PluginID).begin();
00114 else
00115 return PluginMap().end();
00116 }
00117
00118 static PluginIterator End(const char* PluginID)
00119 {
00120 return GetTypeMap(PluginID).end();
00121 }
00122
00124 virtual PluginMapType& GetMap() const =0;
00125
00126 protected:
00129 static PluginMapType& PluginMap()
00130 {
00131 static PluginMapType m;
00132 return m;
00133 }
00134
00136 static PluginMapType& GetTypeMap(const char* PluginID);
00137
00140 static OBPlugin* BaseFindType(PluginMapType& Map, const char* ID);
00141
00142 protected:
00143 const char* _id;
00144 };
00145
00146 #if defined(__CYGWIN__) || defined(__MINGW32__)
00147
00148
00149 #define MAKE_PLUGIN(BaseClass)\
00150 protected:\
00151 static PluginMapType& Map();\
00152 virtual PluginMapType& GetMap()const{return Map();}\
00153 public:\
00154 static BaseClass*& Default(){static BaseClass* d;return d;}\
00155 BaseClass(const char* ID, bool IsDefault=false)\
00156 {_id=ID;if(ID&&*ID){if(IsDefault || Map().empty()) Default() = this;\
00157 Map()[ID]=this;PluginMap()[TypeID()] =this;}}\
00158 static BaseClass* FindType(const char* ID)\
00159 {if(!ID || *ID==0 || *ID==' ') return Default();\
00160 return static_cast<BaseClass*>(BaseFindType(Map(),ID));}
00161
00162 #define PLUGIN_CPP_FILE(BaseClass)\
00163 OBPlugin::PluginMapType& BaseClass::Map()\
00164 { static OBPlugin::PluginMapType map; return map; }
00165
00166 #else // __CYGWIN__ || __MINGW32__
00167
00168
00169 #define MAKE_PLUGIN(BaseClass)\
00170 protected:\
00171 static PluginMapType& Map(){static PluginMapType m;return m;}\
00172 virtual PluginMapType& GetMap()const{return Map();}\
00173 public:\
00174 static BaseClass*& Default(){static BaseClass* d;return d;}\
00175 BaseClass(const char* ID, bool IsDefault=false)\
00176 {_id=ID;if(ID&&*ID){if(IsDefault || Map().empty()) Default() = this;\
00177 Map()[ID]=this;PluginMap()[TypeID()] =this;}}\
00178 static BaseClass* FindType(const char* ID)\
00179 {if(!ID || *ID==0 || *ID==' ') return Default();\
00180 return static_cast<BaseClass*>(BaseFindType(Map(),ID));}
00181
00182 #endif // __CYGWIN__ || __MINGW32__
00183
00312
00320
00321
00322 #ifndef SWIG // Skipped by SWIG (for the moment)
00323
00324 #ifndef USING_DYNAMIC_LIBS
00325
00326 #define OB_STATIC_PLUGIN(className,instanceName) \
00327 class className; \
00328 OBAPI EXTERN className instanceName;
00329
00330
00331 OB_STATIC_PLUGIN(ACRFormat, theACRFormat)
00332 OB_STATIC_PLUGIN(ADFOutputFormat, theADFOutputFormat)
00333 OB_STATIC_PLUGIN(ADFInputFormat, theADFInputFormat)
00334 OB_STATIC_PLUGIN(AlchemyFormat, theAlchemyFormat)
00335 OB_STATIC_PLUGIN(AmberPrepFormat, theAmberPrepFormat)
00336 OB_STATIC_PLUGIN(OBAPIInterface, theOBAPIInterface)
00337 OB_STATIC_PLUGIN(BallStickFormat, theBallStickFormat)
00338 OB_STATIC_PLUGIN(BGFFormat, theBGFFormat)
00339 OB_STATIC_PLUGIN(BoxFormat, theBoxFormat)
00340 OB_STATIC_PLUGIN(CacaoFormat, theCacaoFormat)
00341 OB_STATIC_PLUGIN(CacheFormat, theCacheFormat)
00342 OB_STATIC_PLUGIN(CARFormat, theCARFormat)
00343 OB_STATIC_PLUGIN(CCCFormat, theCCCFormat)
00344 OB_STATIC_PLUGIN(CHEM3D1Format, theCHEM3D1Format)
00345 OB_STATIC_PLUGIN(CHEM3D2Format, theCHEM3D2Format)
00346 OB_STATIC_PLUGIN(ChemDrawBinaryFormat, theChemDrawBinaryFormat)
00347 OB_STATIC_PLUGIN(ChemDrawFormat, theChemDrawFormat)
00348 OB_STATIC_PLUGIN(ChemKinFormat, theChemKinFormat)
00349 OB_STATIC_PLUGIN(CHTFormat, theCHTFormat)
00350 OB_STATIC_PLUGIN(CIFFormat, theCIFFormat)
00351 OB_STATIC_PLUGIN(CopyFormat, theCopyFormat)
00352 OB_STATIC_PLUGIN(CRK2DFormat, theCRK2DFormat)
00353 OB_STATIC_PLUGIN(CRK3DFormat, theCRK3DFormat)
00354 OB_STATIC_PLUGIN(CSRFormat, theCSRFormat)
00355 OB_STATIC_PLUGIN(CSSRFormat, theCSSRFormat)
00356 OB_STATIC_PLUGIN(DlpolyConfigFormat, theDlpolyConfigFormat)
00357 OB_STATIC_PLUGIN(DlpolyHISTORYFormat, theDlpolyHISTORYFormat)
00358 OB_STATIC_PLUGIN(DMolFormat, theDMolFormat)
00359 OB_STATIC_PLUGIN(FASTAFormat, theFASTAFormat)
00360 OB_STATIC_PLUGIN(FastSearchFormat, theFastSearchFormat)
00361 OB_STATIC_PLUGIN(FCHKFormat, theFCHKFormat)
00362 OB_STATIC_PLUGIN(FEATFormat, theFEATFormat)
00363 OB_STATIC_PLUGIN(FenskeZmatFormat, theFenskeZmatFormat)
00364 OB_STATIC_PLUGIN(FHIaimsFormat,theFHIaimsFormat)
00365 OB_STATIC_PLUGIN(FingerprintFormat, theFingerprintFormat)
00366 OB_STATIC_PLUGIN(FreeFormFractionalFormat, theFreeFormFractionalFormat)
00367 OB_STATIC_PLUGIN(GAMESSOutputFormat, theGAMESSOutputFormat)
00368 OB_STATIC_PLUGIN(GAMESSInputFormat, theGAMESSInputFormat)
00369 OB_STATIC_PLUGIN(OBGaussianCubeFormat, theGaussianCubeFormat)
00370 OB_STATIC_PLUGIN(GaussianOutputFormat, theGaussianOutputFormat)
00371 OB_STATIC_PLUGIN(GaussianInputFormat, theGaussianInputFormat)
00372 OB_STATIC_PLUGIN(GaussianZMatrixInputFormat, theGaussianZMatrixInputFormat)
00373 OB_STATIC_PLUGIN(GenBankFormat, theGenBankFormat)
00374 OB_STATIC_PLUGIN(GhemicalFormat, theGhemicalFormat)
00375 OB_STATIC_PLUGIN(GROMOS96Format, theGROMOS96Format)
00376 OB_STATIC_PLUGIN(GULPFormat, theGULPFormat)
00377 OB_STATIC_PLUGIN(HINFormat, theHINFormat)
00378 OB_STATIC_PLUGIN(JaguarOutputFormat, theJaguarOutputFormat)
00379 OB_STATIC_PLUGIN(JaguarInputFormat, theJaguarInputFormat)
00380 OB_STATIC_PLUGIN(MCDLFormat, theMCDLFormat)
00381 OB_STATIC_PLUGIN(MOLFormat, theMOLFormat)
00382 OB_STATIC_PLUGIN(SDFormat, theSDFormat)
00383 OB_STATIC_PLUGIN(OBT41Format, t41Format__)
00384 OB_STATIC_PLUGIN(OBMoldenFormat, moldenFormat__)
00385 OB_STATIC_PLUGIN(mmCIFFormat, themmCIFFormat)
00386 OB_STATIC_PLUGIN(MacroModFormat, theMacroModFormat)
00387 OB_STATIC_PLUGIN(MNAFormat, theMNAFormat)
00388 OB_STATIC_PLUGIN(MOL2Format, theMOL2Format)
00389 OB_STATIC_PLUGIN(MolproOutputFormat, theMolproOutputFormat)
00390 OB_STATIC_PLUGIN(MolproInputFormat, theMolproInputFormat)
00391 OB_STATIC_PLUGIN(MolReportFormat, theMolReportFormat)
00392 OB_STATIC_PLUGIN(MOPACFormat, theMOPACFormat)
00393 OB_STATIC_PLUGIN(MOPACCARTFormat, theMOPACCARTFormat)
00394 OB_STATIC_PLUGIN(MOPACINTFormat, theMOPACINTFormat)
00395 OB_STATIC_PLUGIN(MPDFormat, theMPDFormat)
00396 OB_STATIC_PLUGIN(MPQCFormat, theMPQCFormat)
00397 OB_STATIC_PLUGIN(MPQCInputFormat, theMPQCInputFormat)
00398 OB_STATIC_PLUGIN(MSIFormat, theMSIFormat)
00399 OB_STATIC_PLUGIN(OBMSMSFormat, msmsFormat__)
00400 OB_STATIC_PLUGIN(NulFormat, theNulFormat)
00401 OB_STATIC_PLUGIN(NWChemOutputFormat, theNWChemOutputFormat)
00402 OB_STATIC_PLUGIN(NWChemInputFormat, theNWChemInputFormat)
00403 OB_STATIC_PLUGIN(OBOpenDXCubeFormat, theOpenDXCubeFormat)
00404 OB_STATIC_PLUGIN(OutputFormat, theOutputFormat)
00405 OB_STATIC_PLUGIN(PCModelFormat, thePCModelFormat)
00406 OB_STATIC_PLUGIN(PDBFormat, thePDBFormat)
00407 OB_STATIC_PLUGIN(PDBQTFormat, thePDBQTFormat)
00408 #ifdef HAVE_LIBZ
00409 OB_STATIC_PLUGIN(PNGFormat, thePNGFormat)
00410 #endif
00411 OB_STATIC_PLUGIN(PovrayFormat, thePovrayFormat)
00412 OB_STATIC_PLUGIN(PQRFormat, thePQRFormat)
00413 OB_STATIC_PLUGIN(PQSFormat, thePQSFormat)
00414 OB_STATIC_PLUGIN(PWscfFormat, thePWscfFormat)
00415 OB_STATIC_PLUGIN(QChemOutputFormat, theQChemOutputFormat)
00416 OB_STATIC_PLUGIN(QChemInputFormat, theQChemInputFormat)
00417 OB_STATIC_PLUGIN(ReportFormat, theReportFormat)
00418 OB_STATIC_PLUGIN(SmiReactFormat, theSmiReactFormat)
00419 OB_STATIC_PLUGIN(RXNFormat, theRXNFormat)
00420 OB_STATIC_PLUGIN(ShelXFormat, theShelXFormat)
00421 OB_STATIC_PLUGIN(SMIFormat, theSMIFormat)
00422 OB_STATIC_PLUGIN(CANSMIFormat, theCANSMIFormat)
00423 OB_STATIC_PLUGIN(FIXFormat, theFIXFormat)
00424 OB_STATIC_PLUGIN(SVGFormat, theSVGFormat)
00425 OB_STATIC_PLUGIN(TextFormat, theTextFormat)
00426 OB_STATIC_PLUGIN(ThermoFormat, theThermoFormat)
00427 OB_STATIC_PLUGIN(TinkerFormat, theTinkerFormat)
00428 OB_STATIC_PLUGIN(TitleFormat, theTitleFormat)
00429 OB_STATIC_PLUGIN(TurbomoleFormat, theTurbomoleFormat)
00430 OB_STATIC_PLUGIN(UniChemFormat, theUniChemFormat)
00431 OB_STATIC_PLUGIN(VASPFormat, theVASPFormat)
00432 OB_STATIC_PLUGIN(ViewMolFormat, theViewMolFormat)
00433 OB_STATIC_PLUGIN(XEDFormat, theXEDFormat)
00434 OB_STATIC_PLUGIN(XYZFormat, theXYZFormat)
00435 OB_STATIC_PLUGIN(YOBFormat, theYOBFormat)
00436 OB_STATIC_PLUGIN(ZINDOFormat, theZINDOFormat)
00437 #ifdef HAVE_STATIC_LIBXML
00438 OB_STATIC_PLUGIN(ChemDrawXMLFormat, theChemDrawXMLFormat)
00439 OB_STATIC_PLUGIN(CMLFormat, theCMLFormat)
00440 OB_STATIC_PLUGIN(CMLReactFormat, theCMLReactFormat)
00441 OB_STATIC_PLUGIN(PubChemFormat, thePubChemFormat)
00442 OB_STATIC_PLUGIN(XMLFormat, theXMLFormat)
00443 #endif
00444 #ifdef HAVE_STATIC_INCHI
00445 OB_STATIC_PLUGIN(InChIFormat, theInChIFormat)
00446 #endif
00447 #ifdef HAVE_REGEX_H
00448 OB_STATIC_PLUGIN(GAMESSUKInputFormat, theGAMESSUKInputFormat)
00449 OB_STATIC_PLUGIN(GAMESSUKOutputFormat, theGAMESSUKOutputFormat)
00450 #endif
00451 #ifdef HAVE_RPC_XDR_H
00452 OB_STATIC_PLUGIN(XTCFormat, theXTCFormat)
00453 #endif
00454
00455
00456 OB_STATIC_PLUGIN(CanSmiles, theCanSmiles)
00457 OB_STATIC_PLUGIN(CompoundFilter, dummyCmpFilter)
00458 OB_STATIC_PLUGIN(MWFilter, theMWFilter)
00459 OB_STATIC_PLUGIN(SmartsFilter, firstSmartsFilter)
00460 OB_STATIC_PLUGIN(SmartsFilter, secondSmartsFilter)
00461 OB_STATIC_PLUGIN(TitleFilter, theTitleFilter)
00462 OB_STATIC_PLUGIN(FormulaDescriptor, TheFormulaDescriptor)
00463
00464 OB_STATIC_PLUGIN(InChIFilter, theInChIFilter)
00465
00466 OB_STATIC_PLUGIN(SmartsDescriptor, theHBD)
00467 OB_STATIC_PLUGIN(SmartsDescriptor, theHBA1)
00468 OB_STATIC_PLUGIN(SmartsDescriptor, theHBA2)
00469 OB_STATIC_PLUGIN(SmartsDescriptor, thenF)
00470
00471 OB_STATIC_PLUGIN(OBGroupContrib, thelogP)
00472 OB_STATIC_PLUGIN(OBGroupContrib, theTPSA)
00473 OB_STATIC_PLUGIN(OBGroupContrib, theMR)
00474
00475
00476 OB_STATIC_PLUGIN(fingerprint2, thefingerprint2)
00477 OB_STATIC_PLUGIN(PatternFP, FP3PatternFP)
00478 OB_STATIC_PLUGIN(PatternFP, FP4PatternFP)
00479
00480
00481 OB_STATIC_PLUGIN(OBForceFieldGaff, theForceFieldGaff)
00482 OB_STATIC_PLUGIN(OBForceFieldGhemical, theForceFieldGhemical)
00483 OB_STATIC_PLUGIN(OBForceFieldMMFF94, theForceFieldMMFF94)
00484 OB_STATIC_PLUGIN(OBForceFieldMMFF94, theForceFieldMMFF94s)
00485 OB_STATIC_PLUGIN(OBForceFieldUFF, theForceFieldUFF)
00486
00487
00488 OB_STATIC_PLUGIN(OpAddInIndex, theOpAddInIndex)
00489 OB_STATIC_PLUGIN(OpAddPolarH, theOpAddPolarH)
00490 OB_STATIC_PLUGIN(OpCanonical, theOpCanonical)
00491 OB_STATIC_PLUGIN(OpFillUC, theOpFillUC)
00492 OB_STATIC_PLUGIN(OpEnergy, theOpEnergy)
00493 OB_STATIC_PLUGIN(OpMinimize, theOpMinimize)
00494 OB_STATIC_PLUGIN(OpGen2D, theOpGen2D)
00495 OB_STATIC_PLUGIN(OpGen3D, theOpGen3D)
00496 OB_STATIC_PLUGIN(OpNewS, theOpNewS)
00497 OB_STATIC_PLUGIN(OpPartialCharge, theOpPartialCharge)
00498 OB_STATIC_PLUGIN(OpReadConformers, theOpReadConformers)
00499 OB_STATIC_PLUGIN(OpSort, theOpSort)
00500 OB_STATIC_PLUGIN(OpExtraOut, theOpExtraOut)
00501 #ifdef HAVE_STATIC_INCHI
00502 OB_STATIC_PLUGIN(OpUnique, theOpUnique)
00503 #endif
00504 #ifdef HAVE_EIGEN
00505 OB_STATIC_PLUGIN(OpConformer, theOpConformer)
00506 #endif
00507
00508
00509 OB_STATIC_PLUGIN(GasteigerCharges, theGasteigerCharges)
00510 OB_STATIC_PLUGIN(MMFF94Charges, theMMFF94Charges)
00511 #ifdef HAVE_EIGEN
00512 OB_STATIC_PLUGIN(QEqCharges, theQEqCharges)
00513 OB_STATIC_PLUGIN(QTPIECharges, theQTPIECharges)
00514 #endif
00515
00516 OBAPI std::vector<std::string> EnableStaticPlugins();
00517
00518 #endif // USING_DYNAMIC_LIBS
00519
00520 #endif // SWIG
00521
00522 }
00523
00524 #endif