Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Heed::AtomDef Class Reference

#include <AtomDef.h>

+ Inheritance diagram for Heed::AtomDef:

Public Member Functions

 AtomDef ()
 Default constructor.
 
 AtomDef (const std::string &fnameh, const std::string &fnotationh, int fZh, double fAh)
 Constructor.
 
 ~AtomDef ()
 Destructor.
 
const std::string & name () const
 
const std::string & notation () const
 
int Z () const
 
double A () const
 
void verify ()
 Check that there is no atom with the same name in the container.
 
void print (std::ostream &file, int l=0) const
 
virtual AtomDefcopy () const
 
- Public Member Functions inherited from Heed::RegPassivePtr
 RegPassivePtr (void)
 
 RegPassivePtr (char fs_ban_del, char fs_ban_sub, char fs_ban_cop=0)
 
 RegPassivePtr (const RegPassivePtr &f)
 
RegPassivePtroperator= (const RegPassivePtr &f)
 
CountPP_ns::CountPassivePtrbook (void) const
 
void clear_pointers (void) const
 
virtual RegPassivePtrcopy () const
 
virtual ~RegPassivePtr ()
 
virtual void print (std::ostream &file, int l=1) const
 
void set_s_ban_del (char fs_ban_del)
 
char get_s_ban_del (void) const
 
void set_s_ban_sub (char fs_ban_sub)
 
char get_s_ban_sub (void) const
 
void set_s_ban_cop (char fs_ban_cop)
 
char get_s_ban_cop (void) const
 
void set_s_allow_del_at_zero_count (char fs_allow_del_at_zero_count)
 
char get_s_allow_del_at_zero_count (void) const
 
long get_total_number_of_references (void) const
 

Static Public Member Functions

static void printall (std::ostream &file)
 Print all registered atoms.
 
static std::list< AtomDef * > & get_logbook ()
 
static const std::list< AtomDef * > & get_const_logbook ()
 
static AtomDefget_AtomDef (const std::string &fnotation)
 
static double get_A (int fZ)
 
static AtomDefget_AtomDef (int fZ)
 
- Static Public Member Functions inherited from Heed::RegPassivePtr
static void set_s_ban_del_ignore (char fs_ban_del_ignore)
 
static char get_s_ban_del_ignore (void)
 
static void set_s_print_adr_cpp (char fs_print_adr_cpp)
 
static char get_s_print_adr_cpp (void)
 

Detailed Description

Definition of atoms. Only the basic information: name, notation, atomic weight and charge.

The principle of definitions of atoms is dictionary or a database: the atoms are not repeated, each atom is presented in the total system no more than one time. The system knows each atom presented in it. The atom characteristics can be obtained by literal notation. The system declines the secondary initialization. The copying is not declined. When the user program wants to refer to atom, it has to use either char* (string) notation, or pointer (or reference) to one of these objects. As usually, in the case of pointers I recommend to use protected pointers to external objects PassivePtr. The user pogram can initialize the new atoms. The standard atoms are initiated in files GasLib.h and GasLib.c.

In principle I am going to initiate all atoms from Mendeleev's table, but I haven't finished yet. Only its first half is filled at the moment.

The atoms are registered in the static element of class AtomDef private: static std::list<AtomDef*> logbook; The can be obtained by notations by: public: static const std::list<AtomDef*>& get_AtomDefLogbook(); static AtomDef* get_AtomDef(const std::string& fnotation); returns the address of atom with this name if it is registered in system, or NULL otherwise.

In these files and in the other components of the matter package the principles are similar. This is the principle of database, the principle of the strict protection of internal data (variables marked by suffix 'h') and granting access though the functions which have similar names without this suffix 'h'.

1998-2004, I. Smirnov.

Definition at line 51 of file AtomDef.h.

Constructor & Destructor Documentation

◆ AtomDef() [1/2]

Heed::AtomDef::AtomDef ( )

Default constructor.

Definition at line 26 of file AtomDef.cpp.

26 : nameh("none"), notationh("none") {
27 AtomDef::get_logbook().push_back(this);
28}
static std::list< AtomDef * > & get_logbook()
Definition: AtomDef.cpp:91

Referenced by copy().

◆ AtomDef() [2/2]

Heed::AtomDef::AtomDef ( const std::string &  fnameh,
const std::string &  fnotationh,
int  fZh,
double  fAh 
)

Constructor.

Definition at line 30 of file AtomDef.cpp.

32 : nameh(fnameh), notationh(fnotationh), Zh(fZh), Ah(fAh) {
33 mfunname("AtomDef::AtomDef(...)");
34 check_econd21(fZh, < 1 ||, > max_poss_atom_z, mcerr);
35 verify();
36 AtomDef::get_logbook().push_back(this);
37}
#define check_econd21(a, sign1_b1_sign0, sign2_b2, stream)
Definition: FunNameStack.h:191
#define mfunname(string)
Definition: FunNameStack.h:45
void verify()
Check that there is no atom with the same name in the container.
Definition: AtomDef.cpp:67
#define mcerr
Definition: prstream.h:128

◆ ~AtomDef()

Heed::AtomDef::~AtomDef ( )

Destructor.

Definition at line 110 of file AtomDef.cpp.

110{ AtomDef::get_logbook().remove(this); }

Member Function Documentation

◆ A()

double Heed::AtomDef::A ( ) const
inline

Definition at line 72 of file AtomDef.h.

72{ return Ah; }

Referenced by Heed::operator<<().

◆ copy()

virtual AtomDef * Heed::AtomDef::copy ( ) const
inlinevirtual

