gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
ElementSet.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2017, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
35 #ifndef __ElementSet_h
36 #define __ElementSet_h
37 
38 
66 //******************************************************************************
67 // Include
68 //******************************************************************************
69 #include <iostream>
70 #include <map>
71 #include <string>
72 
73 #ifndef __gVirtualXRayConfig_h
75 #endif
76 
77 #ifndef __AtomicElement_h
79 #endif
80 
81 
82 //******************************************************************************
83 // namespace
84 //******************************************************************************
85 namespace gVirtualXRay {
86 
87 
88 //******************************************************************************
89 // Class declaration
90 //******************************************************************************
91 class ElementSet;
92 
93 
94 //******************************************************************************
95 // Function declarations
96 //******************************************************************************
97 
98 //---------------------------------------------------------------------------
100 /*
101 * @param anOutputSream: the output stream
102 * @param anElement: the element to output
103 * @return the output stream
104 */
105 //---------------------------------------------------------------------------
106 std::ostream & operator << (std::ostream& anOutputSream,
107  const gVirtualXRay::ElementSet& anElementSet);
108 
109 
110 //==============================================================================
115 //==============================================================================
117 //------------------------------------------------------------------------------
118 {
119 //******************************************************************************
120 public:
121  static ElementSet& getInstance();
122 
123 
124  //---------------------------------------------------------------------------
126  //---------------------------------------------------------------------------
127  ~ElementSet();
128 
129 
130  //---------------------------------------------------------------------------
132  /*
133  * @param aFileName: the name of the file to load
134  */
135  //---------------------------------------------------------------------------
136  void loadFromFile(const std::string& aFileName);
137 
138 
139  //--------------------------------------------------------------------------
141  //--------------------------------------------------------------------------
143 
144 
145  //---------------------------------------------------------------------------
147  /*
148  * @param anElement the element to add
149  */
150  //---------------------------------------------------------------------------
151  void addElement(const AtomicElement& anElement);
152 
153 
154  //---------------------------------------------------------------------------
156  /*
157  * @param anAtomicNumber: the atomic number (Z) of the element
158  * @return the element
159  */
160  //---------------------------------------------------------------------------
161  AtomicElement& getElement(unsigned short anAtomicNumber);
162 
163 
164  //---------------------------------------------------------------------------
166  /*
167  * @param anAtomicNumber: the atomic number (Z) of the element
168  * @return the element
169  */
170  //---------------------------------------------------------------------------
171  const AtomicElement& getElement(unsigned short anAtomicNumber) const;
172 
173 
174  //---------------------------------------------------------------------------
176  /*
177  * @param anAtomicNumber: the name of the element
178  * @return the element
179  */
180  //---------------------------------------------------------------------------
181  AtomicElement& getElement(const std::string& aName);
182 
183 
184  //---------------------------------------------------------------------------
186  /*
187  * @param anAtomicNumber: the name of the element
188  * @return the element
189  */
190  //---------------------------------------------------------------------------
191  const AtomicElement& getElement(const std::string& aName) const;
192 
193 
194  //---------------------------------------------------------------------------
196  /*
197  * @param anAtomicNumber: the atomic number (Z) of the element
198  * @return the molar mass of the element
199  */
200  //---------------------------------------------------------------------------
201  float getMolarMass(unsigned short anAtomicNumber) const;
202 
203 
204  //---------------------------------------------------------------------------
206  /*
207  * @param anAtomicNumber: the atomic number (Z) of the element
208  * @return the density of the element
209  */
210  //---------------------------------------------------------------------------
211  float getDensity(unsigned short anAtomicNumber) const;
212 
213 
214  //---------------------------------------------------------------------------
216  /*
217  * @return the number of elements in the set
218  */
219  //---------------------------------------------------------------------------
220  unsigned int getElementSetSize() const;
221 
222 
223  //---------------------------------------------------------------------------
225  /*
226  * @return the begin const_iterator of m_element_set
227  */
228  //---------------------------------------------------------------------------
229  std::map<unsigned short, AtomicElement>::const_iterator begin() const;
230 
231 
232  //---------------------------------------------------------------------------
234  /*
235  * @return the end const_iterator of m_element_set
236  */
237  //---------------------------------------------------------------------------
238  std::map<unsigned short, AtomicElement>::const_iterator end() const;
239 
240 
241 //*******************************************************************************
242 private:
243  //---------------------------------------------------------------------------
245  //---------------------------------------------------------------------------
246  ElementSet();
247 
248 
249  //--------------------------------------------------------------------------
251  //--------------------------------------------------------------------------
252  ElementSet(const ElementSet&);
253 
254 
255  //--------------------------------------------------------------------------
257  //--------------------------------------------------------------------------
258  ElementSet& operator=(const ElementSet&);
259 
260 
261  //---------------------------------------------------------------------------
263  //---------------------------------------------------------------------------
264  void clearMemory();
265 
266 
267  //---------------------------------------------------------------------------
269  //---------------------------------------------------------------------------
270  void clearDynamicallyMemory();
271 
272 
273  //---------------------------------------------------------------------------
275  //---------------------------------------------------------------------------
276  std::map<unsigned short, AtomicElement> m_element_set;
277 };
278 
279 
280 } // namespace gVirtualXRay
281 
282 
283 //******************************************************************************
284 #include "ElementSet.inl"
285 
286 
287 #endif // __ElementSet_h
void loadElementSetFromMemory()
Load the table of elements.
unsigned int getElementSetSize() const
Accessor on the number of elements in the set.
Definition: ElementSet.inl:94
std::map< unsigned short, AtomicElement >::const_iterator end() const
Accessor on the end const_iterator of m_element_set.
void addElement(const AtomicElement &anElement)
Add an element to the list.
AtomicElement & getElement(unsigned short anAtomicNumber)
Get a given element.
ElementSet is a class to manage a table of elements in material.
Definition: ElementSet.h:116
std::map< unsigned short, AtomicElement >::const_iterator begin() const
Accessor on the begin const_iterator of m_element_set.
~ElementSet()
Destructor.
Definition: ElementSet.inl:78
Class to manage a table of elements in material.
static ElementSet & getInstance()
void loadFromFile(const std::string &aFileName)
Load a file containing elements.
AtomicElement is a class to manage elements in material.
std::ostream & operator<<(std::ostream &anOutputSream, const gVirtualXRay::AtomicElement &anElement)
operator <<
Class to manage elements in material.
float getMolarMass(unsigned short anAtomicNumber) const
Accessor on the molar mass of the element.
float getDensity(unsigned short anAtomicNumber) const
Accessor on the density of the element.