TimedEventService.h

00001 #ifndef ERIS_TIMED_EVENT_SERVICE_H
00002 #define ERIS_TIMED_EVENT_SERVICE_H
00003 
00004 #include <wfmath/timestamp.h>
00005 #include <Eris/Types.h>
00006 
00007 namespace Eris
00008 {
00009 
00013 class TimedEvent
00014 {
00015 public:
00016     virtual ~TimedEvent()
00017     {
00018     }
00019     
00026     virtual void expired() = 0;
00027     
00031     virtual const WFMath::TimeStamp& due() const = 0;
00032 };
00033 
00034 class EventsByDueOrdering
00035 {
00036 public:
00037     bool operator()(const TimedEvent* a, const TimedEvent* b) const
00038     {
00039         return a->due() < b->due();
00040     }
00041 };
00042 
00043 class TimedEventService
00044 {
00045 public:
00046 
00047     static TimedEventService* instance();
00048 
00053     unsigned long tick();
00054 
00057     void registerEvent(TimedEvent* te);
00058 
00061     void unregisterEvent(TimedEvent* te);
00062 private:
00063     TimedEventService();
00064     
00065     static TimedEventService* static_instance;
00066     
00067     typedef std::set<TimedEvent*, EventsByDueOrdering> TimedEventsByDue;
00068     TimedEventsByDue m_events;
00069 };
00070 
00071 } // of namespace Eris
00072 
00073 #endif // of ERIS_TIMED_EVENT_SERVICE_H

Generated on Sun Aug 19 18:51:26 2007 for Eris by  doxygen 1.5.2