TTimer


class description - source file - inheritance tree

class TTimer : public TSysEvtHandler


    public:
TTimer TTimer(Long_t milliSec = 0, Bool_t mode = kTRUE) TTimer TTimer(TObject* obj, Long_t milliSec, Bool_t mode = kTRUE) TTimer TTimer(const char* command, Long_t milliSec, Bool_t mode = kTRUE) TTimer TTimer(const TTimer&) virtual void ~TTimer() virtual void Add() Bool_t CheckTimer(const TTime& now) static TClass* Class() TTime GetAbsTime() const const char* GetCommand() const TObject* GetObject() TTime GetTime() const UInt_t GetTimerID() Bool_t HasTimedOut() const virtual TClass* IsA() const Bool_t IsAsync() const Bool_t IsSync() const virtual Bool_t Notify() virtual void Remove() void Reset() void SetCommand(const char* command) void SetObject(TObject* object) void SetTime(Long_t milliSec) void SetTimerID(UInt_t id = 0) virtual void ShowMembers(TMemberInspector& insp, char* parent) static void SingleShot(Int_t milliSec, const char* receiver_class, void* receiver, const char* method) virtual void Start(Int_t milliSec = -1, Bool_t singleShot = kFALSE) virtual void Stop() virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) virtual void Timeout() virtual void TurnOff() virtual void TurnOn()

Data Members


    protected:
TTime fTime time out time in ms TTime fAbsTime absolute time out time in ms Bool_t fTimeout true if timer has timed out Bool_t fSync true if synchrounous timer UInt_t fTimeID the system ID of this timer (for WIN32) TObject* fObject object to be notified (if any) TString fCommand interpreter command to be executed


See also

TProcessEventTimer

Class Description

                                                                      
 TTimer                                                               
                                                                      
 Handles synchronous and a-synchronous timer events. You can use      
 this class in one of the following ways:                             
    - Sub-class TTimer and override the Notify() method.              
    - Re-implement the TObject::HandleTimer() method in your class    
      and pass a pointer to this object to timer, see the SetObject() 
      method.                                                         
    - Pass an interpreter command to timer, see SetCommand() method.  
    - Create a TTimer, connect its Timeout() signal to the            
      appropriate methods. Then when the time is up it will emit a    
      Timeout() signal and call connected slots.                      
                                                                      
  Minimum timeout interval is defined in TSystem::ESysConstants as    
  kItimerResolution (currently 10 ms).                                
                                                                      
  Signal/slots example:                                               
       TTimer *timer = new TTimer();                                  
       Connect(timer, "Timeout()", "myObjectClassName",               
               myObject, "TimerDone()");                              
       timer->Start(2000, kTRUE);   // 2 seconds single-shot          
                                                                      
    // Timeout signal is emitted repeadetly with minimum timeout      
    // timer->Start(0, kFALSE);                                       
                                                                      


TTimer(Long_t ms, Bool_t mode) : fTime(ms)
 Create timer that times out in ms milliseconds. If milliSec is 0
 then the timeout will be the minimum timeout (see TSystem::ESysConstants,
 i.e. 10 ms). If mode == kTRUE then the timer is synchronous else
 a-synchronous. The default is synchronous. Add a timer to the system
 eventloop by calling TurnOn(). Set command to be executed from Notify()
 or set the object whose HandleTimer() method will be called via Notify(),
 derive from TTimer and override Notify() or connect slots to the
 signals Timeout(), TurnOn() and TurnOff().

TTimer(TObject *obj, Long_t ms, Bool_t mode) : fTime(ms)
 Create timer that times out in ms milliseconds. If mode == kTRUE then
 the timer is synchronous else a-synchronous. The default is synchronous.
 Add a timer to the system eventloop by calling TurnOn().
 The object's HandleTimer() will be called by Notify().

TTimer(const char *command, Long_t ms, Bool_t mode) : fTime(ms)
 Create timer that times out in ms milliseconds. If mode == kTRUE then
 the timer is synchronous else a-synchronous. The default is synchronous.
 Add a timer to the system eventloop by calling TurnOn().
 The interpreter will execute command from Notify().

Bool_t CheckTimer(const TTime &now)
 Check if timer timed out.

Bool_t Notify()
 Notify when timer times out. The timer is always reset. To stop
 the timer call TurnOff().

void Reset()
 Reset the timer.

void SetCommand(const char *command)
 Set the interpreter command to be executed at time out. Removes the
 object to be notified (if it was set).

void SetObject(TObject *object)
 Set the object to be notified  at time out. Removes the command to
 be executed (if it was set).

void Start(Int_t milliSec, Bool_t singleShot)
 Starts the timer with a milliSec timeout. If milliSec is 0
 then the timeout will be the minimum timeout (see TSystem::ESysConstants,
 i.e. 10 ms), if milliSec is -1 then the time interval as previously
 specified (in ctor or SetTime()) will be used.
 If singleShot is kTRUE, the timer will be activated only once,
 otherwise it will continue until it is stopped.
 See also TurnOn(), Stop(), TurnOff().

void TurnOff()
 Remove timer from system timer list. This requires that a timer
 has been placed in the system timer list (using TurnOn()).
 If a TTimer subclass is placed on another list, override TurnOff() to
 remove the timer from the correct list.

void TurnOn()
 Add the timer to the system timer list. If a TTimer subclass has to be
 placed on another list, override TurnOn() to add the timer to the correct
 list.

void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
 This static function calls a slot after a given time interval.
 Created internal timer will be deleted after that.



Inline Functions


        const char* GetCommand() const
           TObject* GetObject()
              TTime GetTime() const
             UInt_t GetTimerID()
              TTime GetAbsTime() const
             Bool_t HasTimedOut() const
             Bool_t IsSync() const
             Bool_t IsAsync() const
               void Add()
               void Remove()
               void SetTime(Long_t milliSec)
               void SetTimerID(UInt_t id = 0)
               void Stop()
               void Timeout()
            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void Streamer(TBuffer& b)
               void StreamerNVirtual(TBuffer& b)
             TTimer TTimer(const TTimer&)
               void ~TTimer()


Author: Fons Rademakers 28/11/96
Last update: root/base:$Name: $:$Id: TTimer.cxx,v 1.7 2002/08/02 11:05:01 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.