Geant4  10.02.p01
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: G4UImessenger.cc 84281 2014-10-13 07:21:50Z gcosmo $
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(""), commandsShouldBeInMaster(false)
40 {
41 }
42 
44  G4bool commandsToBeBroadcasted)
45  : baseDir(NULL), baseDirName(""), commandsShouldBeInMaster(false)
46 {
47  CreateDirectory(path, dsc, commandsToBeBroadcasted);
48 }
49 
51 {
52  if(baseDir) delete baseDir;
53 }
54 
56 {
57  G4String nullString;
58  return nullString;
59 }
60 
62 { ; }
63 
65  return this == &messenger;
66 }
67 
69 {
70  std::ostringstream os;
71  os << i;
72  return G4String(os.str());
73 }
74 
76 {
77  std::ostringstream os;
78  os << a;
79  return G4String(os.str());
80 }
81 
83 {
84  G4String vl = "0";
85  if(b) vl = "true";
86  return vl;
87 }
88 
90 {
91  G4int vl;
92  const char* t = str;
93  std::istringstream is(t);
94  is >> vl;
95  return vl;
96 }
97 
99 {
100  G4double vl;
101  const char* t = str;
102  std::istringstream is(t);
103  is >> vl;
104  return vl;
105 }
106 
108 {
109  G4String v = str;
110  v.toUpper();
111  G4bool vl = false;
112  if( v=="Y" || v=="YES" || v=="1" || v=="T" || v=="TRUE" )
113  { vl = true; }
114  return vl;
115 }
116 
117 
119 {
120  G4cerr << "Warning : Old style definition of G4UIcommand <"
121  << newCommand->GetCommandPath() << ">." << G4endl;
122 }
123 
124 void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc,
125  G4bool commandsToBeBroadcasted)
126 {
128 
129  G4String fullpath = path;
130  if(fullpath(fullpath.length()-1) != '/') fullpath.append("/");
131 
132  G4UIcommandTree* tree= ui-> GetTree()-> FindCommandTree(fullpath.c_str());
133  if (tree) {
134  baseDirName = tree-> GetPathName();
135  } else {
136  baseDir = new G4UIdirectory(fullpath.c_str(),commandsToBeBroadcasted);
137  baseDirName = fullpath;
138  baseDir-> SetGuidance(dsc.c_str());
139  }
140 }
G4String baseDirName
virtual G4String GetCurrentValue(G4UIcommand *command)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
G4double a
Definition: TRTMaterials.hh:39
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4bool StoB(G4String s)
void CreateDirectory(const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
void toUpper()
G4String ItoS(G4int i)
bool G4bool
Definition: G4Types.hh:79
G4bool operator==(const G4UImessenger &messenger) const
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:139
G4String DtoS(G4double a)
void AddUIcommand(G4UIcommand *newCommand)
G4int StoI(G4String s)
virtual ~G4UImessenger()
G4double StoD(G4String s)
G4String & append(const G4String &)
G4UIdirectory * baseDir
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4String BtoS(G4bool b)
G4GLOB_DLL std::ostream G4cerr