ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4UImessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4UImessenger.cc
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 //
27 //
28 
29 #include "G4UImessenger.hh"
30 #include "G4UImanager.hh"
31 #include "G4UIcommand.hh"
32 #include "G4UIdirectory.hh"
33 #include "G4UIcommandTree.hh"
34 #include "G4ios.hh"
35 #include <sstream>
36 
38  : baseDir(NULL), baseDirName(""), commandsShouldBeInMaster(false)
39 {
40 }
41 
43  G4bool commandsToBeBroadcasted)
44  : baseDir(NULL), baseDirName(""), commandsShouldBeInMaster(false)
45 {
46  CreateDirectory(path, dsc, commandsToBeBroadcasted);
47 }
48 
50 {
51  if(baseDir) delete baseDir;
52 }
53 
55 {
56  G4String nullString;
57  return nullString;
58 }
59 
61 { ; }
62 
64  return this == &messenger;
65 }
66 
68 {
69  std::ostringstream os;
70  os << i;
71  return G4String(os.str());
72 }
73 
75 {
76  std::ostringstream os;
77  os << a;
78  return G4String(os.str());
79 }
80 
82 {
83  G4String vl = "0";
84  if(b) vl = "true";
85  return vl;
86 }
87 
89 {
90  G4int vl;
91  const char* t = str;
92  std::istringstream is(t);
93  is >> vl;
94  return vl;
95 }
96 
98 {
99  G4long vl;
100  const char* t = str;
101  std::istringstream is(t);
102  is >> vl;
103  return vl;
104 }
105 
107 {
108  G4double vl;
109  const char* t = str;
110  std::istringstream is(t);
111  is >> vl;
112  return vl;
113 }
114 
116 {
117  G4String v = str;
118  v.toUpper();
119  G4bool vl = false;
120  if( v=="Y" || v=="YES" || v=="1" || v=="T" || v=="TRUE" )
121  { vl = true; }
122  return vl;
123 }
124 
125 
127 {
128  G4cerr << "Warning : Old style definition of G4UIcommand <"
129  << newCommand->GetCommandPath() << ">." << G4endl;
130 }
131 
132 void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc,
133  G4bool commandsToBeBroadcasted)
134 {
136 
137  G4String fullpath = path;
138  if(fullpath(fullpath.length()-1) != '/') fullpath.append("/");
139 
140  G4UIcommandTree* tree= ui-> GetTree()-> FindCommandTree(fullpath.c_str());
141  if (tree) {
142  baseDirName = tree-> GetPathName();
143  } else {
144  baseDir = new G4UIdirectory(fullpath.c_str(),commandsToBeBroadcasted);
145  baseDirName = fullpath;
146  baseDir-> SetGuidance(dsc.c_str());
147  }
148 }