00001 #include "G4Svc/RandomCenterMessenger.h" 00002 #include "G4Svc/Goofy.h" 00003 00004 #include "G4UIcommand.hh" 00005 #include "G4UImanager.hh" 00006 00007 #include <string> 00008 #include <fstream.h> 00009 00010 #include "G4Svc/RandomNrCenter.h" 00011 00012 00013 RandomCenterMessenger::RandomCenterMessenger(Goofy *v) 00014 { 00015 rm=v; 00016 00017 setSeed=new G4UIcommand("/Random/SetSeed",this); 00018 setSeed->SetGuidance("Sets the seed to the current generator"); 00019 G4UIparameter* parameter; 00020 G4bool omitable; 00021 parameter = new G4UIparameter ("Random", 'i', omitable = false); 00022 setSeed->SetParameter(parameter); 00023 00024 saveStatus=new G4UIcommand("/Random/SaveStatus",this); 00025 saveStatus->SetGuidance("Saves the status of the current generator"); 00026 G4UIparameter* filename; 00027 filename=new G4UIparameter ("Random", 's', omitable = false); 00028 saveStatus->SetParameter(filename); 00029 00030 readStatus=new G4UIcommand("/Random/RetrieveStatus",this); 00031 readStatus->SetGuidance("Retrieves the status for the current generator"); 00032 filename=new G4UIparameter ("Random", 's', omitable = false); 00033 readStatus->SetParameter(filename); 00034 00035 setEngine=new G4UIcommand("/Random/SetEngine",this); 00036 setEngine->SetGuidance("Allows to choose a new Random Number Engine"); 00037 00038 resetEngine=new G4UIcommand("/Random/ResetEngine",this); 00039 resetEngine->SetGuidance("Resets the engine to its default"); 00040 00041 } 00042 00043 RandomCenterMessenger::~RandomCenterMessenger() 00044 { 00045 delete setSeed; 00046 delete saveStatus; 00047 delete readStatus; 00048 delete setEngine; 00049 delete resetEngine; 00050 } 00051 00052 void RandomCenterMessenger::SetNewValue(G4UIcommand * command,G4String newValues) 00053 { 00054 if (command==setSeed) 00055 { 00056 long int i; 00057 const char* s = newValues; 00058 std::istrstream is ((char*)s); 00059 is>>i; 00060 RandomNrCenter rc; 00061 rc.SetEngineSeed(i); 00062 } 00063 else if (command==saveStatus) 00064 { 00065 RandomNrCenter rc; 00066 rc.SaveEngineStatus(newValues); 00067 } 00068 else if (command==readStatus) 00069 { 00070 RandomNrCenter rc; 00071 rc.RestoreEngineStatus(newValues); 00072 } 00073 else if (command==setEngine) 00074 { 00075 RandomNrCenter rc; 00076 rc.SetEngine(); 00077 } 00078 else if (command==resetEngine) 00079 { 00080 00081 } 00082 } 00083 00084 G4String RandomCenterMessenger::GetCurrentValue(G4UIcommand * command) 00085 { 00086 G4String s="Undefined"; 00087 return s; 00088 }