Homepage Demos Overview Downloads Tutorials Reference
Credits

EventGeneratorBase.h

Go 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()
00026     : BehaviorBase(), myGenID(EventBase::unknownEGID), mySourceID(0), autoListen(false), srcGenID(EventBase::unknownEGID), srcSourceID(0), myName()
00027   {}
00028   EventGeneratorBase(const std::string& name, EventBase::EventGeneratorID_t mgid, unsigned int msid)
00029     : BehaviorBase(), myGenID(mgid), mySourceID(msid), autoListen(false), srcGenID(EventBase::unknownEGID), srcSourceID(0), myName(name)
00030   {}
00031   EventGeneratorBase(const std::string& name, EventBase::EventGeneratorID_t mgid, unsigned int msid,EventBase::EventGeneratorID_t srcgid, unsigned int srcsid)
00032     : BehaviorBase(), myGenID(mgid), mySourceID(msid), autoListen(true), srcGenID(srcgid), srcSourceID(srcsid), myName(name)
00033   {}
00034   //@}
00035 
00036   //! destructor - does nothing
00037   virtual ~EventGeneratorBase() {}
00038   
00039   virtual void DoStart();
00040   
00041   virtual void DoStop();
00042   
00043   //! return the generator ID that will be broadcast from
00044   virtual EventBase::EventGeneratorID_t getGeneratorID() { return myGenID; }
00045   //! set the generator ID that will be broadcast from (typically it's a bad idea to call this...)
00046   virtual void setGeneratorID(EventBase::EventGeneratorID_t gid) { myGenID=gid; }
00047 
00048   //! return the source ID that will be broadcast on
00049   virtual unsigned int getSourceID() { return mySourceID; }
00050   //! set the source ID that will be broadcast on
00051   virtual void setSourceID(unsigned int sid) { mySourceID=sid; }
00052 
00053   //! returns the source ID that will be listened for (not the source of the FilterBankEvent to be created - that depends on the subclass)
00054   virtual unsigned int getListenSourceID() const { return srcSourceID; }
00055   //! returns the generator ID that will be listened for (not the generator of the FilterBankEvent to be created - that depends on the subclass)
00056   virtual EventBase::EventGeneratorID_t getListenGeneratorID() const { return srcGenID; }
00057   //! turns on auto listening to make it easier to set up dependancies between vision filters
00058   virtual void setAutoListen(EventBase::EventGeneratorID_t gid, unsigned int sid) { autoListen=true; srcGenID=gid; srcSourceID=sid; }
00059 
00060   //! turns off auto listening
00061   virtual void unsetAutoListen() { autoListen=false; }
00062 
00063   //! returns current name
00064   virtual std::string getName() const {
00065     return myName;
00066   }
00067 
00068   //! sets a name (overriding automatically generated one)
00069   virtual void setName(const std::string& name) {
00070     myName=name;
00071   }
00072 
00073 protected:
00074   EventBase::EventGeneratorID_t myGenID; //!< the generator ID to broadcast on
00075   unsigned int mySourceID;     //!< the source ID to broadcast on
00076   bool autoListen;          //!< if true, will automatically start listening for EventBase(genID,sourceID) events
00077   EventBase::EventGeneratorID_t srcGenID; //!< the generator ID to listen for (typically the source that this filter works on)
00078   unsigned int srcSourceID;    //!< the source ID to listen for
00079   std::string myName;  //!< the name to report (handy for debugging output)
00080 };
00081 
00082 /*! @file
00083  * @brief 
00084  * @author ejt (Creator)
00085  *
00086  * $Author: ejt $
00087  * $Name: tekkotsu-2_1 $
00088  * $Revision: 1.5 $
00089  * $State: Exp $
00090  * $Date: 2004/02/18 21:12:18 $
00091  */
00092 
00093 #endif

Tekkotsu v2.1
Generated Tue Mar 16 23:19:13 2004 by Doxygen 1.3.5