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
channel-list.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 University of Washington
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
19
#include "ns3/simulator.h"
20
#include "ns3/object-vector.h"
21
#include "ns3/config.h"
22
#include "ns3/log.h"
23
#include "ns3/assert.h"
24
#include "
channel-list.h
"
25
#include "
channel.h
"
26
27
namespace
ns3 {
28
29
NS_LOG_COMPONENT_DEFINE
(
"ChannelList"
);
30
34
class
ChannelListPriv
:
public
Object
35
{
36
public
:
37
static
TypeId
GetTypeId
(
void
);
38
ChannelListPriv
();
39
~ChannelListPriv
();
40
41
uint32_t
Add
(
Ptr<Channel>
channel);
42
43
ChannelList::Iterator
Begin
(
void
)
const
;
44
ChannelList::Iterator
End
(
void
)
const
;
45
46
Ptr<Channel>
GetChannel
(uint32_t n);
47
uint32_t
GetNChannels
(
void
);
48
49
static
Ptr<ChannelListPriv>
Get
(
void
);
50
51
private
:
52
static
Ptr<ChannelListPriv>
*
DoGet
(
void
);
53
static
void
Delete
(
void
);
54
virtual
void
DoDispose
(
void
);
55
std::vector<Ptr<Channel> >
m_channels
;
56
};
57
58
NS_OBJECT_ENSURE_REGISTERED
(
ChannelListPriv
);
59
60
TypeId
61
ChannelListPriv::GetTypeId
(
void
)
62
{
63
static
TypeId
tid =
TypeId
(
"ns3::ChannelListPriv"
)
64
.
SetParent
<
Object
> ()
65
.AddAttribute (
"ChannelList"
,
"The list of all channels created during the simulation."
,
66
ObjectVectorValue
(),
67
MakeObjectVectorAccessor
(&
ChannelListPriv::m_channels
),
68
MakeObjectVectorChecker<Channel> ())
69
;
70
return
tid;
71
}
72
73
Ptr<ChannelListPriv>
74
ChannelListPriv::Get
(
void
)
75
{
76
NS_LOG_FUNCTION_NOARGS
();
77
return
*
DoGet
();
78
}
79
80
Ptr<ChannelListPriv>
*
81
ChannelListPriv::DoGet
(
void
)
82
{
83
NS_LOG_FUNCTION_NOARGS
();
84
static
Ptr<ChannelListPriv>
ptr = 0;
85
if
(ptr == 0)
86
{
87
ptr = CreateObject<ChannelListPriv> ();
88
Config::RegisterRootNamespaceObject
(ptr);
89
Simulator::ScheduleDestroy
(&
ChannelListPriv::Delete
);
90
}
91
return
&ptr;
92
}
93
94
void
95
ChannelListPriv::Delete
(
void
)
96
{
97
NS_LOG_FUNCTION_NOARGS
();
98
Config::UnregisterRootNamespaceObject
(
Get
());
99
(*
DoGet
()) = 0;
100
}
101
102
ChannelListPriv::ChannelListPriv
()
103
{
104
NS_LOG_FUNCTION
(
this
);
105
}
106
107
ChannelListPriv::~ChannelListPriv
()
108
{
109
NS_LOG_FUNCTION
(
this
);
110
}
111
void
112
ChannelListPriv::DoDispose
(
void
)
113
{
114
NS_LOG_FUNCTION
(
this
);
115
for
(std::vector<
Ptr<Channel>
>::iterator i =
m_channels
.begin ();
116
i !=
m_channels
.end (); i++)
117
{
118
Ptr<Channel>
channel = *i;
119
channel->Dispose ();
120
*i = 0;
121
}
122
m_channels
.erase (
m_channels
.begin (),
m_channels
.end ());
123
Object::DoDispose
();
124
}
125
126
uint32_t
127
ChannelListPriv::Add
(
Ptr<Channel>
channel)
128
{
129
NS_LOG_FUNCTION
(
this
<< channel);
130
uint32_t index =
m_channels
.size ();
131
m_channels
.push_back (channel);
132
return
index;
133
134
}
135
136
ChannelList::Iterator
137
ChannelListPriv::Begin
(
void
)
const
138
{
139
NS_LOG_FUNCTION
(
this
);
140
return
m_channels
.begin ();
141
}
142
143
ChannelList::Iterator
144
ChannelListPriv::End
(
void
)
const
145
{
146
NS_LOG_FUNCTION
(
this
);
147
return
m_channels
.end ();
148
}
149
150
uint32_t
151
ChannelListPriv::GetNChannels
(
void
)
152
{
153
NS_LOG_FUNCTION
(
this
);
154
return
m_channels
.size ();
155
}
156
157
Ptr<Channel>
158
ChannelListPriv::GetChannel
(uint32_t n)
159
{
160
NS_LOG_FUNCTION
(
this
<< n);
161
NS_ASSERT_MSG
(n <
m_channels
.size (),
"Channel index "
<< n <<
162
" is out of range (only have "
<<
m_channels
.size () <<
" channels)."
);
163
return
m_channels
[n];
164
}
165
166
uint32_t
167
ChannelList::Add
(
Ptr<Channel>
channel)
168
{
169
NS_LOG_FUNCTION_NOARGS
();
170
return
ChannelListPriv::Get
()->Add (channel);
171
}
172
173
ChannelList::Iterator
174
ChannelList::Begin
(
void
)
175
{
176
NS_LOG_FUNCTION_NOARGS
();
177
return
ChannelListPriv::Get
()->Begin ();
178
}
179
180
ChannelList::Iterator
181
ChannelList::End
(
void
)
182
{
183
NS_LOG_FUNCTION_NOARGS
();
184
return
ChannelListPriv::Get
()->End ();
185
}
186
187
Ptr<Channel>
188
ChannelList::GetChannel
(uint32_t n)
189
{
190
NS_LOG_FUNCTION
(n);
191
return
ChannelListPriv::Get
()->GetChannel (n);
192
}
193
194
uint32_t
195
ChannelList::GetNChannels
(
void
)
196
{
197
NS_LOG_FUNCTION_NOARGS
();
198
return
ChannelListPriv::Get
()->GetNChannels ();
199
}
200
201
}
// namespace ns3
ns3::MakeObjectVectorAccessor
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberContainer)
Definition:
object-vector.h:51
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
ns3::ChannelList::GetNChannels
static uint32_t GetNChannels(void)
Definition:
channel-list.cc:195
ns3::ChannelListPriv::GetChannel
Ptr< Channel > GetChannel(uint32_t n)
Definition:
channel-list.cc:158
ns3::ChannelListPriv::ChannelListPriv
ChannelListPriv()
Definition:
channel-list.cc:102
ns3::ChannelListPriv::DoDispose
virtual void DoDispose(void)
Definition:
channel-list.cc:112
ns3::ChannelListPriv::Get
static Ptr< ChannelListPriv > Get(void)
Definition:
channel-list.cc:74
ns3::Object::DoDispose
virtual void DoDispose(void)
Definition:
object.cc:335
ns3::Config::UnregisterRootNamespaceObject
void UnregisterRootNamespaceObject(Ptr< Object > obj)
Definition:
config.cc:751
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Definition:
log.h:275
ns3::ChannelListPriv::GetNChannels
uint32_t GetNChannels(void)
Definition:
channel-list.cc:151
ns3::ChannelListPriv::DoGet
static Ptr< ChannelListPriv > * DoGet(void)
Definition:
channel-list.cc:81
channel-list.h
ns3::ChannelListPriv::m_channels
std::vector< Ptr< Channel > > m_channels
Definition:
channel-list.cc:55
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
channel.h
ns3::ChannelListPriv::Add
uint32_t Add(Ptr< Channel > channel)
Definition:
channel-list.cc:127
ns3::ChannelListPriv::End
ChannelList::Iterator End(void) const
Definition:
channel-list.cc:144
ns3::ChannelList::Iterator
std::vector< Ptr< Channel > >::const_iterator Iterator
Definition:
channel-list.h:41
ns3::ChannelList::Begin
static Iterator Begin(void)
Definition:
channel-list.cc:174
ns3::ChannelListPriv
private implementation detail of the ChannelList API.
Definition:
channel-list.cc:34
ns3::Config::RegisterRootNamespaceObject
void RegisterRootNamespaceObject(Ptr< Object > obj)
Definition:
config.cc:745
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
Definition:
assert.h:86
ns3::ChannelListPriv::Delete
static void Delete(void)
Definition:
channel-list.cc:95
ns3::NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("PacketLossCounter")
ns3::ChannelList::Add
static uint32_t Add(Ptr< Channel > channel)
Definition:
channel-list.cc:167
ns3::Simulator::ScheduleDestroy
static EventId ScheduleDestroy(MEM mem_ptr, OBJ obj)
Definition:
simulator.h:1076
ns3::ChannelList::End
static Iterator End(void)
Definition:
channel-list.cc:181
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:63
ns3::ObjectPtrContainerValue
contain a set of ns3::Object pointers.
Definition:
object-ptr-container.h:38
ns3::ChannelList::GetChannel
static Ptr< Channel > GetChannel(uint32_t n)
Definition:
channel-list.cc:188
ns3::ChannelListPriv::~ChannelListPriv
~ChannelListPriv()
Definition:
channel-list.cc:107
ns3::ChannelListPriv::GetTypeId
static TypeId GetTypeId(void)
Definition:
channel-list.cc:61
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::ChannelListPriv::Begin
ChannelList::Iterator Begin(void) const
Definition:
channel-list.cc:137
src
network
model
channel-list.cc
Generated on Sun Apr 20 2014 11:14:59 for ns-3 by
1.8.6