00001 // $Id: SequencerTimerTool.h,v 1.7 2005/07/29 16:49:43 hmd Exp $ 00002 #ifndef SEQUENCERTIMERTOOL_H 00003 #define SEQUENCERTIMERTOOL_H 1 00004 00005 // Include files 00006 // from Gaudi 00007 #include "GaudiAlg/GaudiTool.h" 00008 #include "GaudiAlg/ISequencerTimerTool.h" 00009 00010 // local 00011 #include "TimerForSequencer.h" 00012 00013 00021 class SequencerTimerTool : public GaudiTool, virtual public ISequencerTimerTool{ 00022 public: 00023 00025 SequencerTimerTool( const std::string& type, 00026 const std::string& name, 00027 const IInterface* parent); 00028 00029 virtual ~SequencerTimerTool( ); 00030 00032 virtual StatusCode initialize(); 00033 00035 virtual StatusCode finalize(); 00036 00038 virtual int addTimer( std::string name ) { 00039 std::string myName; 00040 if ( 0 < m_indent ) { 00041 std::string prefix( m_indent, ' ' ); 00042 myName += prefix; 00043 } 00044 unsigned int headerSize = 30; 00045 00046 std::string space( headerSize, ' ' ); 00047 myName += name + space ; 00048 myName = myName.substr( 0, headerSize ); 00049 00050 m_timerList.push_back( TimerForSequencer(myName, m_normFactor) ); 00051 return m_timerList.size() -1; 00052 }; 00053 00055 virtual void increaseIndent() { m_indent += 2; }; 00056 00058 virtual void decreaseIndent() { 00059 m_indent -= 2; 00060 if ( 0 > m_indent ) m_indent = 0; 00061 }; 00062 00064 void start( int index ) { m_timerList[index].start(); }; 00065 00067 double stop( int index ) { return m_timerList[index].stop(); }; 00068 00070 double lastTime( int index ) { return m_timerList[index].lastTime(); }; 00071 00073 std::string name( int index ) { return m_timerList[index].name(); }; 00074 00076 int indexByName( std::string name ); 00077 00079 virtual bool globalTiming() { return m_globalTiming; }; 00080 00081 protected: 00082 00083 private: 00084 int m_shots; 00085 bool m_normalised; 00086 int m_indent; 00087 std::vector<TimerForSequencer> m_timerList; 00088 double m_normFactor; 00089 double m_speedRatio; 00090 bool m_globalTiming; 00091 }; 00092 #endif // SEQUENCERTIMERTOOL_H