/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/G4Svc/G4Svc-00-01-52/other_src/GoofyMessenger.cpp

Go to the documentation of this file.
00001 #include "G4Svc/GoofyMessenger.h"
00002 #include "G4Svc/Goofy.h"
00003 
00004 #include "G4UIcommand.hh"
00005 #include "G4UImanager.hh"
00006 
00007 #include "FadsPackageLoader/PackageLoader.h"
00008 
00009 GoofyMessenger::GoofyMessenger(Goofy *v)
00010 {
00011         rm=v;
00012 
00013         shell=new G4UIcommand("/shell",this);
00014         shell->SetGuidance("Invokes a shell command");
00015         G4UIparameter* parameter;
00016         G4bool omitable;
00017         parameter = new G4UIparameter ("Command", 's', omitable = false);
00018         shell->SetParameter(parameter);
00019 
00020         echo=new G4UIcommand("/echo",this);
00021         echo->SetGuidance("Echoes a string");
00022         echo->SetParameter(parameter);
00023         
00024         edit=new G4UIcommand("/edit",this);
00025         edit->SetGuidance("Invokes the chosen editor");
00026         parameter = new G4UIparameter ("File to be edited", 's', omitable = false);
00027         edit->SetParameter(parameter);
00028 
00029         quit=new G4UIcommand("/quit",this);
00030         quit->SetGuidance("quits the application");
00031         
00032         load=new G4UIcommand("/load",this);
00033         load->SetGuidance("Dynamically loads a shared library");
00034         parameter = new G4UIparameter ("Library to be loaded", 's', omitable = false);
00035         load->SetParameter(parameter);
00036         
00037         unload=new G4UIcommand("/unload",this);
00038         unload->SetGuidance("Drops a shared library");
00039         parameter = new G4UIparameter ("Library to be dropped", 's', omitable = false);
00040         unload->SetParameter(parameter);
00041 }
00042 
00043 GoofyMessenger::~GoofyMessenger()
00044 {
00045         delete shell;
00046         delete echo;
00047         delete edit;
00048         delete load;
00049         delete unload;
00050         delete quit;
00051 }
00052 
00053 void GoofyMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
00054 {
00055         if (command==shell)
00056         {
00057                 std::string temp(newValues);
00058                 unsigned int i=temp.find_first_not_of ('"');
00059                 if (i != std::string::npos)
00060                 {
00061                         if (i>0) temp = temp.substr (i);
00062                         i = temp.find_last_not_of ('"');
00063                         if (i < temp.size ()) temp = temp.substr (0, i + 1);
00064                 }
00065                 i=Goofy::Shell(temp);
00066         }
00067         else if (command==echo)
00068         {
00069                 std::string temp(newValues);
00070                 unsigned int i=temp.find_first_not_of ('"');
00071                 if (i != std::string::npos)
00072                 {
00073                         if (i>0) temp = temp.substr (i);
00074                         i = temp.find_last_not_of ('"');
00075                         if (i < temp.size ()) temp = temp.substr (0, i + 1);
00076                 }
00077                 i=Goofy::Shell("echo "+temp);
00078         }
00079         else if (command==quit)
00080         {
00081                 G4UImanager *man=G4UImanager::GetUIpointer();
00082                 man->ApplyCommand("/exit");
00083         }
00084         else if (command==edit)
00085         {
00086                 std::string s="$GOOFY_EDITOR "+newValues+" &";
00087                 Goofy::Shell(s);
00088         }
00089         else if (command==load)
00090         {
00091                 PackageLoader a(newValues.c_str());
00092         }
00093         else if (command==unload)
00094         {
00095                 bool test;
00096                 PackageLoader a;
00097                 test=a.unload(newValues);
00098         }
00099 }
00100 
00101 G4String GoofyMessenger::GetCurrentValue(G4UIcommand * command)
00102 {
00103         G4String s="Undefined";
00104         return s;
00105 }

Generated on Tue Nov 29 23:14:33 2016 for BOSS_7.0.2 by  doxygen 1.4.7