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
bridge-channel.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License version 2 as
5
* published by the Free Software Foundation;
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
*
16
* Author: Gustavo Carneiro <gjc@inescporto.pt>
17
*/
18
19
#include "ns3/log.h"
20
#include "
bridge-channel.h
"
21
22
NS_LOG_COMPONENT_DEFINE
(
"BridgeChannel"
);
23
24
namespace
ns3 {
25
26
NS_OBJECT_ENSURE_REGISTERED
(BridgeChannel);
27
28
TypeId
29
BridgeChannel::GetTypeId
(
void
)
30
{
31
static
TypeId
tid =
TypeId
(
"ns3::BridgeChannel"
)
32
.
SetParent
<
Channel
> ()
33
.AddConstructor<BridgeChannel> ()
34
;
35
return
tid;
36
}
37
38
BridgeChannel::BridgeChannel
()
39
:
Channel
()
40
{
41
NS_LOG_FUNCTION_NOARGS
();
42
}
43
44
BridgeChannel::~BridgeChannel
()
45
{
46
NS_LOG_FUNCTION_NOARGS
();
47
48
for
(std::vector<
Ptr<Channel>
>::iterator iter =
m_bridgedChannels
.begin ();
49
iter !=
m_bridgedChannels
.end (); iter++)
50
{
51
*iter = 0;
52
}
53
m_bridgedChannels
.clear ();
54
}
55
56
57
void
58
BridgeChannel::AddChannel
(
Ptr<Channel>
bridgedChannel)
59
{
60
m_bridgedChannels
.push_back (bridgedChannel);
61
}
62
63
uint32_t
64
BridgeChannel::GetNDevices
(
void
)
const
65
{
66
uint32_t ndevices = 0;
67
for
(std::vector<
Ptr<Channel>
>::const_iterator iter =
m_bridgedChannels
.begin ();
68
iter !=
m_bridgedChannels
.end (); iter++)
69
{
70
ndevices += (*iter)->GetNDevices ();
71
}
72
return
ndevices;
73
}
74
75
76
Ptr<NetDevice>
77
BridgeChannel::GetDevice
(uint32_t i)
const
78
{
79
uint32_t ndevices = 0;
80
for
(std::vector<
Ptr<Channel>
>::const_iterator iter =
m_bridgedChannels
.begin ();
81
iter !=
m_bridgedChannels
.end (); iter++)
82
{
83
if
((i - ndevices) < (*iter)->GetNDevices ())
84
{
85
return
(*iter)->GetDevice (i - ndevices);
86
}
87
ndevices += (*iter)->GetNDevices ();
88
}
89
return
NULL;
90
}
91
92
93
}
// namespace ns3
ns3::BridgeChannel::AddChannel
void AddChannel(Ptr< Channel > bridgedChannel)
Definition:
bridge-channel.cc:58
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::Channel
Abstract Channel Base Class.
Definition:
channel.h:43
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Definition:
log.h:275
ns3::BridgeChannel::BridgeChannel
BridgeChannel()
Definition:
bridge-channel.cc:38
ns3::BridgeChannel::GetTypeId
static TypeId GetTypeId(void)
Definition:
bridge-channel.cc:29
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("BridgeChannel")
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
bridge-channel.h
ns3::BridgeChannel::m_bridgedChannels
std::vector< Ptr< Channel > > m_bridgedChannels
Definition:
bridge-channel.h:54
ns3::BridgeChannel::~BridgeChannel
virtual ~BridgeChannel()
Definition:
bridge-channel.cc:44
ns3::BridgeChannel::GetNDevices
virtual uint32_t GetNDevices(void) const
Definition:
bridge-channel.cc:64
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::BridgeChannel::GetDevice
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
Definition:
bridge-channel.cc:77
src
bridge
model
bridge-channel.cc
Generated on Sun Apr 20 2014 11:14:45 for ns-3 by
1.8.6