Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

TimerEvent.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_TimerEvent_h_
00003 #define INCLUDED_TimerEvent_h_
00004 
00005 #include "Events/EventBase.h"
00006 
00007 class EventListener;
00008 
00009 //! Adds a target field to EventBase so listeners can resolve source ID conflict between different behaviors
00010 /*! See EventRouter's class documentation for discussion of how to request
00011  *  and use timers. */
00012 class TimerEvent : public EventBase {
00013 public:
00014   //! empty constructor, initializes #target to NULL
00015   TimerEvent() : EventBase(), target(NULL) {}
00016   //! the full specification constructor, pass original requester @a tgt, generator @a gid (probably should always be EventBase::timerEGID), source @a sid, type @a tid (typically EventBase::statusETID), and duration @a dur
00017   TimerEvent(EventListener * tgt, EventGeneratorID_t gid, size_t sid, EventTypeID_t tid, unsigned int dur=0) : EventBase(gid,sid,tid,dur), target(tgt) {}
00018   //! copy constructor, does a shallow copy (copies pointer value, doesn't try to clone #target!)
00019   TimerEvent(const TimerEvent& te) : EventBase(te), target(te.target) {}
00020   //! assignment operator, does a shallow copy (copies pointer value, doesn't try to clone #target!)
00021   TimerEvent& operator=(const TimerEvent& te) { target=te.target; EventBase::operator=(te); return *this; }
00022 
00023   virtual EventBase* clone() const { return new TimerEvent(*this); }
00024   
00025   virtual unsigned int getClassTypeID() const { return autoRegisterTimerEvent; }
00026   
00027   EventListener * getTarget() const { return target; } //!< returns #target
00028   void setTarget(EventListener* tgt) { target=tgt; } //!< assigns @a tgt to #target
00029 
00030   std::string getDescription(bool showTypeSpecific=true, unsigned int verbosity=0) const;
00031   
00032   virtual unsigned int getBinSize() const;
00033   virtual unsigned int loadBinaryBuffer(const char buf[], unsigned int len);
00034   virtual unsigned int saveBinaryBuffer(char buf[], unsigned int len) const;
00035   virtual void loadXML(xmlNode* node);
00036   virtual void saveXML(xmlNode * node) const;
00037     
00038 protected:
00039   EventListener * target; //!< indicates the listener for which the timer was created
00040 
00041   //! causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())
00042   static const EventBase::classTypeID_t autoRegisterTimerEvent;
00043 };
00044 
00045 /*! @file
00046  * @brief 
00047  * @author Ethan Tira-Thompson (ejt) (Creator)
00048  */
00049 
00050 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:52 2016 by Doxygen 1.6.3