A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
list-scheduler.cc
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#include "list-scheduler.h"
22
#include "event-impl.h"
23
#include "log.h"
24
#include <utility>
25
#include <string>
26
#include "assert.h"
27
28
NS_LOG_COMPONENT_DEFINE
(
"ListScheduler"
);
29
30
namespace
ns3 {
31
32
33
NS_OBJECT_ENSURE_REGISTERED (ListScheduler);
34
35
TypeId
36
ListScheduler::GetTypeId (
void
)
37
{
38
static
TypeId tid = TypeId (
"ns3::ListScheduler"
)
39
.SetParent<Scheduler> ()
40
.AddConstructor<ListScheduler> ()
41
;
42
return
tid;
43
}
44
45
ListScheduler::ListScheduler ()
46
{
47
NS_LOG_FUNCTION
(
this
);
48
}
49
ListScheduler::~ListScheduler ()
50
{
51
}
52
53
void
54
ListScheduler::Insert
(
const
Event
&ev)
55
{
56
NS_LOG_FUNCTION
(
this
<< &ev);
57
for
(EventsI i = m_events.begin (); i != m_events.end (); i++)
58
{
59
if
(ev.key < i->key)
60
{
61
m_events.insert (i, ev);
62
return
;
63
}
64
}
65
m_events.push_back (ev);
66
}
67
bool
68
ListScheduler::IsEmpty
(
void
)
const
69
{
70
NS_LOG_FUNCTION
(
this
);
71
return
m_events.empty ();
72
}
73
Scheduler::Event
74
ListScheduler::PeekNext
(
void
)
const
75
{
76
NS_LOG_FUNCTION
(
this
);
77
return
m_events.front ();
78
}
79
80
Scheduler::Event
81
ListScheduler::RemoveNext
(
void
)
82
{
83
NS_LOG_FUNCTION
(
this
);
84
Event
next = m_events.front ();
85
m_events.pop_front ();
86
return
next;
87
}
88
89
void
90
ListScheduler::Remove
(
const
Event
&ev)
91
{
92
NS_LOG_FUNCTION
(
this
<< &ev);
93
for
(EventsI i = m_events.begin (); i != m_events.end (); i++)
94
{
95
if
(i->key.m_uid == ev.key.m_uid)
96
{
97
NS_ASSERT
(ev.impl == i->impl);
98
m_events.erase (i);
99
return
;
100
}
101
}
102
NS_ASSERT
(
false
);
103
}
104
105
}
// namespace ns3
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
ns3::ListScheduler::RemoveNext
virtual Event RemoveNext(void)
Definition:
list-scheduler.cc:81
ns3::ListScheduler::Remove
virtual void Remove(const Event &ev)
Definition:
list-scheduler.cc:90
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
ns3::ListScheduler::PeekNext
virtual Event PeekNext(void) const
Definition:
list-scheduler.cc:74
ns3::ListScheduler::IsEmpty
virtual bool IsEmpty(void) const
Definition:
list-scheduler.cc:68
ns3::ListScheduler::Insert
virtual void Insert(const Event &ev)
Definition:
list-scheduler.cc:54
ns3::Scheduler::Event
Definition:
scheduler.h:64
src
core
model
list-scheduler.cc
Generated on Sun Mar 16 2014 11:25:02 for ns-3 by
1.8.6