Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
TimeOutTrans.hGo 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 { 00010 public: 00011 //! constructor, specify delay in milliseconds 00012 TimeOutTrans(StateNode* destination, unsigned int delay) : Transition(destination), d(delay) {} 00013 00014 //!starts timer 00015 virtual void DoStart() { 00016 Transition::DoStart(); 00017 resetTimer(); 00018 } 00019 00020 //!stops timer 00021 virtual void DoStop() { erouter->forgetListener(this); Transition::DoStop(); } 00022 00023 //!resets timer 00024 void resetTimer() { 00025 //std::cout << "Reset @ " << get_time() << " stop @ " << get_time()+d << ' ' << this << std::endl; 00026 erouter->addTimer(this,0,d,false); 00027 } 00028 00029 //!if we receive the timer event, activate() 00030 virtual void processEvent(const EventBase& e) { 00031 std::cout << "Timeout @ " << get_time() << " from " << e.getName() << ' ' << this << std::endl; 00032 activate(); 00033 } 00034 00035 virtual std::string getName() const { return "TimeOutTrans"; } 00036 00037 protected: 00038 //!amount to delay (in milliseconds) before transition 00039 unsigned int d; 00040 }; 00041 00042 /*! @file 00043 * @brief Defines TimeOutTrans, which causes a transition after a specified amount of time has passed 00044 * @author ejt (Creator) 00045 * 00046 * $Author: ejt $ 00047 * $Name: tekkotsu-2_1 $ 00048 * $Revision: 1.9 $ 00049 * $State: Exp $ 00050 * $Date: 2003/11/11 00:08:18 $ 00051 */ 00052 00053 #endif |
Tekkotsu v2.1 |
Generated Tue Mar 16 23:19:15 2004 by Doxygen 1.3.5 |