G4UImessenger.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 
00030 #include "G4UImessenger.hh"
00031 #include "G4UImanager.hh"
00032 #include "G4UIcommand.hh"
00033 #include "G4UIdirectory.hh"
00034 #include "G4UIcommandTree.hh"
00035 #include "G4ios.hh"
00036 #include <sstream>
00037 
00038 G4UImessenger::G4UImessenger()
00039   : baseDir(NULL), baseDirName("")
00040 { 
00041 }
00042 
00043 G4UImessenger::G4UImessenger(const G4String& path, const G4String& dsc)
00044   : baseDir(NULL), baseDirName("")
00045 {
00046   CreateDirectory(path, dsc);
00047 }
00048 
00049 G4UImessenger::~G4UImessenger()
00050 {
00051   if(baseDir) delete baseDir;
00052 }
00053 
00054 G4String G4UImessenger::GetCurrentValue(G4UIcommand*) 
00055 { 
00056   G4String nullString;
00057   return nullString;
00058 }
00059 
00060 void G4UImessenger::SetNewValue(G4UIcommand*,G4String) 
00061 { ; }
00062 
00063 G4bool G4UImessenger::operator == (const G4UImessenger& messenger) const {
00064   return this == &messenger;
00065 }
00066 
00067 G4String G4UImessenger::ItoS(G4int i)
00068 {
00069   std::ostringstream os;
00070   os << i;
00071   return G4String(os.str());
00072 }
00073 
00074 G4String G4UImessenger::DtoS(G4double a)
00075 {
00076   std::ostringstream os;
00077   os << a;
00078   return G4String(os.str());
00079 }
00080 
00081 G4String G4UImessenger::BtoS(G4bool b)
00082 {
00083   G4String vl = "0";
00084   if(b) vl = "true";
00085   return vl;
00086 }
00087 
00088 G4int G4UImessenger::StoI(G4String str)
00089 {
00090   G4int vl;
00091   const char* t = str;
00092   std::istringstream is(t);
00093   is >> vl;
00094   return vl;
00095 }
00096 
00097 G4double G4UImessenger::StoD(G4String str)
00098 {
00099   G4double vl;
00100   const char* t = str;
00101   std::istringstream is(t);
00102   is >> vl;
00103   return vl;
00104 }
00105 
00106 G4bool G4UImessenger::StoB(G4String str)
00107 {
00108   G4String v = str;
00109   v.toUpper();
00110   G4bool vl = false;
00111   if( v=="Y" || v=="YES" || v=="1" || v=="T" || v=="TRUE" )
00112   { vl = true; }
00113   return vl;
00114 }
00115 
00116 
00117 void G4UImessenger::AddUIcommand(G4UIcommand * newCommand)
00118 {
00119   G4cerr << "Warning : Old style definition of G4UIcommand <" 
00120          << newCommand->GetCommandPath() << ">." << G4endl;
00121 }
00122 
00123 void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc)
00124 {
00125   G4UImanager* ui = G4UImanager::GetUIpointer();
00126 
00127   G4String fullpath = path;
00128   if(fullpath(fullpath.length()-1) != '/') fullpath.append("/");
00129 
00130   G4UIcommandTree* tree= ui-> GetTree()-> FindCommandTree(fullpath.c_str());
00131   if (tree) {
00132     baseDirName = tree-> GetPathName();
00133   } else {
00134     baseDir = new G4UIdirectory(fullpath.c_str());
00135     baseDirName = fullpath;
00136     baseDir-> SetGuidance(dsc.c_str());
00137   }
00138 }

Generated on Mon May 27 17:50:06 2013 for Geant4 by  doxygen 1.4.7