Open Babel: obmolecformat.h Source File

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

# obmolecformat.h

Go to the documentation of this file.

    00001 /**********************************************************************
    00002 obmolecformat.h - Subclass of OBFormat for conversion of OBMol.
    00003
    00004 Copyright (C) 2005 Chris Morley
    00005
    00006 This file is part of the Open Babel project.
    00007 For more information, see <http://openbabel.org/>
    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,
    00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00016 GNU General Public License for more details.
    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 // This macro is used in DLL builds. If it has not
    00047 // been set in babelconfig.h, define it as nothing.
    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       //The follow are OBMol options, which should not be in OBConversion.
    00088       //But here isn't entirely appropriate either, since one could have
    00089       //OBMol formats loaded but which don't derived from this class.
    00090       //However, this possibility is remote.
    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   static bool DoOutputOptions(OBBase* pOb, OBConversion* pConv);
    00122
    00124
    00125
    00126
    00127   static bool   DeferMolOutput(OBMol* pmol, OBConversion* pConv, OBFormat* pF);
    00129   static bool   OutputDeferredMols(OBConversion* pConv);
    00131   static bool   DeleteDeferredMols();
    00133   static OBMol* MakeCombinedMolecule(OBMol* pFirst, OBMol* pSecond);
    00135
    00136 #ifdef HAVE_SHARED_POINTER
    00137
    00138   static bool OutputMolsFromReaction
    00139     (OBReaction* pReact, OBConversion* pConv, OBFormat* pFormat);
    00140 #endif
    00141
    00142 #ifdef _MSC_VER
    00143   typedef stdext::hash_map<std::string, unsigned> NameIndexType;
    00144 #elif (__GNUC__ == 4 && __GNUC_MINOR__ >= 1 && !defined(__APPLE_CC__)) || defined (USE_BOOST)
    00145   typedef std::tr1::unordered_map<std::string, unsigned> NameIndexType;
    00146 #else
    00147   typedef std::map<std::string, unsigned> NameIndexType;
    00148 #endif
    00149
    00150   // documentation in obmolecformat.cpp
    00151   static bool   ReadNameIndex(NameIndexType& index, const std::string& datafilename,
    00152                   OBFormat* pInFormat);
    00153
    00155   const std::type_info& GetType()
    00156   {
    00157     return typeid(OBMol*);
    00158   }
    00159
    00160 private:
    00161
    00162   static bool OptionsRegistered;
    00163   static std::map<std::string, OBMol*> IMols;
    00164   static OBMol* _jmol;
    00165   static std::vector<OBMol> MolArray;
    00166   static bool StoredMolsReady;
    00167   static OBDescriptor* _pDesc;
    00168
    00169 };
    00170
    00171 }
    00172 #endif //OB_MOLECULEFORMAT_H
    00173

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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

Documentation copyright © 1998-2007, the Open Babel Developers.
Open Babel is hosted by:
Generated on Mon Oct 25 2010 11:55:11 by 1.7.2.