Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
33#include "G4UIcommand.hh"
34#include "G4UIcommandTree.hh"
35#include "G4UIdirectory.hh"
36#include "G4UImanager.hh"
37#include "G4UIparsing.hh"
38#include "G4ios.hh"
39
40#include <sstream>
41#include <utility>
42
43// --------------------------------------------------------------------
45 G4bool commandsToBeBroadcasted)
46{
47 CreateDirectory(path, dsc, commandsToBeBroadcasted);
48}
49
50// --------------------------------------------------------------------
55
56// --------------------------------------------------------------------
61
62// --------------------------------------------------------------------
64
65// --------------------------------------------------------------------
67{
68 std::ostringstream os;
69 os << i;
70 return G4String(os.str());
71}
72
73// --------------------------------------------------------------------
75{
76 std::ostringstream os;
77 os << l;
78 return G4String(os.str());
79}
80
81// --------------------------------------------------------------------
83{
84 std::ostringstream os;
85 os << a;
86 return G4String(os.str());
87}
88
89// --------------------------------------------------------------------
91{
92 return b ? "true" : "0";
93}
94
95// --------------------------------------------------------------------
97{
98 return G4UIparsing::StoT<G4int>(str);
99}
100
101// --------------------------------------------------------------------
103{
104 return G4UIparsing::StoT<G4long>(str);
105}
106
107// --------------------------------------------------------------------
112
113// --------------------------------------------------------------------
115{
116 G4String v = G4StrUtil::to_upper_copy(std::move(str));
117 return (v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE");
118}
119
120// --------------------------------------------------------------------
122{
123 G4cerr << "Warning : Old style definition of G4UIcommand <" << newCommand->GetCommandPath()
124 << ">." << G4endl;
125}
126
127// --------------------------------------------------------------------
129 G4bool commandsToBeBroadcasted)
130{
132
133 G4String fullpath = path;
134 if (fullpath.back() != '/') {
135 fullpath.append("/");
136 }
137
138 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
139 if (tree != nullptr) {
140 baseDirName = tree->GetPathName();
141 }
142 else {
143 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
144 baseDirName = fullpath;
145 baseDir->SetGuidance(dsc.c_str());
146 }
147}
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:67
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
const G4String & GetCommandPath() const
void SetGuidance(const char *aGuidance)
G4UIcommandTree * GetTree() const
static G4UImanager * GetUIpointer()
G4String ItoS(G4int i)
virtual G4String GetCurrentValue(G4UIcommand *command)
G4String BtoS(G4bool b)
G4String baseDirName
virtual ~G4UImessenger()
G4String LtoS(G4long l)
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)
T StoT(const G4String &s)