BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSMySQLVariable.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSMYSQLVARIABLE_H
19#define BDSMYSQLVARIABLE_H
20
21#include "globals.hh"
22#include <vector>
23
31{
32public:
33 BDSMySQLVariable(G4String aVarName, G4String aVarType);
34
35 void AddValue(G4double aVarValue);
36 void AddValue(G4String aVarValue);
37 void AddValue(G4int aVarValue);
38
40 inline G4String GetStrValue(G4int itemN) const {return itsStrVar[itemN];}
41 inline G4double GetDblValue(G4int itemN) const {return itsDblVar[itemN];}
42 inline G4int GetIntValue(G4int itemN) const {return itsIntVar[itemN];}
43 inline G4int GetNVariables() const {return itsNVariables;}
44 inline G4String GetVarType() const {return itsVarType;}
45 inline G4String GetName() const {return itsVarName;}
47
49 inline void SetStrValue(G4int itemN, G4String newValue) {itsStrVar[itemN] = newValue;}
50 inline void SetDblValue(G4int itemN, G4double newValue) {itsDblVar[itemN] = newValue;}
51 inline void SetIntValue(G4int itemN, G4int newValue) {itsIntVar[itemN] = newValue;}
53
54 void Print();
55
57
58private:
60
61 G4int itsNVariables;
62 G4String itsVarName;
63 G4String itsVarType;
64 std::vector<G4double> itsDblVar;
65 std::vector<G4String> itsStrVar;
66 std::vector<G4int> itsIntVar;
67};
68
69inline BDSMySQLVariable::BDSMySQLVariable(G4String aVarName, G4String aVarType)
70{
71 itsVarName=aVarName;
72 itsVarType=aVarType;
73 itsNVariables=0;
74}
75
76inline void BDSMySQLVariable::AddValue(G4double aVarValue)
77{
78 itsNVariables++;
79 // Check is to avoid unecessary confusion
80 if(itsVarType=="DOUBLE")
81 itsDblVar.push_back(aVarValue);
82}
83
84inline void BDSMySQLVariable::AddValue(G4int aVarValue)
85{
86 itsNVariables++;
87 // Check is to avoid unecessary confusion
88 if(itsVarType=="INTEGER")
89 itsIntVar.push_back(aVarValue);
90}
91
92inline void BDSMySQLVariable::AddValue(G4String aVarValue)
93{
94 itsNVariables++;
95 itsStrVar.push_back(aVarValue);
96}
97
98#endif
A variable representation for mysql loader.
G4int GetNVariables() const
Accessor.
G4String GetName() const
Accessor.
G4double GetDblValue(G4int itemN) const
Accessor.
void SetDblValue(G4int itemN, G4double newValue)
Setter.
G4String GetVarType() const
Accessor.
G4int GetIntValue(G4int itemN) const
Accessor.
void SetIntValue(G4int itemN, G4int newValue)
Setter.
G4String GetStrValue(G4int itemN) const
Accessor.
void SetStrValue(G4int itemN, G4String newValue)
Setter.