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
topology-reader.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Universita' di Firenze, Italy
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: Tommaso Pecorella (tommaso.pecorella@unifi.it)
19
* Author: Valerio Sartini (valesar@gmail.com)
20
*/
21
22
#include "ns3/log.h"
23
24
#include "
topology-reader.h
"
25
26
27
namespace
ns3 {
28
29
NS_LOG_COMPONENT_DEFINE
(
"TopologyReader"
);
30
31
NS_OBJECT_ENSURE_REGISTERED
(TopologyReader);
32
33
TypeId
TopologyReader::GetTypeId
(
void
)
34
{
35
static
TypeId
tid =
TypeId
(
"ns3::TopologyReader"
)
36
.
SetParent
<
Object
> ()
37
;
38
return
tid;
39
}
40
41
TopologyReader::TopologyReader
()
42
{
43
NS_LOG_FUNCTION
(
this
);
44
}
45
46
TopologyReader::~TopologyReader
()
47
{
48
NS_LOG_FUNCTION
(
this
);
49
}
50
51
void
52
TopologyReader::SetFileName
(
const
std::string &fileName)
53
{
54
m_fileName
= fileName;
55
}
56
57
std::string
58
TopologyReader::GetFileName
()
const
59
{
60
return
m_fileName
;
61
}
62
63
/* Manipulating the address block */
64
65
TopologyReader::ConstLinksIterator
66
TopologyReader::LinksBegin
(
void
)
const
67
{
68
return
m_linksList
.begin ();
69
}
70
71
TopologyReader::ConstLinksIterator
72
TopologyReader::LinksEnd
(
void
)
const
73
{
74
return
m_linksList
.end ();
75
}
76
77
int
78
TopologyReader::LinksSize
(
void
)
const
79
{
80
return
m_linksList
.size ();
81
}
82
83
bool
84
TopologyReader::LinksEmpty
(
void
)
const
85
{
86
return
m_linksList
.empty ();
87
}
88
89
void
90
TopologyReader::AddLink
(
Link
link)
91
{
92
m_linksList
.push_back (link);
93
return
;
94
}
95
96
97
TopologyReader::Link::Link
(
Ptr<Node>
fromPtr,
const
std::string &fromName,
Ptr<Node>
toPtr,
const
std::string &toName )
98
{
99
m_fromPtr
= fromPtr;
100
m_fromName
= fromName;
101
m_toPtr
= toPtr;
102
m_toName
= toName;
103
}
104
105
TopologyReader::Link::Link
()
106
{
107
}
108
109
110
Ptr<Node>
TopologyReader::Link::GetFromNode
(
void
)
const
111
{
112
return
m_fromPtr;
113
}
114
115
std::string
116
TopologyReader::Link::GetFromNodeName
(
void
)
const
117
{
118
return
m_fromName;
119
}
120
121
Ptr<Node>
122
TopologyReader::Link::GetToNode
(
void
)
const
123
{
124
return
m_toPtr;
125
}
126
127
std::string
128
TopologyReader::Link::GetToNodeName
(
void
)
const
129
{
130
return
m_toName;
131
}
132
133
std::string
134
TopologyReader::Link::GetAttribute
(
const
std::string &name)
const
135
{
136
NS_ASSERT_MSG
(m_linkAttr.find (name) != m_linkAttr.end (),
"Requested topology link attribute not found"
);
137
return
m_linkAttr.find (name)->second;
138
}
139
140
bool
141
TopologyReader::Link::GetAttributeFailSafe
(
const
std::string &name, std::string &value)
const
142
{
143
if
( m_linkAttr.find (name) == m_linkAttr.end () )
144
{
145
return
false
;
146
}
147
value = m_linkAttr.find (name)->second;
148
return
true
;
149
}
150
151
void
152
TopologyReader::Link::SetAttribute
(
const
std::string &name,
const
std::string &value)
153
{
154
m_linkAttr[name] = value;
155
}
156
157
TopologyReader::Link::ConstAttributesIterator
158
TopologyReader::Link::AttributesBegin
(
void
)
159
{
160
return
m_linkAttr.begin ();
161
}
162
TopologyReader::Link::ConstAttributesIterator
163
TopologyReader::Link::AttributesEnd
(
void
)
164
{
165
return
m_linkAttr.end ();
166
}
167
168
169
}
/* namespace ns3 */
src
topology-read
model
topology-reader.cc
Generated on Tue Nov 13 2012 10:32:23 for ns-3 by
1.8.1.2