Homepage Demos Overview Downloads Tutorials Reference
Credits

EventTrans.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_EventTrans_h_
00003 #define INCLUDED_EventTrans_h_
00004 
00005 #include "Behaviors/Transition.h"
00006 #include "Events/EventRouter.h"
00007 
00008 //! causes a transition when the specified event is received
00009 
00010 class EventTrans : public Transition {
00011 private:
00012   int argcount;
00013   EventBase::EventGeneratorID_t egid;
00014   unsigned int esid;
00015   EventBase::EventTypeID_t etid;
00016 
00017 public:
00018   EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid) :
00019     Transition(destination), argcount(1), egid(gid), esid(0), etid(EventBase::statusETID) {};
00020 
00021   EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid) :
00022     Transition(destination), argcount(2), egid(gid), esid(sid), etid(EventBase::statusETID) {};
00023 
00024   EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, 
00025        unsigned int sid, EventBase::EventTypeID_t tid) :
00026     Transition(destination), argcount(3), egid(gid), esid(sid), etid(tid) {};
00027 
00028   //! starts listening
00029   virtual void DoStart() {
00030     Transition::DoStart();
00031     switch (argcount) {
00032     case 1: erouter->addListener(this,egid); break;
00033     case 2: erouter->addListener(this,egid,esid); break;
00034     case 3: erouter->addListener(this,egid,esid,etid);
00035     };
00036   }
00037 
00038   //! stops listening
00039   virtual void DoStop() {
00040     erouter->removeListener(this);
00041     Transition::DoStop();
00042   }
00043 
00044   //! fire the transition if an event is seen
00045   virtual void processEvent(const EventBase&) { fire(); }
00046 
00047   virtual std::string getName() const { return "EventTrans"; }
00048 
00049 };
00050 
00051 /*! @file
00052  * @brief Defines EventTrans, which causes a transition if an event of the specified type occurs
00053  * @author dst (Creator)
00054  *
00055  * $Author: ejt $
00056  * $Name: tekkotsu-2_2 $
00057  * $Revision: 1.3 $
00058  * $State: Exp $
00059  * $Date: 2004/10/07 19:07:05 $
00060  */
00061 
00062 #endif

Tekkotsu v2.2
Generated Tue Oct 19 14:19:14 2004 by Doxygen 1.3.9.1