Geant4-11
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
39// --------------------------------------------------------------------
41{
42}
43
44// --------------------------------------------------------------------
46 G4bool commandsToBeBroadcasted)
47{
48 CreateDirectory(path, dsc, commandsToBeBroadcasted);
49}
50
51// --------------------------------------------------------------------
53{
54 delete baseDir;
55}
56
57// --------------------------------------------------------------------
59{
60 G4String nullString;
61 return nullString;
62}
63
64// --------------------------------------------------------------------
66{
67}
68
69// --------------------------------------------------------------------
71{
72 return this == &messenger;
73}
74
75// --------------------------------------------------------------------
77{
78 return this != &messenger;
79}
80
81// --------------------------------------------------------------------
83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}
88
89// --------------------------------------------------------------------
91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}
96
97// --------------------------------------------------------------------
99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}
105
106// --------------------------------------------------------------------
108{
109 G4int vl;
110 const char* t = str;
111 std::istringstream is(t);
112 is >> vl;
113 return vl;
114}
115
116// --------------------------------------------------------------------
118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
125
126// --------------------------------------------------------------------
128{
129 G4double vl;
130 const char* t = str;
131 std::istringstream is(t);
132 is >> vl;
133 return vl;
134}
135
136// --------------------------------------------------------------------
138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
147
148// --------------------------------------------------------------------
150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
154
155// --------------------------------------------------------------------
157 G4bool commandsToBeBroadcasted)
158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
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:136
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4int StoI(G4String s)
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
G4long StoL(G4String s)
void AddUIcommand(G4UIcommand *newCommand)
G4String DtoS(G4double a)
void CreateDirectory(const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
G4double StoD(G4String s)
G4UIdirectory * baseDir
G4bool StoB(G4String s)
G4String to_upper_copy(G4String str)
Return uppercase copy of string.