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
36
TypeId
37
ListScheduler::GetTypeId
(
void
)
38
{
39
static
TypeId
tid =
TypeId
(
"ns3::ListScheduler"
)
40
.
SetParent
<
Scheduler
> ()
41
.AddConstructor<ListScheduler> ()
42
;
43
return
tid;
44
}
45
46
ListScheduler::ListScheduler
()
47
{
48
NS_LOG_FUNCTION
(
this
);
49
}
50
ListScheduler::~ListScheduler
()
51
{
52
}
53
54
void
55
ListScheduler::Insert
(
const
Event
&ev)
56
{
57
NS_LOG_FUNCTION
(
this
<< &ev);
58
for
(
EventsI
i =
m_events
.begin (); i !=
m_events
.end (); i++)
59
{
60
if
(ev.
key
< i->key)
61
{
62
m_events
.insert (i, ev);
63
return
;
64
}
65
}
66
m_events
.push_back (ev);
67
}
68
bool
69
ListScheduler::IsEmpty
(
void
)
const
70
{
71
NS_LOG_FUNCTION
(
this
);
72
return
m_events
.empty ();
73
}
74
Scheduler::Event
75
ListScheduler::PeekNext
(
void
)
const
76
{
77
NS_LOG_FUNCTION
(
this
);
78
return
m_events
.front ();
79
}
80
81
Scheduler::Event
82
ListScheduler::RemoveNext
(
void
)
83
{
84
NS_LOG_FUNCTION
(
this
);
85
Event
next =
m_events
.front ();
86
m_events
.pop_front ();
87
return
next;
88
}
89
90
void
91
ListScheduler::Remove
(
const
Event
&ev)
92
{
93
NS_LOG_FUNCTION
(
this
<< &ev);
94
for
(
EventsI
i =
m_events
.begin (); i !=
m_events
.end (); i++)
95
{
96
if
(i->key.m_uid == ev.
key
.
m_uid
)
97
{
98
NS_ASSERT
(ev.
impl
== i->impl);
99
m_events
.erase (i);
100
return
;
101
}
102
}
103
NS_ASSERT
(
false
);
104
}
105
106
}
// namespace ns3
ns3::ListScheduler::EventsI
std::list< Event >::iterator EventsI
Definition:
list-scheduler.h:56
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
event-impl.h
ns3::ListScheduler::RemoveNext
virtual Event RemoveNext(void)
This method cannot be invoked if the list is empty.
Definition:
list-scheduler.cc:82
ns3::ListScheduler::Remove
virtual void Remove(const Event &ev)
Definition:
list-scheduler.cc:91
ns3::Scheduler::Event::impl
EventImpl * impl
Definition:
scheduler.h:72
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
ns3::ListScheduler::PeekNext
virtual Event PeekNext(void) const
Definition:
list-scheduler.cc:75
ns3::ListScheduler::IsEmpty
virtual bool IsEmpty(void) const
Definition:
list-scheduler.cc:69
list-scheduler.h
ns3::Scheduler::Event::key
EventKey key
Definition:
scheduler.h:73
ns3::Scheduler::EventKey::m_uid
uint32_t m_uid
Definition:
scheduler.h:66
assert.h
ns3::Scheduler
Maintain the event list.
Definition:
scheduler.h:57
ns3::ListScheduler::Insert
virtual void Insert(const Event &ev)
Definition:
list-scheduler.cc:55
ns3::Scheduler::Event
Definition:
scheduler.h:70
ns3::ListScheduler::GetTypeId
static TypeId GetTypeId(void)
Definition:
list-scheduler.cc:37
ns3::ListScheduler::~ListScheduler
virtual ~ListScheduler()
Definition:
list-scheduler.cc:50
ns3::ListScheduler::m_events
Events m_events
Definition:
list-scheduler.h:57
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("ListScheduler")
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:611
ns3::ListScheduler::ListScheduler
ListScheduler()
Definition:
list-scheduler.cc:46
src
core
model
list-scheduler.cc
Generated on Sat Apr 19 2014 14:06:51 for ns-3 by
1.8.6