The Gnome Chemistry Utils  0.12.13
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-2010 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 2 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 <glib.h>
29 #include <map>
30 #include <string>
31 #include <vector>
32 #include "chemistry.h"
33 #include "isotope.h"
34 #include "value.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 gchar* Symbol (gint Z);
89  static bool BestSide (gint Z);
94  static gint Z (const gchar* symbol);
99  static Element* GetElement (gint Z);
104  static Element* GetElement (const gchar* symbol);
121  static bool GetRadius (GcuAtomicRadius* radius);
137  static bool GetElectronegativity (GcuElectronegativity* en);
145  static unsigned GetMaxBonds (gint Z);
149  static void LoadRadii ();
153  static void LoadElectronicProps ();
157  static void LoadIsotopes ();
161  static void LoadBODR ();
165  static void LoadAllData ();
166 
170  int GetZ () {return m_Z;}
174  const char* GetSymbol () {return m_Symbol;}
179  char GetDefaultValence () {return m_DefaultValence;}
185  unsigned GetMaxBonds () {return m_MaxBonds;}
191  bool GetBestSide () {return m_BestSide;}
196  double* GetDefaultColor () {return m_DefaultColor;}
200  const char* GetName () {return name.c_str();}
205  const GcuAtomicRadius** GetRadii ();
214  unsigned GetValenceElectrons () {return m_nve;}
219  unsigned GetTotalValenceElectrons () {return m_tve;}
224  unsigned GetMaxValenceElectrons () {return m_maxve;}
228  DimensionalValue const *GetWeight ();
235  IsotopicPattern *GetIsotopicPattern (unsigned natoms);
241  std::string const& GetElectronicConfiguration () {return ElecConfig;}
245  std::map<std::string, std::string> const& GetNames () {return names;}
251  GcuDimensionalValue const *GetIonizationEnergy (unsigned rank = 1);
258  GcuDimensionalValue const *GetElectronAffinity (unsigned rank = 1);
265  Value const *GetProperty (char const *property_name);
272  std::string &GetStringProperty (char const *property_name);
279  int GetIntegerProperty (char const *property_name);
280 
284  bool IsMetallic ();
285 
286 private:
287  unsigned char m_Z, m_nve, m_tve, m_maxve;
288  char m_Symbol[4];
289  DimensionalValue const *m_AtomicWeight;
290  char m_DefaultValence;
291  unsigned char m_MaxBonds;
292  bool m_BestSide, m_Metallic, m_MetallicCached;
293  double m_DefaultColor[3];
294  std::string name;
295  std::vector<GcuAtomicRadius*> m_radii;
296  std::vector<GcuElectronegativity*> m_en;
297  std::vector<Isotope*> m_isotopes;
298  std::vector<IsotopicPattern*> m_patterns;
299  std::vector<GcuDimensionalValue> m_ei;
300  std::vector<GcuDimensionalValue> m_ae;
301  std::map<std::string, std::string> names;
302  std::map<std::string, Value*> props;
303  std::map<std::string, std::string> sprops;
304  std::map<std::string, int> iprops;
305  std::string ElecConfig;
306 };
307 
308 } // namespace gcu
309 
310 #endif // GCU_ELEMENT_H