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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
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
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::ListScheduler::RemoveNext
virtual Event RemoveNext(void)
This method cannot be invoked if the list is empty.
Definition:
list-scheduler.cc:81
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition:
object-base.h:38
ns3::ListScheduler::Remove
virtual void Remove(const Event &ev)
Definition:
list-scheduler.cc:90
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:170
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
list-scheduler.h
assert.h
ns3::Scheduler
Maintain the event list.
Definition:
scheduler.h:58
ns3::ListScheduler::Insert
virtual void Insert(const Event &ev)
Definition:
list-scheduler.cc:54
ns3::Scheduler::Event
Definition:
scheduler.h:71
ns3::ListScheduler::GetTypeId
static TypeId GetTypeId(void)
Definition:
list-scheduler.cc:36
ns3::ListScheduler::~ListScheduler
virtual ~ListScheduler()
Definition:
list-scheduler.cc:49
ns3::ListScheduler::m_events
Events m_events
Definition:
list-scheduler.h:57
log.h
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:610
ns3::ListScheduler::ListScheduler
ListScheduler()
Definition:
list-scheduler.cc:45
src
core
model
list-scheduler.cc
Generated on Wed Sep 17 2014 23:33:22 for ns-3 by
1.8.6