Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

ElementDB.h (Maintainer: Andreas Bertsch)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Andreas Bertsch $
00025 // --------------------------------------------------------------------------
00026 //
00027 
00028 #ifndef OPENMS_CHEMISTRY_ELEMENTDB_H
00029 #define OPENMS_CHEMISTRY_ELEMENTDB_H
00030 
00031 #include <OpenMS/DATASTRUCTURES/String.h>
00032 #include <OpenMS/DATASTRUCTURES/HashMap.h>
00033 #include <OpenMS/CHEMISTRY/IsotopeDistribution.h>
00034 
00035 namespace OpenMS
00036 {
00037   class Element;
00038 
00053   class ElementDB
00054   {
00055     public:
00056   
00060 
00061       inline static const ElementDB* getInstance()
00062       {
00063         static ElementDB* db_ = 0;
00064         if (db_ == 0)
00065         {
00066           db_ = new ElementDB;
00067         }
00068         return db_;
00069       }
00070       
00072       const HashMap<String, const Element*>& getNames() const;
00073       
00075       const HashMap<String, const Element*>& getSymbols() const;
00076 
00078       const HashMap<UInt, const Element*>& getAtomicNumbers() const;
00079 
00084       const Element* getElement(const String& name) const;
00085 
00087       const Element* getElement(UInt atomic_number) const;
00089       
00093 
00094       bool hasElement(const String& name) const;
00095 
00097       bool hasElement(UInt atomic_number) const;
00099 
00100     protected:
00101   
00102       /*_ parses a Histogram given as a OpenMS String and return the distribution
00103        */
00104       IsotopeDistribution parseIsotopeDistribution_(const HashMap<UInt, double>& distribution) 
00105         throw(Exception::ParseError);
00106 
00107       /*_ read elements from a XML file, formated as a Param file.
00108        */
00109       void readFromFile_(const String& file_name) throw(Exception::FileNotFound, Exception::ParseError);
00110 
00111       /*_ resets all containers 
00112        */
00113       void clear_();
00114 
00115       HashMap<String, const Element*> names_;
00116 
00117       HashMap<String, const Element*> symbols_;
00118 
00119       HashMap<UInt, const Element*> atomic_numbers_;
00120 
00121     private:
00122 
00123       ElementDB();
00124 
00125       ElementDB(const ElementDB& db);
00126 
00127       ElementDB& operator = (const ElementDB& db);
00128 
00129       virtual ~ElementDB();
00130   };
00131 
00132 } // namespace OpenMS
00133 #endif
00134 

Generated Tue Apr 1 15:36:34 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1