00001
00002 #ifndef INCLUDED_EventGeneratorBase_h_
00003 #define INCLUDED_EventGeneratorBase_h_
00004
00005 #include "Behaviors/BehaviorBase.h"
00006 #include "Events/EventBase.h"
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 class EventGeneratorBase : public BehaviorBase {
00023 public:
00024
00025
00026
00027
00028 virtual ~EventGeneratorBase() {}
00029
00030 virtual void doStart();
00031
00032 virtual void doStop();
00033
00034
00035
00036
00037
00038
00039 virtual void processEvent(const EventBase& ev);
00040
00041
00042
00043
00044
00045
00046 virtual EventBase::EventGeneratorID_t getGeneratorID() const { return myGenID; }
00047
00048 virtual void setGeneratorID(EventBase::EventGeneratorID_t gid) { myGenID=gid; }
00049
00050
00051 virtual size_t getSourceID() const { return mySourceID; }
00052
00053 virtual void setSourceID(size_t sid) { mySourceID=sid; }
00054
00055
00056 virtual bool hasListeners() const;
00057
00058
00059
00060
00061
00062
00063
00064 enum specificity_t {
00065 GENERATOR,
00066 SOURCE,
00067 TYPE
00068 };
00069
00070 virtual specificity_t getSpecificity() const { return specificity; }
00071
00072
00073 virtual void setAutoListen(EventBase::EventGeneratorID_t gid);
00074
00075 virtual void setAutoListen(EventBase::EventGeneratorID_t gid, size_t sid);
00076
00077 virtual void setAutoListen(EventBase::EventGeneratorID_t gid, size_t sid, EventBase::EventTypeID_t tid);
00078
00079 virtual void unsetAutoListen();
00080
00081
00082 virtual EventBase::EventGeneratorID_t getListenGeneratorID() const { return srcGenID; }
00083
00084 virtual size_t getListenSourceID() const { return srcSourceID; }
00085
00086 virtual EventBase::EventTypeID_t getListenTypeID() const { return srcTypeID; }
00087
00088
00089
00090 protected:
00091
00092
00093 EventGeneratorBase(const std::string& instancename, EventBase::EventGeneratorID_t mgid, size_t msid)
00094 : BehaviorBase(instancename), myGenID(mgid), mySourceID(msid), autoListen(false), isListening(false), srcGenID(EventBase::numEGIDs), srcSourceID(), srcTypeID(), specificity()
00095 {}
00096 EventGeneratorBase(const std::string& instancename, EventBase::EventGeneratorID_t mgid, size_t msid,EventBase::EventGeneratorID_t srcgid)
00097 : BehaviorBase(instancename), myGenID(mgid), mySourceID(msid), autoListen(srcgid!=EventBase::numEGIDs), isListening(false), srcGenID(srcgid), srcSourceID(), srcTypeID(), specificity(GENERATOR)
00098 {}
00099 EventGeneratorBase(const std::string& instancename, EventBase::EventGeneratorID_t mgid, size_t msid,EventBase::EventGeneratorID_t srcgid, size_t srcsid)
00100 : BehaviorBase(instancename), myGenID(mgid), mySourceID(msid), autoListen(srcgid!=EventBase::numEGIDs), isListening(false), srcGenID(srcgid), srcSourceID(srcsid), srcTypeID(), specificity(SOURCE)
00101 {}
00102 EventGeneratorBase(const std::string& instancename, EventBase::EventGeneratorID_t mgid, size_t msid,EventBase::EventGeneratorID_t srcgid, size_t srcsid, EventBase::EventTypeID_t srctype)
00103 : BehaviorBase(instancename), myGenID(mgid), mySourceID(msid), autoListen(srcgid!=EventBase::numEGIDs), isListening(false), srcGenID(srcgid), srcSourceID(srcsid), srcTypeID(srctype), specificity(TYPE)
00104 {}
00105
00106
00107
00108 virtual void addSrcListener();
00109
00110
00111 virtual void removeSrcListener();
00112
00113 EventBase::EventGeneratorID_t myGenID;
00114 size_t mySourceID;
00115 bool autoListen;
00116 bool isListening;
00117 EventBase::EventGeneratorID_t srcGenID;
00118 size_t srcSourceID;
00119 EventBase::EventTypeID_t srcTypeID;
00120 specificity_t specificity;
00121 };
00122
00123
00124
00125
00126
00127
00128 #endif