EventDebuggerMessenger.cc

Go to the documentation of this file.
00001 // $Header: /cvs/lcd/slic/src/EventDebuggerMessenger.cc,v 1.4 2005/12/09 01:58:34 jeremy Exp $
00002 #include "EventDebuggerMessenger.hh"
00003 
00004 // slic
00005 #include "EventDebugger.hh"
00006 
00007 // lcdd
00008 #include "StringUtil.hh"
00009 
00010 // geant4
00011 #include "G4UIcmdWithAString.hh"
00012 #include "G4UIcmdWithABool.hh"
00013 
00014 namespace slic
00015 {
00016   EventDebuggerMessenger::EventDebuggerMessenger()
00017   {
00018     defineCommands();
00019   }
00020 
00021   EventDebuggerMessenger::~EventDebuggerMessenger()
00022   {}
00023 
00024   void EventDebuggerMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals)
00025   {
00026     EventDebugger* debugger = EventDebugger::instance();
00027     if ( cmd == m_debugMacroCmd ) {
00028       debugger->setDebugMacro( newVals );
00029     }
00030     else if ( cmd == m_cleanupMacroCmd ) {
00031       debugger->setCleanupMacro( newVals );
00032     }
00033     else if ( cmd == m_addDebugEventsCmd ) {
00034 
00035       std::vector<std::string> strList;
00036       const std::string str = std::string(newVals);
00037       const std::string delim = " ";
00038 
00039       StringUtil::split( str, delim, strList );
00040 
00041       EventDebugger::DebugEventList dbgList;
00042       for ( std::vector<std::string>::iterator it = strList.begin();
00043             it != strList.end();
00044             it++ ) {
00045         debugger->addDebugEvent(StringUtil::toInt(*it));
00046       }
00047     }
00048     else if ( cmd == m_clearDebugEventsCmd ) {
00049       debugger->clearDebugEvents();
00050     }
00051     else if ( cmd == m_enableDebugCmd ) {
00052       debugger->enableDebug( m_enableDebugCmd->GetNewBoolValue( newVals.c_str() ) );
00053     }
00054   }
00055 
00056   void EventDebuggerMessenger::defineCommands()
00057   {
00058     m_debugDir = new G4UIdirectory( "/debug/" );
00059     m_debugDir->SetGuidance( "Debugging commands. [SLIC]" );
00060 
00061     m_debugMacroCmd = new G4UIcmdWithAString( "/debug/debugMacro", this );
00062     m_debugMacroCmd->SetGuidance( "Set macro for debugging." );
00063 
00064     m_cleanupMacroCmd = new G4UIcmdWithAString( "/debug/cleanupMacro", this );
00065     m_cleanupMacroCmd->SetGuidance( "Set macro to cleanup debug state." );
00066 
00067     m_addDebugEventsCmd = new G4UIcmdWithAString( "/debug/addEvents", this );
00068     m_addDebugEventsCmd->SetGuidance( "Add event IDs to debug, separated by spaces." );
00069 
00070     m_clearDebugEventsCmd = new G4UIcommand( "/debug/clearEvents", this );
00071     m_clearDebugEventsCmd->SetGuidance( "Clear the list of events to debug." );
00072 
00073     m_enableDebugCmd = new G4UIcmdWithABool( "/debug/enableDebug", this );
00074     m_enableDebugCmd->SetGuidance( "Enable event debugging for all subsequent events." );
00075     m_enableDebugCmd->SetParameterName("enable", true);
00076     m_enableDebugCmd->SetDefaultValue(true);
00077   }
00078 } // namespace slic

Generated on Thu Nov 15 15:24:15 2007 for Simulator for the Linear Collider by  doxygen 1.5.4