Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_base.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include "PoPI.hpp"
11
12namespace PoPI {
13
14/*! \class Base
15 * This class is the base class for all **Particle** and **SymbolBase** instances.
16 */
17
18/* *********************************************************************************************************//**
19 * @param a_id [in] The **PoPs** id for *this*.
20 * @param a_class [in] The **PoPI** class for *this*.
21 ***********************************************************************************************************/
22
23Base::Base( std::string const &a_id, Particle_class a_class ) :
24 m_id( a_id ),
25 m_class( a_class ),
26 m_index( SIZE_MAX ),
27 m_intid( -1 ) {
28
29}
30
31/* *********************************************************************************************************//**
32 * Constructor that parses an **HAPI** instance.
33 *
34 * @param a_node [in] The **HAPI::Node** to be parsed.
35 * @param a_label [in] This is either *id* or *symbol*. That is, it is the name of the attribute in *a_node* whose value represents *this* *m_id* member.
36 * @param a_class [in] The **PoPI** class for *this*.
37 ***********************************************************************************************************/
38
39Base::Base( HAPI::Node const &a_node, std::string const &a_label, Particle_class a_class ) :
40 m_id( a_node.attribute( a_label.c_str( ) ).value( ) ),
41 m_class( a_class ),
42 m_index( SIZE_MAX ),
43 m_intid( -1 ) {
44
45}
46
47/* *********************************************************************************************************//**
48 ***********************************************************************************************************/
49
51
52}
53
54/*! \class IDBase
55 * This class is the base class for all **Particle** instances.
56 */
57
58/* *********************************************************************************************************//**
59 * @param a_id [in] The **PoPs** id for *this*.
60 * @param a_class [in] The **PoPI** class for *this*.
61 ***********************************************************************************************************/
62
63IDBase::IDBase( std::string const &a_id, Particle_class a_class ) :
64 Base( a_id, a_class ) {
65
66}
67
68/* *********************************************************************************************************//**
69 * Constructor that parses an **HAPI** instance.
70 *
71 * @param a_node [in] The **HAPI::Node** to be parsed.
72 * @param a_class [in] The **PoPI** class for *this*.
73 ***********************************************************************************************************/
74
75IDBase::IDBase( HAPI::Node const &a_node, Particle_class a_class ) :
76 Base( a_node, PoPI_idChars, a_class ) {
77
78}
79
80/* *********************************************************************************************************//**
81 ***********************************************************************************************************/
82
84
85}
86
87/* *********************************************************************************************************//**
88 * This method adds *this* to the *m_list* member of *a_DB*.
89 *
90 * @param a_DB [in] The **PoPI::Database** instance to add *this* to.
91 *
92 * @return The index assigned to *this* by *a_DB*.
93 ***********************************************************************************************************/
94
95std::size_t IDBase::addToDatabase( Database *a_DB ) {
96
97 a_DB->add( this );
98 return( index( ) );
99}
100
101/*! \class SymbolBase
102 * This class is the base class for all **SymbolBase** instances.
103 */
104
105/* *********************************************************************************************************//**
106 * @param a_node [in] The **HAPI::Node** to be parsed.
107 * @param a_class [in] The **PoPI** class for *this*.
108 ***********************************************************************************************************/
109
111 Base( a_node, PoPI_symbolChars, a_class ) {
112
113}
114
115/* *********************************************************************************************************//**
116 ***********************************************************************************************************/
117
121
122/* *********************************************************************************************************//**
123 * This method adds *this* to the *m_symbolList* member of *a_DB*.
124 *
125 * @param a_DB [in] The **PoPI::Database** instance to add *this* to.
126 *
127 * @return The index assigned to *this* by *a_DB*.
128 ***********************************************************************************************************/
129
130std::size_t SymbolBase::addToSymbols( Database *a_DB ) {
131
132 a_DB->addSymbol( this );
133 return( index( ) );
134}
135
136}
#define PoPI_symbolChars
Definition PoPI.hpp:40
#define PoPI_idChars
Definition PoPI.hpp:39
Base(std::string const &a_id, Particle_class a_class)
Definition PoPI_base.cc:23
std::size_t index(void) const
Definition PoPI.hpp:653
virtual ~Base()
Definition PoPI_base.cc:50
std::size_t addSymbol(SymbolBase *a_item)
std::size_t add(Base *a_item)
virtual ~IDBase()
Definition PoPI_base.cc:83
std::size_t addToDatabase(Database *a_DB)
Definition PoPI_base.cc:95
IDBase(std::string const &a_id, Particle_class a_class)
Definition PoPI_base.cc:63
SymbolBase(HAPI::Node const &a_node, Particle_class a_class)
Definition PoPI_base.cc:110
std::size_t addToSymbols(Database *a_DB)
Definition PoPI_base.cc:130
Definition PoPI.hpp:28
Particle_class
Definition PoPI.hpp:58