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 size_t esid;
00015 unsigned int *esidAddr;
00016 EventBase::EventTypeID_t etid;
00017
00018 public:
00019
00020
00021 EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid)
00022 : Transition(destination), argcount(1), egid(gid), esid(0), esidAddr(NULL), etid(EventBase::statusETID)
00023 {}
00024
00025 EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, size_t sid)
00026 : Transition(destination), argcount(2), egid(gid), esid(sid), esidAddr(NULL), etid(EventBase::statusETID)
00027 {}
00028
00029 EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int *sidAddr)
00030 : Transition(destination), argcount(2), egid(gid), esid(0), esidAddr(sidAddr), etid(EventBase::statusETID)
00031 {}
00032
00033 EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, size_t sid, EventBase::EventTypeID_t tid)
00034 : Transition(destination), argcount(3), egid(gid), esid(sid), esidAddr(NULL), etid(tid)
00035 {}
00036
00037 EventTrans(StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int* sidAddr, EventBase::EventTypeID_t tid)
00038 : Transition(destination), argcount(3), egid(gid), esid(0), esidAddr(sidAddr), etid(tid)
00039 {}
00040
00041 EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid)
00042 : Transition(name,destination), argcount(1), egid(gid), esid(0), esidAddr(NULL), etid(EventBase::statusETID)
00043 {}
00044
00045 EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid, size_t sid)
00046 : Transition(name,destination), argcount(2), egid(gid), esid(sid), esidAddr(NULL), etid(EventBase::statusETID)
00047 {}
00048
00049 EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int *sidAddr)
00050 : Transition(name,destination), argcount(2), egid(gid), esid(0), esidAddr(sidAddr), etid(EventBase::statusETID)
00051 {}
00052
00053 EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid, size_t sid, EventBase::EventTypeID_t tid)
00054 : Transition(name,destination), argcount(3), egid(gid), esid(sid), esidAddr(NULL), etid(tid)
00055 {}
00056
00057 EventTrans(const std::string& name, StateNode* destination, EventBase::EventGeneratorID_t gid, unsigned int *sidAddr, EventBase::EventTypeID_t tid)
00058 : Transition(name,destination), argcount(3), egid(gid), esid(0), esidAddr(sidAddr), etid(tid)
00059 {}
00060
00061
00062
00063 virtual void preStart() {
00064 Transition::preStart();
00065 if ( esidAddr != 0 )
00066 erouter->addListener(this,egid);
00067 else {
00068 switch (argcount) {
00069 case 1: erouter->addListener(this,egid); break;
00070 case 2: erouter->addListener(this,egid,esid); break;
00071 case 3: erouter->addListener(this,egid,esid,etid); break;
00072 }
00073 }
00074 }
00075
00076
00077 virtual void doEvent() {
00078 if ( esidAddr == 0 )
00079 fire(*event);
00080 else if ( event->getSourceID() == *esidAddr )
00081 if ( argcount == 2 || event->getTypeID() == etid )
00082 fire(*event);
00083 }
00084
00085 private:
00086 EventTrans(const EventTrans&);
00087 EventTrans& operator=(const EventTrans&);
00088 };
00089
00090
00091
00092
00093
00094
00095 #endif