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) 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 BDSMYSQLVARIABLE_H
20#define BDSMYSQLVARIABLE_H
21
22#include "globals.hh"
23#include <vector>
24
32{
33public:
34 BDSMySQLVariable(G4String aVarName, G4String aVarType);
35
36 void AddValue(G4double aVarValue);
37 void AddValue(G4String aVarValue);
38 void AddValue(G4int aVarValue);
39
41 inline G4String GetStrValue(G4int itemN) const {return itsStrVar[itemN];}
42 inline G4double GetDblValue(G4int itemN) const {return itsDblVar[itemN];}
43 inline G4int GetIntValue(G4int itemN) const {return itsIntVar[itemN];}
44 inline G4int GetNVariables() const {return itsNVariables;}
45 inline G4String GetVarType() const {return itsVarType;}
46 inline G4String GetName() const {return itsVarName;}
48
50 inline void SetStrValue(G4int itemN, G4String newValue) {itsStrVar[itemN] = newValue;}
51 inline void SetDblValue(G4int itemN, G4double newValue) {itsDblVar[itemN] = newValue;}
52 inline void SetIntValue(G4int itemN, G4int newValue) {itsIntVar[itemN] = newValue;}
54
55 void Print();
56
58
59private:
61
62 G4int itsNVariables;
63 G4String itsVarName;
64 G4String itsVarType;
65 std::vector<G4double> itsDblVar;
66 std::vector<G4String> itsStrVar;
67 std::vector<G4int> itsIntVar;
68};
69
70inline BDSMySQLVariable::BDSMySQLVariable(G4String aVarName, G4String aVarType)
71{
72 itsVarName=aVarName;
73 itsVarType=aVarType;
74 itsNVariables=0;
75}
76
77inline void BDSMySQLVariable::AddValue(G4double aVarValue)
78{
79 itsNVariables++;
80 // Check is to avoid unecessary confusion
81 if(itsVarType=="DOUBLE")
82 itsDblVar.push_back(aVarValue);
83}
84
85inline void BDSMySQLVariable::AddValue(G4int aVarValue)
86{
87 itsNVariables++;
88 // Check is to avoid unecessary confusion
89 if(itsVarType=="INTEGER")
90 itsIntVar.push_back(aVarValue);
91}
92
93inline void BDSMySQLVariable::AddValue(G4String aVarValue)
94{
95 itsNVariables++;
96 itsStrVar.push_back(aVarValue);
97}
98
99#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.