Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
EventGeneratorBase.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_EventGeneratorBase_h_ 00003 #define INCLUDED_EventGeneratorBase_h_ 00004 00005 #include "Behaviors/BehaviorBase.h" 00006 00007 //! A simple convenience class for event generators 00008 /*! Note that you don't need to inherit from this class to be able to 00009 * send events! Any code can send any event any time, just by calling 00010 * one of the EventRouter::postEvent() functions. 00011 * 00012 * Uses a BehaviorBase base class so that you can start and stop it. 00013 * 00014 * Allows variable settings of the generator id and source id for 00015 * outgoing events as well as automatic handling of 00016 * listening/unlistening for a single optional event source. If you 00017 * want something more fancy that that though, you'll have to 00018 * override DoStart/DoStop yourself. (or extend/modify this class...) 00019 * 00020 */ 00021 class EventGeneratorBase : public BehaviorBase { 00022 public: 00023 //!@name Constructors 00024 //! 00025 EventGeneratorBase(const std::string& name, EventBase::EventGeneratorID_t mgid, unsigned int msid) 00026 : BehaviorBase(name), myGenID(mgid), mySourceID(msid), autoListen(false), isListening(false), srcGenID(EventBase::unknownEGID), srcSourceID(0) 00027 {} 00028 EventGeneratorBase(const std::string& name, EventBase::EventGeneratorID_t mgid, unsigned int msid,EventBase::EventGeneratorID_t srcgid, unsigned int srcsid) 00029 : BehaviorBase(name), myGenID(mgid), mySourceID(msid), autoListen(true), isListening(false), srcGenID(srcgid), srcSourceID(srcsid) 00030 {} 00031 //@} 00032 00033 //! destructor - does nothing 00034 virtual ~EventGeneratorBase() {} 00035 00036 virtual void DoStart(); 00037 00038 virtual void DoStop(); 00039 00040 //! if autolistening, will receive EventRouter events concerning our own listeners 00041 /*! This will automatically reduce overhead by eliminating chains of events thrown 00042 * that don't have any end listeners. However, this might mean your subclass's 00043 * processEvent will be receiving the events from erouterEGID, and will need 00044 * to call EventGeneratorBase::processEvent() in order to allow them to be used */ 00045 virtual void processEvent(const EventBase& event); 00046 00047 //! return the generator ID that will be broadcast from 00048 virtual EventBase::EventGeneratorID_t getGeneratorID() { return myGenID; } 00049 //! set the generator ID that will be broadcast from (typically it's a bad idea to call this...) 00050 virtual void setGeneratorID(EventBase::EventGeneratorID_t gid) { myGenID=gid; } 00051 00052 //! return the source ID that will be broadcast on 00053 virtual unsigned int getSourceID() { return mySourceID; } 00054 //! set the source ID that will be broadcast on 00055 virtual void setSourceID(unsigned int sid) { mySourceID=sid; } 00056 00057 //! returns the source ID that will be listened for (not the source of the FilterBankEvent to be created - that depends on the subclass) 00058 virtual unsigned int getListenSourceID() const { return srcSourceID; } 00059 //! returns the generator ID that will be listened for (not the generator of the FilterBankEvent to be created - that depends on the subclass) 00060 virtual EventBase::EventGeneratorID_t getListenGeneratorID() const { return srcGenID; } 00061 //! turns on auto listening to make it easier to set up dependancies between vision filters 00062 virtual void setAutoListen(EventBase::EventGeneratorID_t gid, unsigned int sid); 00063 00064 //! turns off auto listening 00065 virtual void unsetAutoListen(); 00066 00067 protected: 00068 EventBase::EventGeneratorID_t myGenID; //!< the generator ID to broadcast on 00069 unsigned int mySourceID; //!< the source ID to broadcast on 00070 bool autoListen; //!< if true, will automatically start listening for EventBase(genID,sourceID) events 00071 bool isListening; //!< true if listening triggered by autoListen 00072 EventBase::EventGeneratorID_t srcGenID; //!< the generator ID to listen for (typically the source that this filter works on) 00073 unsigned int srcSourceID; //!< the source ID to listen for 00074 }; 00075 00076 /*! @file 00077 * @brief 00078 * @author ejt (Creator) 00079 * 00080 * $Author: ejt $ 00081 * $Name: tekkotsu-2_2_1 $ 00082 * $Revision: 1.7 $ 00083 * $State: Exp $ 00084 * $Date: 2004/11/11 01:45:37 $ 00085 */ 00086 00087 #endif |
Tekkotsu v2.2.1 |
Generated Tue Nov 23 16:36:38 2004 by Doxygen 1.3.9.1 |