BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
atom.h
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef ATOM_H
20#define ATOM_H
21
22#include <iomanip>
23#include <iostream>
24#include <string>
25
26#include "published.h"
27
28namespace GMAD
29{
36 struct Atom : public Published<Atom>{
38 std::string name;
39
40 double A;
41 double Z;
42 std::string symbol;
43
45 Atom();
47 void clear();
49 void print()const;
51 template <typename T>
52 void set_value(std::string property, T value);
53
54 private:
56 void PublishMembers();
57 };
58
59 template <typename T>
60 void Atom::set_value(std::string property, T value)
61 {
62#ifdef BDSDEBUG
63 std::cout << "parser> Setting value " << std::setw(25) << std::left << property << value << std::endl;
64#endif
65 // member method can throw runtime_error, catch and exit gracefully
66 try
67 {set(this,property,value);}
68 catch(const std::runtime_error&)
69 {
70 std::cerr << "Error: parser> unknown atom option \"" << property << "\" with value \"" << value << "\"" << std::endl;
71 exit(1);
72 }
73 }
74}
75
76#endif
Class that provides introspection to its members.
Definition: published.h:47
void set(Atom *instance, const std::string &name, double value)
Definition: published.h:99
Parser namespace for GMAD language. Combination of Geant4 and MAD.
Atom class.
Definition: atom.h:36
double A
g*mol^-1
Definition: atom.h:40
void print() const
printout
Definition: atom.cc:45
void clear()
reset
Definition: atom.cc:29
Atom()
constructor
Definition: atom.cc:23
void set_value(std::string property, T value)
set methods by property name and value
Definition: atom.h:60
std::string name
name
Definition: atom.h:38
void PublishMembers()
publish members so these can be looked up from parser
Definition: atom.cc:37