Homepage Demos Overview Downloads Tutorials Reference
Credits
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Search

TimeOutTrans.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_TimeOutTrans_h_
00003 #define INCLUDED_TimeOutTrans_h_
00004 
00005 #include "Behaviors/Transition.h"
00006 #include "Events/EventRouter.h"
00007 
00008 //! causes a transition after a specified amount of time has passed
00009 class TimeOutTrans : public Transition, public EventListener {
00010 public:
00011   //! constructor, specify delay in milliseconds
00012   TimeOutTrans(StateNode* source, StateNode* destination, unsigned int delay) : Transition(source,destination), EventListener(), d(delay) {}
00013   
00014   //!starts timer
00015   virtual void enable() { resetTimer(); }
00016 
00017   //!stops timer
00018   virtual void disable() { erouter->forgetListener(this); }
00019 
00020   //!resets timer
00021   void resetTimer() { erouter->addTimer(this,0,d,false); }
00022 
00023   //!if we receive the timer event, activate()
00024   virtual void processEvent(const EventBase&) {
00025     activate();
00026   }
00027 protected:
00028   //!amount to delay (in milliseconds) before transition
00029   unsigned int d;
00030 };
00031 
00032 /*! @file
00033  * @brief Defines TimeOutTrans, which causes a transition after a specified amount of time has passed
00034  * @author ejt (Creator)
00035  *
00036  * $Author: ejt $
00037  * $Name: tekkotsu-1_4_1 $
00038  * $Revision: 1.2 $
00039  * $State: Exp $
00040  * $Date: 2003/03/09 02:45:22 $
00041  */
00042 
00043 #endif

Tekkotsu v1.4
Generated Sat Jul 19 00:06:32 2003 by Doxygen 1.3.2