00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OB_MOLECULEFORMAT_H
00020 #define OB_MOLECULEFORMAT_H
00021
00022 #ifdef _MSC_VER
00023 #include <hash_map>
00024 #endif
00025
00026 #if __GNUC__ == 4 && __GNUC_MINOR__ >= 1
00027 #include <tr1/unordered_map>
00028 #elif defined(USE_BOOST)
00029 #include <boost/tr1/unordered_map.hpp>
00030 #endif
00031
00032 #include <typeinfo>
00033
00034 #include <openbabel/mol.h>
00035 #ifdef HAVE_SHARED_POINTER
00036 #include <openbabel/reaction.h>
00037 #endif
00038 #include <openbabel/babelconfig.h>
00039 #include <openbabel/obconversion.h>
00040 #include <typeinfo>
00041 #include <openbabel/descriptor.h>
00042 #include <set>
00043
00044 namespace OpenBabel {
00045
00046
00047
00048 #ifndef OBCOMMON
00049 #define OBCOMMON
00050 #endif
00051
00066
00067
00068 class OBCOMMON OBMoleculeFormat : public OBFormat
00069 {
00070 public:
00071
00072 OBMoleculeFormat()
00073 {
00074 if(!OptionsRegistered)
00075 {
00076 OptionsRegistered=true;
00077 OBConversion::RegisterOptionParam("b", this, 0, OBConversion::INOPTIONS);
00078 OBConversion::RegisterOptionParam("s", this, 0, OBConversion::INOPTIONS);
00079 OBConversion::RegisterOptionParam("title", this, 1, OBConversion::GENOPTIONS);
00080 OBConversion::RegisterOptionParam("addtotitle",this, 1, OBConversion::GENOPTIONS);
00081 OBConversion::RegisterOptionParam("property", this, 2, OBConversion::GENOPTIONS);
00082 OBConversion::RegisterOptionParam("C", this, 0, OBConversion::GENOPTIONS);
00083 OBConversion::RegisterOptionParam("j", this, 0, OBConversion::GENOPTIONS);
00084 OBConversion::RegisterOptionParam("join", this, 0, OBConversion::GENOPTIONS);
00085 OBConversion::RegisterOptionParam("separate", this, 0, OBConversion::GENOPTIONS);
00086
00087
00088
00089
00090
00091 OBConversion::RegisterOptionParam("s", NULL, 1,OBConversion::GENOPTIONS);
00092 OBConversion::RegisterOptionParam("v", NULL, 1,OBConversion::GENOPTIONS);
00093 OBConversion::RegisterOptionParam("h", NULL, 0,OBConversion::GENOPTIONS);
00094 OBConversion::RegisterOptionParam("d", NULL, 0,OBConversion::GENOPTIONS);
00095 OBConversion::RegisterOptionParam("b", NULL, 0,OBConversion::GENOPTIONS);
00096 OBConversion::RegisterOptionParam("c", NULL, 0,OBConversion::GENOPTIONS);
00097 OBConversion::RegisterOptionParam("p", NULL, 1,OBConversion::GENOPTIONS);
00098 OBConversion::RegisterOptionParam("t", NULL, 0,OBConversion::GENOPTIONS);
00099 OBConversion::RegisterOptionParam("k", NULL, 0,OBConversion::GENOPTIONS);
00100 OBConversion::RegisterOptionParam("filter", NULL, 1,OBConversion::GENOPTIONS);
00101 OBConversion::RegisterOptionParam("add", NULL, 1,OBConversion::GENOPTIONS);
00102 OBConversion::RegisterOptionParam("delete", NULL, 1,OBConversion::GENOPTIONS);
00103 OBConversion::RegisterOptionParam("append", NULL, 1,OBConversion::GENOPTIONS);
00104 }
00105 }
00106
00108 static bool ReadChemObjectImpl(OBConversion* pConv, OBFormat*);
00110 static bool WriteChemObjectImpl(OBConversion* pConv, OBFormat*);
00111
00113 virtual bool ReadChemObject(OBConversion* pConv)
00114 { return ReadChemObjectImpl(pConv, this);}
00115
00117 virtual bool WriteChemObject(OBConversion* pConv)
00118 { return WriteChemObjectImpl(pConv, this);}
00119
00121
00122
00123
00124 static bool DeferMolOutput(OBMol* pmol, OBConversion* pConv, OBFormat* pF);
00126 static bool OutputDeferredMols(OBConversion* pConv);
00128 static bool DeleteDeferredMols();
00130 static OBMol* MakeCombinedMolecule(OBMol* pFirst, OBMol* pSecond);
00132
00134
00135 #ifdef HAVE_SHARED_POINTER
00137 static bool OutputMolsFromReaction
00138 (OBReaction* pReact, OBConversion* pConv, OBFormat* pFormat);
00139 #endif
00140
00141 #ifdef _MSC_VER
00142 typedef stdext::hash_map<std::string, unsigned> NameIndexType;
00143 #elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1 && !defined(__APPLE_CC__)) || defined (USE_BOOST)
00144 typedef std::tr1::unordered_map<std::string, unsigned> NameIndexType;
00145 #else
00146 typedef std::map<std::string, unsigned> NameIndexType;
00147 #endif
00148
00149
00150 static bool ReadNameIndex(NameIndexType& index, const std::string& datafilename,
00151 OBFormat* pInFormat);
00152
00154 const std::type_info& GetType()
00155 {
00156 return typeid(OBMol*);
00157 }
00158
00159 private:
00160
00161 static bool OptionsRegistered;
00162 static std::map<std::string, OBMol*> IMols;
00163 static OBMol* _jmol;
00164 static std::vector<OBMol> MolArray;
00165 static bool StoredMolsReady;
00166 static OBDescriptor* _pDesc;
00167
00168 };
00169
00170 }
00171 #endif //OB_MOLECULEFORMAT_H
00172