Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 //
27 // $Id$
28 //
29 
30 #include "G4UImessenger.hh"
31 #include "G4UImanager.hh"
32 #include "G4UIcommand.hh"
33 #include "G4UIdirectory.hh"
34 #include "G4UIcommandTree.hh"
35 #include "G4ios.hh"
36 #include <sstream>
37 
39  : baseDir(NULL), baseDirName("")
40 {
41 }
42 
44  : baseDir(NULL), baseDirName("")
45 {
46  CreateDirectory(path, dsc);
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  G4double vl;
100  const char* t = str;
101  std::istringstream is(t);
102  is >> vl;
103  return vl;
104 }
105 
107 {
108  G4String v = str;
109  v.toUpper();
110  G4bool vl = false;
111  if( v=="Y" || v=="YES" || v=="1" || v=="T" || v=="TRUE" )
112  { vl = true; }
113  return vl;
114 }
115 
116 
118 {
119  G4cerr << "Warning : Old style definition of G4UIcommand <"
120  << newCommand->GetCommandPath() << ">." << G4endl;
121 }
122 
123 void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc)
124 {
126 
127  G4String fullpath = path;
128  if(fullpath(fullpath.length()-1) != '/') fullpath.append("/");
129 
130  G4UIcommandTree* tree= ui-> GetTree()-> FindCommandTree(fullpath.c_str());
131  if (tree) {
132  baseDirName = tree-> GetPathName();
133  } else {
134  baseDir = new G4UIdirectory(fullpath.c_str());
135  baseDirName = fullpath;
136  baseDir-> SetGuidance(dsc.c_str());
137  }
138 }