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
File Members
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
28
namespace
ns3
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"ListScheduler"
);
31
32
NS_OBJECT_ENSURE_REGISTERED
(ListScheduler);
33
34
TypeId
35
ListScheduler::GetTypeId
(
void
)
36
{
37
static
TypeId
tid =
TypeId
(
"ns3::ListScheduler"
)
38
.
SetParent
<
Scheduler
> ()
39
.AddConstructor<ListScheduler> ()
40
;
41
return
tid;
42
}
43
44
ListScheduler::ListScheduler
()
45
{
46
NS_LOG_FUNCTION
(
this
);
47
}
48
ListScheduler::~ListScheduler
()
49
{
50
}
51
52
void
53
ListScheduler::Insert
(
const
Event &ev)
54
{
55
NS_LOG_FUNCTION
(
this
<< &ev);
56
for
(
EventsI
i =
m_events
.begin (); i !=
m_events
.end (); i++)
57
{
58
if
(ev.key < i->key)
59
{
60
m_events
.insert (i, ev);
61
return
;
62
}
63
}
64
m_events
.push_back (ev);
65
}
66
bool
67
ListScheduler::IsEmpty
(
void
)
const
68
{
69
NS_LOG_FUNCTION
(
this
);
70
return
m_events
.empty ();
71
}
72
Scheduler::Event
73
ListScheduler::PeekNext
(
void
)
const
74
{
75
NS_LOG_FUNCTION
(
this
);
76
return
m_events
.front ();
77
}
78
79
Scheduler::Event
80
ListScheduler::RemoveNext
(
void
)
81
{
82
NS_LOG_FUNCTION
(
this
);
83
Event next =
m_events
.front ();
84
m_events
.pop_front ();
85
return
next;
86
}
87
88
void
89
ListScheduler::Remove
(
const
Event &ev)
90
{
91
NS_LOG_FUNCTION
(
this
<< &ev);
92
for
(
EventsI
i =
m_events
.begin (); i !=
m_events
.end (); i++)
93
{
94
if
(i->key.m_uid == ev.key.m_uid)
95
{
96
NS_ASSERT
(ev.impl == i->impl);
97
m_events
.erase (i);
98
return
;
99
}
100
}
101
NS_ASSERT
(
false
);
102
}
103
104
}
// namespace ns3
ns3::ListScheduler::EventsI
std::list< Event >::iterator EventsI
Definition:
list-scheduler.h:56
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:207
event-impl.h
ns3::EventImpl declarations.
ns3::ListScheduler::RemoveNext
virtual Event RemoveNext(void)
This method cannot be invoked if the list is empty.
Definition:
list-scheduler.cc:80
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:44
ns3::ListScheduler::Remove
virtual void Remove(const Event &ev)
Definition:
list-scheduler.cc:89
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:61
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::ListScheduler::PeekNext
virtual Event PeekNext(void) const
Definition:
list-scheduler.cc:73
ns3::ListScheduler::IsEmpty
virtual bool IsEmpty(void) const
Definition:
list-scheduler.cc:67
list-scheduler.h
assert.h
ns3::Scheduler
Maintain the event list.
Definition:
scheduler.h:66
ns3::ListScheduler::Insert
virtual void Insert(const Event &ev)
Definition:
list-scheduler.cc:53
ns3::Scheduler::Event
Scheduler event.
Definition:
scheduler.h:88
ns3::ListScheduler::GetTypeId
static TypeId GetTypeId(void)
Definition:
list-scheduler.cc:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ListScheduler::~ListScheduler
virtual ~ListScheduler()
Definition:
list-scheduler.cc:48
ns3::ListScheduler::m_events
Events m_events
Definition:
list-scheduler.h:57
log.h
Debug message logging.
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:51
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:631
ns3::ListScheduler::ListScheduler
ListScheduler()
Definition:
list-scheduler.cc:44
src
core
model
list-scheduler.cc
Generated on Thu Feb 5 2015 18:33:34 for ns-3 by
1.8.9.1