• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files

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.sourceforge.net/>
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 #include <openbabel/mol.h>
00027 #include <openbabel/babelconfig.h>
00028 #include <openbabel/obconversion.h>
00029 #include <typeinfo>
00030 
00031 namespace OpenBabel {
00032 
00033 // This macro is used in DLL builds. If it has not
00034 // been set in babelconfig.h, define it as nothing.
00035 #ifndef OBCOMMON
00036   #define OBCOMMON
00037 #endif
00038 
00052 class OBCOMMON OBMoleculeFormat : public OBFormat
00053 {
00054 private:
00055   static bool OptionsRegistered;
00056   static std::map<std::string, OBMol*> IMols;
00057   static OBMol* _jmol; 
00058   static std::vector<OBMol> MolArray; 
00059   static bool StoredMolsReady; 
00060 
00061 public:
00062 
00063   OBMoleculeFormat()
00064   {
00065     if(!OptionsRegistered)
00066     {
00067       OptionsRegistered=true;
00068       OBConversion::RegisterOptionParam("b", this, 0, OBConversion::INOPTIONS);
00069       OBConversion::RegisterOptionParam("s", this, 0, OBConversion::INOPTIONS);
00070       OBConversion::RegisterOptionParam("title", this, 1,OBConversion::GENOPTIONS);
00071       OBConversion::RegisterOptionParam("addtotitle", this, 1,OBConversion::GENOPTIONS);
00072       OBConversion::RegisterOptionParam("property", this, 2, OBConversion::GENOPTIONS);
00073       OBConversion::RegisterOptionParam("C",        this, 0,OBConversion::GENOPTIONS);
00074       OBConversion::RegisterOptionParam("j",        this, 0,OBConversion::GENOPTIONS);
00075       OBConversion::RegisterOptionParam("join",     this, 0,OBConversion::GENOPTIONS);
00076       OBConversion::RegisterOptionParam("separate", this, 0,OBConversion::GENOPTIONS);
00077 
00078       //The follow are OBMol options, which should not be in OBConversion.
00079       //But here isn't entirely appropriate either, since one could have
00080       //OBMol formats loaded but which don't derived from this class.
00081       //However, this possibility is remote.
00082       OBConversion::RegisterOptionParam("s", NULL, 1,OBConversion::GENOPTIONS);
00083       OBConversion::RegisterOptionParam("v", NULL, 1,OBConversion::GENOPTIONS);
00084       OBConversion::RegisterOptionParam("h", NULL, 0,OBConversion::GENOPTIONS);
00085       OBConversion::RegisterOptionParam("d", NULL, 0,OBConversion::GENOPTIONS);
00086       OBConversion::RegisterOptionParam("b", NULL, 0,OBConversion::GENOPTIONS);
00087       OBConversion::RegisterOptionParam("c", NULL, 0,OBConversion::GENOPTIONS);
00088       OBConversion::RegisterOptionParam("p", NULL, 0,OBConversion::GENOPTIONS); 
00089       OBConversion::RegisterOptionParam("t", NULL, 0,OBConversion::GENOPTIONS);
00090       OBConversion::RegisterOptionParam("k", NULL, 0,OBConversion::GENOPTIONS);
00091       OBConversion::RegisterOptionParam("filter", NULL, 1,OBConversion::GENOPTIONS);
00092       OBConversion::RegisterOptionParam("add", NULL, 1,OBConversion::GENOPTIONS);
00093       OBConversion::RegisterOptionParam("delete", NULL, 1,OBConversion::GENOPTIONS);
00094       OBConversion::RegisterOptionParam("append", NULL, 1,OBConversion::GENOPTIONS);
00095     }
00096   }
00097 
00099   static bool ReadChemObjectImpl(OBConversion* pConv, OBFormat*);
00101   static bool WriteChemObjectImpl(OBConversion* pConv, OBFormat*);
00102 
00104   virtual bool ReadChemObject(OBConversion* pConv)
00105   { return ReadChemObjectImpl(pConv, this);}
00106 
00108   virtual bool WriteChemObject(OBConversion* pConv)
00109   { return WriteChemObjectImpl(pConv, this);}
00110 
00112 
00113 
00114 
00115   static bool   DeferMolOutput(OBMol* pmol, OBConversion* pConv, OBFormat* pF);
00117   static bool   OutputDeferredMols(OBConversion* pConv);
00119   static bool   DeleteDeferredMols();
00121   static OBMol* MakeCombinedMolecule(OBMol* pFirst, OBMol* pSecond);
00123 
00124 #ifdef _MSC_VER
00125   typedef stdext::hash_map<std::string, unsigned> NameIndexType;
00126 #else
00127   typedef std::map<std::string, unsigned> NameIndexType;
00128 #endif
00129   
00130   // documentation in obmolecformat.cpp
00131   static bool   ReadNameIndex(NameIndexType& index, const std::string& datafilename,
00132                   OBFormat* pInFormat);
00133 
00135   const std::type_info& GetType()
00136   {
00137     return typeid(OBMol*);
00138   }
00140 
00141 };
00142 
00143 }
00144 #endif //OB_MOLECULEFORMAT_H
00145 

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

Documentation copyright © 1998-2007, the Open Babel Developers.
Open Babel is hosted by: SourceForge Logo
Generated on Thu Jul 3 14:30:34 2008 by doxygen 1.5.6.