Reimplemented from Heed::RegPassivePtr.

Definition at line 94 of file AtomDef.h.

94{ return new AtomDef(*this); }
AtomDef()
Default constructor.
Definition: AtomDef.cpp:26

◆ get_A()

double Heed::AtomDef::get_A ( int  fZ)
static

Return the atomic number corresponding to a given Z. If the atom is not registered, the current version terminates the program through spexit(). Be careful!

Definition at line 39 of file AtomDef.cpp.

39 {
40 mfunnamep("double AtomDef::get_A(int fZ)");
41 const std::list<AtomDef*>& logbook = AtomDef::get_logbook();
42 std::list<AtomDef*>::const_iterator it;
43 std::list<AtomDef*>::const_iterator end = logbook.end();
44 for (it = logbook.begin(); it != end; ++it) {
45 if ((*it)->Z() == fZ) return (*it)->A();
46 }
47 funnw.ehdr(mcerr);
48 mcerr << "Atom is not found, Z=" << fZ << '\n';
50 return 0.0;
51}
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256

◆ get_AtomDef() [1/2]

AtomDef * Heed::AtomDef::get_AtomDef ( const std::string &  fnotation)
static

Return the address of atom with this name if it is registered in system, or NULL otherwise

Definition at line 100 of file AtomDef.cpp.

100 {
101 const std::list<AtomDef*>& logbook = AtomDef::get_logbook();
102 std::list<AtomDef*>::const_iterator it;
103 std::list<AtomDef*>::const_iterator end = logbook.end();
104 for (it = logbook.begin(); it != end; ++it) {
105 if ((*it)->notation() == fnotation) return *it;
106 }
107 return NULL;
108}

Referenced by Heed::AtomMixDef::AtomMixDef().

◆ get_AtomDef() [2/2]

AtomDef * Heed::AtomDef::get_AtomDef ( int  fZ)
static

Return the address of atom corresponding to a given Z. If the atom is not registered, the current version terminates the program through spexit(). Be careful!

Definition at line 53 of file AtomDef.cpp.

53 {
54 mfunnamep("AtomDef* AtomDef::get_AtomDef(int fZ)");
55 const std::list<AtomDef*>& logbook = AtomDef::get_logbook();
56 std::list<AtomDef*>::const_iterator it;
57 std::list<AtomDef*>::const_iterator end = logbook.end();
58 for (it = logbook.begin(); it != end; ++it) {
59 if ((*it)->Z() == fZ) return *it;
60 }
61 funnw.ehdr(mcerr);
62 mcerr << "Atom is not found, Z=" << fZ << '\n';
64 return NULL;
65}

◆ get_const_logbook()

const std::list< AtomDef * > & Heed::AtomDef::get_const_logbook ( )
static

Definition at line 96 of file AtomDef.cpp.

96 {
97 return AtomDef::get_logbook();
98}

◆ get_logbook()

std::list< AtomDef * > & Heed::AtomDef::get_logbook ( )
static

Initialize the logbook at the first request and keep it as internal static variable.

Definition at line 91 of file AtomDef.cpp.

91 {
92 static std::list<AtomDef*> logbook;
93 return logbook;
94}

Referenced by AtomDef(), get_A(), get_AtomDef(), get_const_logbook(), printall(), verify(), and ~AtomDef().

◆ name()

const std::string & Heed::AtomDef::name ( ) const
inline

Definition at line 69 of file AtomDef.h.

69{ return nameh; }

Referenced by Heed::operator<<().

◆ notation()

const std::string & Heed::AtomDef::notation ( ) const
inline

Definition at line 70 of file AtomDef.h.

70{ return notationh; }

Referenced by Heed::operator<<().

◆ print()

void Heed::AtomDef::print ( std::ostream &  file,
int  l = 0 
) const
virtual

Reimplemented from Heed::RegPassivePtr.

Definition at line 14 of file AtomDef.cpp.

14 {
15 if (l > 0) file << (*this);
16}

◆ printall()

void Heed::AtomDef::printall ( std::ostream &  file)
static

Print all registered atoms.

Definition at line 18 of file AtomDef.cpp.

18 {
19 Ifile << "AtomDef::printall:\n";
20 const std::list<AtomDef*>& logbook = AtomDef::get_logbook();
21 std::list<AtomDef*>::const_iterator it;
22 std::list<AtomDef*>::const_iterator end = logbook.end();
23 for (it = logbook.begin(); it != end; ++it) file << (*it);
24}
#define Ifile
Definition: prstream.h:196

◆ verify()

void Heed::AtomDef::verify ( )

Check that there is no atom with the same name in the container.

Definition at line 67 of file AtomDef.cpp.

67 {
68 mfunnamep("void AtomDef::verify()");
69 if (nameh == "none" && notationh == "none") return;
70 const std::list<AtomDef*>& logbook = AtomDef::get_logbook();
71 std::list<AtomDef*>::const_iterator it;
72 std::list<AtomDef*>::const_iterator end = logbook.end();
73 for (it = logbook.begin(); it != end; ++it) {
74 if ((*it)->nameh == nameh || (*it)->notationh == notationh) {
75 funnw.ehdr(mcerr);
76 mcerr << "cannot initialize two atoms with the same name or notation\n";
77 mcerr << "name=" << nameh << " notation=" << notationh << '\n';
79 }
80 }
81}

Referenced by AtomDef().

◆ Z()

int Heed::AtomDef::Z ( ) const
inline

Definition at line 71 of file AtomDef.h.

71{ return Zh; }

Referenced by Heed::operator<<().


The documentation for this class was generated from the following files: