The Gnome Chemistry Utils  0.14.0
element.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * Gnome Chemistry Utils
5  * element.h
6  *
7  * Copyright (C) 2002-2012 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCU_ELEMENT_H
26 #define GCU_ELEMENT_H
27 
28 #include <map>
29 #include <string>
30 #include <vector>
31 #include "chemistry.h"
32 #include "isotope.h"
33 #include "value.h"
34 #include "macros.h"
35 
40 #define GCU_ERROR (1 << (sizeof(int) - 1))
41 
47 namespace gcu
48 {
49 
50 class EltTable;
51 
60 class Element
61 {
62 friend class EltTable;
63 private:
70  Element (int Z, const char* Symbol);
74  virtual ~Element ();
75 
76 public:
81  static const char* Symbol (int Z);
89  static bool BestSide (int Z);
94  static int Z (const char* symbol);
99  static Element* GetElement (int Z);
104  static Element* GetElement (const char* symbol);
121  static bool GetRadius (GcuAtomicRadius* radius);
137  static bool GetElectronegativity (GcuElectronegativity* en);
145  static unsigned GetMaxBonds (int Z);
149  static void LoadRadii ();
153  static void LoadElectronicProps ();
157  static void LoadIsotopes ();
161  static void LoadBODR ();
165  static void LoadAllData ();
170  static void Init ();
171 
175  int GetZ () {return m_Z;}
179  const char* GetSymbol () {return m_Symbol;}
184  char GetDefaultValence () {return m_DefaultValence;}
190  unsigned GetMaxBonds () {return m_MaxBonds;}
196  bool GetBestSide () {return m_BestSide;}
201  double* GetDefaultColor () {return m_DefaultColor;}
205  const char* GetName () {return name.c_str();}
210  const GcuAtomicRadius** GetRadii ();
219  unsigned GetValenceElectrons () {return m_nve;}
224  unsigned GetTotalValenceElectrons () {return m_tve;}
229  unsigned GetMaxValenceElectrons () {return m_maxve;}
233  DimensionalValue const *GetWeight ();
240  IsotopicPattern *GetIsotopicPattern (unsigned natoms);
246  std::string const& GetElectronicConfiguration () {return ElecConfig;}
250  std::map<std::string, std::string> const& GetNames () {return names;}
256  GcuDimensionalValue const *GetIonizationEnergy (unsigned rank = 1);
263  GcuDimensionalValue const *GetElectronAffinity (unsigned rank = 1);
270  Value const *GetProperty (char const *property_name);
277  std::string &GetStringProperty (char const *property_name);
284  int GetIntegerProperty (char const *property_name);
285 
289  bool IsMetallic ();
290 
291 private:
292  unsigned char m_Z, m_nve, m_tve, m_maxve;
293  char m_Symbol[4];
294  DimensionalValue const *m_AtomicWeight;
295  char m_DefaultValence;
296  unsigned char m_MaxBonds;
297  bool m_BestSide, m_Metallic, m_MetallicCached;
298  double m_DefaultColor[3];
299  std::string name;
300  std::vector<GcuAtomicRadius*> m_radii;
301  std::vector<GcuElectronegativity*> m_en;
302  std::vector<Isotope*> m_isotopes;
303  std::vector<IsotopicPattern*> m_patterns;
304  std::vector<GcuDimensionalValue> m_ei;
305  std::vector<GcuDimensionalValue> m_ae;
306  std::map<std::string, std::string> names;
307  std::map<std::string, Value*> props;
308  std::map<std::string, std::string> sprops;
309  std::map<std::string, int> iprops;
310  std::string ElecConfig;
314 GCU_RO_PROP (bool, Stability)
315 };
316 
317 } // namespace gcu
318 
319 #endif // GCU_ELEMENT_H