Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4UImessenger.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4UImessenger
27//
28// Author: Makoto Asai, 1998
29// --------------------------------------------------------------------
30
31#include "G4UImessenger.hh"
32#include "G4UImanager.hh"
33#include "G4UIcommand.hh"
34#include "G4UIdirectory.hh"
35#include "G4UIcommandTree.hh"
36#include "G4ios.hh"
37#include <sstream>
38#include <utility>
39
40// --------------------------------------------------------------------
42 G4bool commandsToBeBroadcasted)
43{
44 CreateDirectory(path, dsc, commandsToBeBroadcasted);
45}
46
47// --------------------------------------------------------------------
49{
50 delete baseDir;
51}
52
53// --------------------------------------------------------------------
55{
56 G4String nullString;
57 return nullString;
58}
59
60// --------------------------------------------------------------------
62{
63}
64
65// --------------------------------------------------------------------
67{
68 return this == &messenger;
69}
70
71// --------------------------------------------------------------------
73{
74 return this != &messenger;
75}
76
77// --------------------------------------------------------------------
79{
80 std::ostringstream os;
81 os << i;
82 return G4String(os.str());
83}
84
85// --------------------------------------------------------------------
87{
88 std::ostringstream os;
89 os << a;
90 return G4String(os.str());
91}
92
93// --------------------------------------------------------------------
95{
96 G4String vl = "0";
97 if(b)
98 {
99 vl = "true";
100 }
101 return vl;
102}
103
104// --------------------------------------------------------------------
106{
107 G4int vl;
108 const char* t = str;
109 std::istringstream is(t);
110 is >> vl;
111 return vl;
112}
113
114// --------------------------------------------------------------------
116{
117 G4long vl;
118 const char* t = str;
119 std::istringstream is(t);
120 is >> vl;
121 return vl;
122}
123
124// --------------------------------------------------------------------
126{
127 G4double vl;
128 const char* t = str;
129 std::istringstream is(t);
130 is >> vl;
131 return vl;
132}
133
134// --------------------------------------------------------------------
136{
137 G4String v = G4StrUtil::to_upper_copy(std::move(str));
138 G4bool vl = false;
139 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
140 {
141 vl = true;
142 }
143 return vl;
144}
145
146// --------------------------------------------------------------------
148{
149 G4cerr << "Warning : Old style definition of G4UIcommand <"
150 << newCommand->GetCommandPath() << ">." << G4endl;
151}
152
153// --------------------------------------------------------------------
155 G4bool commandsToBeBroadcasted)
156{
158
159 G4String fullpath = path;
160 if(fullpath.back() != '/')
161 {
162 fullpath.append("/");
163 }
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
double G4double
Definition: G4Types.hh:83
long G4long
Definition: G4Types.hh:87
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:137
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:157
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4bool operator!=(const G4UImessenger &messenger) const
G4String ItoS(G4int i)
virtual G4String GetCurrentValue(G4UIcommand *command)
G4String BtoS(G4bool b)
G4String baseDirName
virtual ~G4UImessenger()
G4bool operator==(const G4UImessenger &messenger) const
G4UImessenger()=default
G4double StoD(const G4String &s)
void AddUIcommand(G4UIcommand *newCommand)
G4String DtoS(G4double a)
G4long StoL(const G4String &s)
void CreateDirectory(const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIdirectory * baseDir
G4bool StoB(G4String s)
G4int StoI(const G4String &s)
G4String to_upper_copy(G4String str)
Return uppercase copy of string.