A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
list-scheduler.cc
Go to the documentation of this file.
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
34
namespace
ns3
{
35
36
NS_LOG_COMPONENT_DEFINE
(
"ListScheduler"
);
37
38
NS_OBJECT_ENSURE_REGISTERED
(ListScheduler);
39
40
TypeId
41
ListScheduler::GetTypeId
(
void
)
42
{
43
static
TypeId
tid =
TypeId
(
"ns3::ListScheduler"
)
44
.
SetParent
<
Scheduler
> ()
45
.SetGroupName (
"Core"
)
46
.AddConstructor<
ListScheduler
> ()
47
;
48
return
tid;
49
}
50
51
ListScheduler::ListScheduler
()
52
{
53
NS_LOG_FUNCTION
(
this
);
54
}
55
ListScheduler::~ListScheduler
()
56
{}
57
58
void
59
ListScheduler::Insert
(
const
Event
&ev)
60
{
61
NS_LOG_FUNCTION
(
this
<< &ev);
62
for
(
EventsI
i =
m_events
.begin (); i !=
m_events
.end (); i++)
63
{
64
if
(ev.
key
< i->key)
65
{
66
m_events
.insert (i, ev);
67
return
;
68
}
69
}
70
m_events
.push_back (ev);
71
}
72
bool
73
ListScheduler::IsEmpty
(
void
)
const
74
{
75
NS_LOG_FUNCTION
(
this
);
76
return
m_events
.empty ();
77
}
78
Scheduler::Event
79
ListScheduler::PeekNext
(
void
)
const
80
{
81
NS_LOG_FUNCTION
(
this
);
82
return
m_events
.front ();
83
}
84
85
Scheduler::Event
86
ListScheduler::RemoveNext
(
void
)
87
{
88
NS_LOG_FUNCTION
(
this
);
89
Event
next =
m_events
.front ();
90
m_events
.pop_front ();
91
return
next;
92
}
93
94
void
95
ListScheduler::Remove
(
const
Event
&ev)
96
{
97
NS_LOG_FUNCTION
(
this
<< &ev);
98
for
(
EventsI
i =
m_events
.begin (); i !=
m_events
.end (); i++)
99
{
100
if
(i->key.m_uid == ev.
key
.
m_uid
)
101
{
102
NS_ASSERT
(ev.
impl
== i->impl);
103
m_events
.erase (i);
104
return
;
105
}
106
}
107
NS_ASSERT
(
false
);
108
}
109
110
}
// namespace ns3
assert.h
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
ns3::ListScheduler
a std::list event scheduler
Definition:
list-scheduler.h:65
ns3::ListScheduler::Insert
virtual void Insert(const Scheduler::Event &ev)
Insert a new Event in the schedule.
Definition:
list-scheduler.cc:59
ns3::ListScheduler::RemoveNext
virtual Scheduler::Event RemoveNext(void)
Remove the earliest event from the event list.
Definition:
list-scheduler.cc:86
ns3::ListScheduler::~ListScheduler
virtual ~ListScheduler()
Destructor.
Definition:
list-scheduler.cc:55
ns3::ListScheduler::PeekNext
virtual Scheduler::Event PeekNext(void) const
Get a pointer to the next event.
Definition:
list-scheduler.cc:79
ns3::ListScheduler::EventsI
std::list< Scheduler::Event >::iterator EventsI
Events iterator.
Definition:
list-scheduler.h:89
ns3::ListScheduler::IsEmpty
virtual bool IsEmpty(void) const
Test if the schedule is empty.
Definition:
list-scheduler.cc:73
ns3::ListScheduler::ListScheduler
ListScheduler()
Constructor.
Definition:
list-scheduler.cc:51
ns3::ListScheduler::m_events
Events m_events
The event list.
Definition:
list-scheduler.h:92
ns3::ListScheduler::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition:
list-scheduler.cc:41
ns3::ListScheduler::Remove
virtual void Remove(const Scheduler::Event &ev)
Remove a specific event from the event list.
Definition:
list-scheduler.cc:95
ns3::Scheduler
Maintain the event list.
Definition:
scheduler.h:156
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:922
event-impl.h
ns3::EventImpl declarations.
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition:
assert.h:67
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
list-scheduler.h
ns3::ListScheduler declaration.
log.h
Debug message logging.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Scheduler::Event
Scheduler event.
Definition:
scheduler.h:182
ns3::Scheduler::Event::key
EventKey key
Key for sorting and ordering Events.
Definition:
scheduler.h:184
ns3::Scheduler::Event::impl
EventImpl * impl
Pointer to the event implementation.
Definition:
scheduler.h:183
ns3::Scheduler::EventKey::m_uid
uint32_t m_uid
Event unique id.
Definition:
scheduler.h:171
src
core
model
list-scheduler.cc
Generated on Tue Feb 6 2024 19:21:16 for ns-3 by
1.9.1