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("EventTrans",destination), argcount(1), egid(gid), esid(0), etid(EventBase::statusETID)
00020   {}
00021 
00022   EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid)
00023     : Transition("EventTrans",destination), argcount(2), egid(gid), esid(sid), etid(EventBase::statusETID)
00024   {}
00025 
00026   EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid, EventBase::EventTypeID_t tid)
00027     : Transition("EventTrans",destination), argcount(3), egid(gid), esid(sid), etid(tid)
00028   {}
00029 
00030   EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid)
00031     : Transition("EventTrans",name,destination), argcount(1), egid(gid), esid(0), etid(EventBase::statusETID)
00032   {}
00033 
00034   EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid)
00035     : Transition("EventTrans",name,destination), argcount(2), egid(gid), esid(sid), etid(EventBase::statusETID)
00036   {}
00037 
00038   EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid, EventBase::EventTypeID_t tid)
00039     : Transition("EventTrans",name,destination), argcount(3), egid(gid), esid(sid), etid(tid)
00040   {}
00041 
00042   //! starts listening
00043   virtual void DoStart() {
00044     Transition::DoStart();
00045     switch (argcount) {
00046     case 1: erouter->addListener(this,egid); break;
00047     case 2: erouter->addListener(this,egid,esid); break;
00048     case 3: erouter->addListener(this,egid,esid,etid);
00049     };
00050   }
00051 
00052   //! stops listening
00053   virtual void DoStop() {
00054     erouter->removeListener(this);
00055     Transition::DoStop();
00056   }
00057 
00058   //! fire the transition if an event is seen
00059   virtual void processEvent(const EventBase&) { fire(); }
00060 
00061 };
00062 
00063 /*! @file
00064  * @brief Defines EventTrans, which causes a transition if an event of the specified type occurs
00065  * @author dst (Creator)
00066  *
00067  * $Author: ejt $
00068  * $Name: tekkotsu-2_2_1 $
00069  * $Revision: 1.5 $
00070  * $State: Exp $
00071  * $Date: 2004/11/15 22:46:19 $
00072  */
00073 
00074 #endif

Tekkotsu v2.2.1
Generated Tue Nov 23 16:36:38 2004 by Doxygen 1.3.9.1