00001
00002
00003
00004
00005 #ifndef _EVENTQUEUE_H
00006 #define _EVENTQUEUE_H
00007
00008 #include <deque>
00009 #include <map>
00010 #include <queue>
00011 #include <boost/random.hpp>
00012 #include <boost/shared_ptr.hpp>
00013 #include <boost/bind.hpp>
00014 #include <boost/function.hpp>
00015
00016 #include "../YansCore/Types.h"
00017 #include "../YansCore/Event.h"
00018
00019 namespace YansCoreNS
00020 {
00023 typedef std::pair<Time, boost::shared_ptr<Event const> > TimedEvent;
00024
00029 class EventQueue
00030 {
00034 typedef std::pair<Time, size_t> QueueIndex;
00035
00037 typedef std::map<QueueIndex, boost::shared_ptr<Event const> > Queue;
00038
00039 public:
00045 explicit EventQueue (RandomNumberGenerator & rng);
00046
00049 ~EventQueue (void);
00050
00058 void AddEvent (Time time,
00059 boost::shared_ptr<Event> event);
00060
00074 bool RemoveEvent (Time time,
00075 boost::shared_ptr<Event const> event);
00076
00091 bool RemoveEvent (boost::shared_ptr<Event const> event);
00092
00108 TimedEvent GetNextEvent (void);
00109
00110 private:
00115 EventQueue (EventQueue const &);
00116
00117 Queue queue;
00118 RandomNumberGenerator & rng;
00119 Event::EventID currentEventId;
00120 };
00121
00125 typedef boost::function<void (Time, boost::shared_ptr<Event>)> ScheduleEventFunction;
00126 }
00127
00128 #endif
00129