00001
00002 #ifndef INCLUDED_EventTrans_h_
00003 #define INCLUDED_EventTrans_h_
00004
00005 #include "Behaviors/Transition.h"
00006 #include "Events/EventRouter.h"
00007
00008
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
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
00039 virtual void DoStop() {
00040 erouter->removeListener(this);
00041 Transition::DoStop();
00042 }
00043
00044
00045 virtual void processEvent(const EventBase&) { fire(); }
00046
00047 virtual std::string getName() const { return "EventTrans"; }
00048
00049 };
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #endif