src/core/model/list-scheduler.cc
changeset 9134 7a750f032acd
parent 7383 c5e131450339
child 9138 967a214aeb54
equal deleted inserted replaced
9133:bcf7cef191c1 9134:7a750f032acd
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    19  */
    19  */
    20 
    20 
    21 #include "list-scheduler.h"
    21 #include "list-scheduler.h"
    22 #include "event-impl.h"
    22 #include "event-impl.h"
       
    23 #include "log.h"
    23 #include <utility>
    24 #include <utility>
    24 #include <string>
    25 #include <string>
    25 #include "assert.h"
    26 #include "assert.h"
       
    27 
       
    28 NS_LOG_COMPONENT_DEFINE ("ListScheduler");
    26 
    29 
    27 namespace ns3 {
    30 namespace ns3 {
    28 
    31 
    29 
    32 
    30 NS_OBJECT_ENSURE_REGISTERED (ListScheduler);
    33 NS_OBJECT_ENSURE_REGISTERED (ListScheduler);
    31 
    34 
    32 TypeId
    35 TypeId
    33 ListScheduler::GetTypeId (void)
    36 ListScheduler::GetTypeId (void)
    34 {
    37 {
       
    38   NS_LOG_FUNCTION_NOARGS ();
    35   static TypeId tid = TypeId ("ns3::ListScheduler")
    39   static TypeId tid = TypeId ("ns3::ListScheduler")
    36     .SetParent<Scheduler> ()
    40     .SetParent<Scheduler> ()
    37     .AddConstructor<ListScheduler> ()
    41     .AddConstructor<ListScheduler> ()
    38   ;
    42   ;
    39   return tid;
    43   return tid;
    40 }
    44 }
    41 
    45 
    42 ListScheduler::ListScheduler ()
    46 ListScheduler::ListScheduler ()
    43 {
    47 {
       
    48   NS_LOG_FUNCTION (this);
    44 }
    49 }
    45 ListScheduler::~ListScheduler ()
    50 ListScheduler::~ListScheduler ()
    46 {
    51 {
    47 }
    52 }
    48 
    53 
    49 void
    54 void
    50 ListScheduler::Insert (const Event &ev)
    55 ListScheduler::Insert (const Event &ev)
    51 {
    56 {
       
    57   NS_LOG_FUNCTION (this << &ev);
    52   for (EventsI i = m_events.begin (); i != m_events.end (); i++)
    58   for (EventsI i = m_events.begin (); i != m_events.end (); i++)
    53     {
    59     {
    54       if (ev.key < i->key)
    60       if (ev.key < i->key)
    55         {
    61         {
    56           m_events.insert (i, ev);
    62           m_events.insert (i, ev);
    60   m_events.push_back (ev);
    66   m_events.push_back (ev);
    61 }
    67 }
    62 bool
    68 bool
    63 ListScheduler::IsEmpty (void) const
    69 ListScheduler::IsEmpty (void) const
    64 {
    70 {
       
    71   NS_LOG_FUNCTION (this);
    65   return m_events.empty ();
    72   return m_events.empty ();
    66 }
    73 }
    67 Scheduler::Event
    74 Scheduler::Event
    68 ListScheduler::PeekNext (void) const
    75 ListScheduler::PeekNext (void) const
    69 {
    76 {
       
    77   NS_LOG_FUNCTION (this);
    70   return m_events.front ();
    78   return m_events.front ();
    71 }
    79 }
    72 
    80 
    73 Scheduler::Event
    81 Scheduler::Event
    74 ListScheduler::RemoveNext (void)
    82 ListScheduler::RemoveNext (void)
    75 {
    83 {
       
    84   NS_LOG_FUNCTION (this);
    76   Event next = m_events.front ();
    85   Event next = m_events.front ();
    77   m_events.pop_front ();
    86   m_events.pop_front ();
    78   return next;
    87   return next;
    79 }
    88 }
    80 
    89 
    81 void
    90 void
    82 ListScheduler::Remove (const Event &ev)
    91 ListScheduler::Remove (const Event &ev)
    83 {
    92 {
       
    93   NS_LOG_FUNCTION (this << &ev);
    84   for (EventsI i = m_events.begin (); i != m_events.end (); i++)
    94   for (EventsI i = m_events.begin (); i != m_events.end (); i++)
    85     {
    95     {
    86       if (i->key.m_uid == ev.key.m_uid)
    96       if (i->key.m_uid == ev.key.m_uid)
    87         {
    97         {
    88           NS_ASSERT (ev.impl == i->impl);
    98           NS_ASSERT (ev.impl == i->impl);