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; //!< the number of arguments which were supplied to the constructor (granularity of filtering)
00013   EventBase::EventGeneratorID_t egid; //!< the requested generator
00014   unsigned int esid; //!< the requested source
00015   EventBase::EventTypeID_t etid; //!< the requested type
00016 
00017 public:
00018   //!@name Constructors
00019   //! follows general pattern of EventRouter::addListener()
00020   EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid)
00021     : Transition("EventTrans",destination), argcount(1), egid(gid), esid(0), etid(EventBase::statusETID)
00022   {}
00023 
00024   EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid)
00025     : Transition("EventTrans",destination), argcount(2), egid(gid), esid(sid), etid(EventBase::statusETID)
00026   {}
00027 
00028   EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid, EventBase::EventTypeID_t tid)
00029     : Transition("EventTrans",destination), argcount(3), egid(gid), esid(sid), etid(tid)
00030   {}
00031 
00032   EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid)
00033     : Transition("EventTrans",name,destination), argcount(1), egid(gid), esid(0), etid(EventBase::statusETID)
00034   {}
00035 
00036   EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid)
00037     : Transition("EventTrans",name,destination), argcount(2), egid(gid), esid(sid), etid(EventBase::statusETID)
00038   {}
00039 
00040   EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int sid, EventBase::EventTypeID_t tid)
00041     : Transition("EventTrans",name,destination), argcount(3), egid(gid), esid(sid), etid(tid)
00042   {}
00043   //@}
00044 
00045   //! starts listening
00046   virtual void DoStart() {
00047     Transition::DoStart();
00048     switch (argcount) {
00049     case 1: erouter->addListener(this,egid); break;
00050     case 2: erouter->addListener(this,egid,esid); break;
00051     case 3: erouter->addListener(this,egid,esid,etid);
00052     };
00053   }
00054 
00055   //! stops listening
00056   virtual void DoStop() {
00057     erouter->removeListener(this);
00058     Transition::DoStop();
00059   }
00060 
00061   //! fire the transition if an event is seen
00062   virtual void processEvent(const EventBase&) { fire(); }
00063 
00064 };
00065 
00066 /*! @file
00067  * @brief Defines EventTrans, which causes a transition if an event of the specified type occurs
00068  * @author dst (Creator)
00069  *
00070  * $Author: ejt $
00071  * $Name: tekkotsu-2_2_2 $
00072  * $Revision: 1.6 $
00073  * $State: Exp $
00074  * $Date: 2004/12/23 01:47:07 $
00075  */
00076 
00077 #endif

Tekkotsu v2.2.2
Generated Tue Jan 4 15:43:13 2005 by Doxygen 1.4.0