--- a/src/simulator/scheduler-heap.cc Mon Sep 04 15:24:05 2006 +0200
+++ b/src/simulator/scheduler-heap.cc Mon Sep 04 15:37:32 2006 +0200
@@ -145,7 +145,7 @@
}
bool
-SchedulerHeap::is_empty (void) const
+SchedulerHeap::real_is_empty (void) const
{
return (m_heap.size () == 1)?true:false;
}
@@ -192,7 +192,7 @@
EventId
-SchedulerHeap::insert (EventImpl *event, Scheduler::EventKey key)
+SchedulerHeap::real_insert (EventImpl *event, Scheduler::EventKey key)
{
m_heap.push_back (std::make_pair (event, key));
bottom_up ();
@@ -201,21 +201,18 @@
}
EventImpl *
-SchedulerHeap::peek_next (void) const
+SchedulerHeap::real_peek_next (void) const
{
- assert (!is_empty ());
return m_heap[root ()].first;
}
Scheduler::EventKey
-SchedulerHeap::peek_next_key (void) const
+SchedulerHeap::real_peek_next_key (void) const
{
- assert (!is_empty ());
return m_heap[root ()].second;
}
void
-SchedulerHeap::remove_next (void)
+SchedulerHeap::real_remove_next (void)
{
- assert (!is_empty ());
exch (root (), last ());
m_heap.pop_back ();
top_down ();
@@ -223,7 +220,7 @@
EventImpl *
-SchedulerHeap::remove (EventId id, Scheduler::EventKey *key)
+SchedulerHeap::real_remove (EventId id, Scheduler::EventKey *key)
{
EventImpl *ev = id.get_event_impl ();
uint32_t i = get_from_event (ev);
@@ -235,7 +232,7 @@
}
bool
-SchedulerHeap::is_valid (EventId id)
+SchedulerHeap::real_is_valid (EventId id)
{
EventImpl *ev = id.get_event_impl ();
uint32_t i = get_from_event (ev);
--- a/src/simulator/scheduler-heap.h Mon Sep 04 15:24:05 2006 +0200
+++ b/src/simulator/scheduler-heap.h Mon Sep 04 15:37:32 2006 +0200
@@ -35,14 +35,15 @@
SchedulerHeap ();
virtual ~SchedulerHeap ();
- virtual EventId insert (EventImpl *event, Scheduler::EventKey key);
- virtual bool is_empty (void) const;
- virtual EventImpl *peek_next (void) const;
- virtual Scheduler::EventKey peek_next_key (void) const;
- virtual void remove_next (void);
- virtual EventImpl *remove (EventId ev, Scheduler::EventKey *key);
- virtual bool is_valid (EventId id);
private:
+ virtual EventId real_insert (EventImpl *event, Scheduler::EventKey key);
+ virtual bool real_is_empty (void) const;
+ virtual EventImpl *real_peek_next (void) const;
+ virtual Scheduler::EventKey real_peek_next_key (void) const;
+ virtual void real_remove_next (void);
+ virtual EventImpl *real_remove (EventId ev, Scheduler::EventKey *key);
+ virtual bool real_is_valid (EventId id);
+
typedef std::vector<std::pair<EventImpl *, Scheduler::EventKey> > BinaryHeap;
inline void store_in_event (EventImpl *ev, uint32_t index) const;
uint32_t get_from_event (EventImpl *ev) const;
--- a/src/simulator/scheduler-list.cc Mon Sep 04 15:24:05 2006 +0200
+++ b/src/simulator/scheduler-list.cc Mon Sep 04 15:37:32 2006 +0200
@@ -60,7 +60,7 @@
EventId
-SchedulerList::insert (EventImpl *event, Scheduler::EventKey key)
+SchedulerList::real_insert (EventImpl *event, Scheduler::EventKey key)
{
Scheduler::EventKeyCompare compare;
for (EventsI i = m_events.begin (); i != m_events.end (); i++) {
@@ -73,31 +73,29 @@
return get_event_id (key, --(m_events.end ()));
}
bool
-SchedulerList::is_empty (void) const
+SchedulerList::real_is_empty (void) const
{
return m_events.empty ();
}
EventImpl *
-SchedulerList::peek_next (void) const
+SchedulerList::real_peek_next (void) const
{
- assert (!is_empty ());
return m_events.front ().first;
}
Scheduler::EventKey
-SchedulerList::peek_next_key (void) const
+SchedulerList::real_peek_next_key (void) const
{
- assert (!is_empty ());
return m_events.front ().second;
}
void
-SchedulerList::remove_next (void)
+SchedulerList::real_remove_next (void)
{
m_events.pop_front ();
}
EventImpl *
-SchedulerList::remove (EventId id, Scheduler::EventKey *key)
+SchedulerList::real_remove (EventId id, Scheduler::EventKey *key)
{
EventsI i = get_iterator (id);
*key = i->second;
@@ -109,7 +107,7 @@
}
bool
-SchedulerList::is_valid (EventId id)
+SchedulerList::real_is_valid (EventId id)
{
EventsI i = get_iterator (id);
Scheduler::EventKey key = i->second;
--- a/src/simulator/scheduler-list.h Mon Sep 04 15:24:05 2006 +0200
+++ b/src/simulator/scheduler-list.h Mon Sep 04 15:37:32 2006 +0200
@@ -37,14 +37,15 @@
SchedulerList ();
virtual ~SchedulerList ();
- virtual EventId insert (EventImpl *event, EventKey key);
- virtual bool is_empty (void) const;
- virtual EventImpl *peek_next (void) const;
- virtual Scheduler::EventKey peek_next_key (void) const;
- virtual void remove_next (void);
- virtual EventImpl *remove (EventId ev, Scheduler::EventKey *key);
- virtual bool is_valid (EventId id);
private:
+ virtual EventId real_insert (EventImpl *event, EventKey key);
+ virtual bool real_is_empty (void) const;
+ virtual EventImpl *real_peek_next (void) const;
+ virtual Scheduler::EventKey real_peek_next_key (void) const;
+ virtual void real_remove_next (void);
+ virtual EventImpl *real_remove (EventId ev, Scheduler::EventKey *key);
+ virtual bool real_is_valid (EventId id);
+
typedef std::list<std::pair<EventImpl*, EventKey> > Events;
typedef std::list<std::pair<EventImpl*, EventKey> >::iterator EventsI;
EventId get_event_id (Scheduler::EventKey key, EventsI i);
--- a/src/simulator/scheduler-map.cc Mon Sep 04 15:24:05 2006 +0200
+++ b/src/simulator/scheduler-map.cc Mon Sep 04 15:37:32 2006 +0200
@@ -61,7 +61,7 @@
}
EventId
-SchedulerMap::insert (EventImpl *event, Scheduler::EventKey key)
+SchedulerMap::real_insert (EventImpl *event, Scheduler::EventKey key)
{
std::pair<EventMapI,bool> result = m_list.insert (std::make_pair (key, event));
assert (result.second);
@@ -70,38 +70,34 @@
}
bool
-SchedulerMap::is_empty (void) const
+SchedulerMap::real_is_empty (void) const
{
return m_list.empty ();
}
EventImpl *
-SchedulerMap::peek_next (void) const
+SchedulerMap::real_peek_next (void) const
{
- assert (!is_empty ());
EventMapCI i = m_list.begin ();
assert (i != m_list.end ());
return (*i).second;
}
Scheduler::EventKey
-SchedulerMap::peek_next_key (void) const
+SchedulerMap::real_peek_next_key (void) const
{
- assert (!is_empty ());
EventMapCI i = m_list.begin ();
assert (i != m_list.end ());
return (*i).first;
}
void
-SchedulerMap::remove_next (void)
+SchedulerMap::real_remove_next (void)
{
- assert (!is_empty ());
m_list.erase (m_list.begin ());
}
EventImpl *
-SchedulerMap::remove (EventId id, Scheduler::EventKey *key)
+SchedulerMap::real_remove (EventId id, Scheduler::EventKey *key)
{
- assert (!is_empty ());
EventMapI i = get_from_event (id.get_event_impl ());
*key = i->first;
m_list.erase (i);
@@ -109,7 +105,7 @@
}
bool
-SchedulerMap::is_valid (EventId id)
+SchedulerMap::real_is_valid (EventId id)
{
EventMapI i = get_from_event (id.get_event_impl ());
Scheduler::EventKey key = i->first;
--- a/src/simulator/scheduler-map.h Mon Sep 04 15:24:05 2006 +0200
+++ b/src/simulator/scheduler-map.h Mon Sep 04 15:37:32 2006 +0200
@@ -36,14 +36,15 @@
SchedulerMap ();
virtual ~SchedulerMap ();
- virtual EventId insert (EventImpl *event, Scheduler::EventKey key);
- virtual bool is_empty (void) const;
- virtual EventImpl *peek_next (void) const;
- virtual Scheduler::EventKey peek_next_key (void) const;
- virtual void remove_next (void);
- virtual EventImpl *remove (EventId ev, Scheduler::EventKey *key);
- virtual bool is_valid (EventId id);
private:
+ virtual EventId real_insert (EventImpl *event, Scheduler::EventKey key);
+ virtual bool real_is_empty (void) const;
+ virtual EventImpl *real_peek_next (void) const;
+ virtual Scheduler::EventKey real_peek_next_key (void) const;
+ virtual void real_remove_next (void);
+ virtual EventImpl *real_remove (EventId ev, Scheduler::EventKey *key);
+ virtual bool real_is_valid (EventId id);
+
typedef std::map<Scheduler::EventKey, EventImpl*, Scheduler::EventKeyCompare> EventMap;
typedef std::map<Scheduler::EventKey, EventImpl*, Scheduler::EventKeyCompare>::iterator EventMapI;
typedef std::map<Scheduler::EventKey, EventImpl*, Scheduler::EventKeyCompare>::const_iterator EventMapCI;
--- a/src/simulator/scheduler.cc Mon Sep 04 15:24:05 2006 +0200
+++ b/src/simulator/scheduler.cc Mon Sep 04 15:37:32 2006 +0200
@@ -22,8 +22,9 @@
#include "scheduler.h"
#include <cassert>
+namespace ns3 {
-ns3::Scheduler::~Scheduler ()
+Scheduler::~Scheduler ()
{}
/* Note the invariants which this function must provide:
@@ -32,7 +33,7 @@
* - transitivity: f(x,y) and f(y,z) => f(x,z)
*/
bool
-ns3::Scheduler::EventKeyCompare::operator () (struct EventKey a, struct EventKey b)
+Scheduler::EventKeyCompare::operator () (struct EventKey a, struct EventKey b)
{
assert (a.m_uid != b.m_uid);
if (a.m_ns < b.m_ns) {
@@ -44,3 +45,45 @@
}
}
+
+EventId
+Scheduler::insert (EventImpl *event, struct EventKey key)
+{
+ return real_insert (event, key);
+}
+bool
+Scheduler::is_empty (void) const
+{
+ return real_is_empty ();
+}
+EventImpl *
+Scheduler::peek_next (void) const
+{
+ assert (!real_is_empty ());
+ return real_peek_next ();
+}
+Scheduler::EventKey
+Scheduler::peek_next_key (void) const
+{
+ assert (!real_is_empty ());
+ return real_peek_next_key ();
+}
+void
+Scheduler::remove_next (void)
+{
+ assert (!real_is_empty ());
+ return real_remove_next ();
+}
+EventImpl *
+Scheduler::remove (EventId id, EventKey *key)
+{
+ assert (!real_is_empty ());
+ return real_remove (id, key);
+}
+bool
+Scheduler::is_valid (EventId id)
+{
+ return real_is_valid (id);
+}
+
+}; // namespace ns3
--- a/src/simulator/scheduler.h Mon Sep 04 15:24:05 2006 +0200
+++ b/src/simulator/scheduler.h Mon Sep 04 15:37:32 2006 +0200
@@ -41,14 +41,23 @@
};
virtual ~Scheduler () = 0;
- virtual EventId insert (EventImpl *event, EventKey key) = 0;
- virtual bool is_empty (void) const = 0;
- virtual EventImpl *peek_next (void) const = 0;
- virtual EventKey peek_next_key (void) const = 0;
- virtual void remove_next (void) = 0;
- virtual EventImpl *remove (EventId id, EventKey *key) = 0;
- virtual bool is_valid (EventId id) = 0;
+
+ EventId insert (EventImpl *event, EventKey key);
+ bool is_empty (void) const;
+ EventImpl *peek_next (void) const;
+ Scheduler::EventKey peek_next_key (void) const ;
+ void remove_next (void);
+ EventImpl *remove (EventId id, EventKey *key);
+ bool is_valid (EventId id);
+private:
+ virtual EventId real_insert (EventImpl *event, EventKey key) = 0;
+ virtual bool real_is_empty (void) const = 0;
+ virtual EventImpl *real_peek_next (void) const = 0;
+ virtual Scheduler::EventKey real_peek_next_key (void) const = 0;
+ virtual void real_remove_next (void) = 0;
+ virtual EventImpl *real_remove (EventId id, EventKey *key) = 0;
+ virtual bool real_is_valid (EventId id) = 0;
};
}; // namespace ns3