A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
topology-reader.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Universita' di Firenze, Italy
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
18 * Author: Valerio Sartini (valesar@gmail.com)
19 */
20
21#include "topology-reader.h"
22
23#include "ns3/log.h"
24
25/**
26 * \file
27 * \ingroup topology
28 * ns3::TopologyReader implementation.
29 */
30
31namespace ns3
32{
33
34NS_LOG_COMPONENT_DEFINE("TopologyReader");
35
36NS_OBJECT_ENSURE_REGISTERED(TopologyReader);
37
38TypeId
40{
41 static TypeId tid =
42 TypeId("ns3::TopologyReader").SetParent<Object>().SetGroupName("TopologyReader");
43 return tid;
44}
45
47{
48 NS_LOG_FUNCTION(this);
49}
50
52{
53 NS_LOG_FUNCTION(this);
54}
55
56void
57TopologyReader::SetFileName(const std::string& fileName)
58{
59 m_fileName = fileName;
60}
61
62std::string
64{
65 return m_fileName;
66}
67
68/* Manipulating the address block */
69
72{
73 return m_linksList.begin();
74}
75
78{
79 return m_linksList.end();
80}
81
82int
84{
85 return m_linksList.size();
86}
87
88bool
90{
91 return m_linksList.empty();
92}
93
94void
96{
97 m_linksList.push_back(link);
98}
99
101 const std::string& fromName,
102 Ptr<Node> toPtr,
103 const std::string& toName)
104{
105 m_fromPtr = fromPtr;
106 m_fromName = fromName;
107 m_toPtr = toPtr;
108 m_toName = toName;
109}
110
112{
113}
114
117{
118 return m_fromPtr;
119}
120
121std::string
123{
124 return m_fromName;
125}
126
129{
130 return m_toPtr;
131}
132
133std::string
135{
136 return m_toName;
137}
138
139std::string
140TopologyReader::Link::GetAttribute(const std::string& name) const
141{
142 NS_ASSERT_MSG(m_linkAttr.find(name) != m_linkAttr.end(),
143 "Requested topology link attribute not found");
144 return m_linkAttr.find(name)->second;
145}
146
147bool
148TopologyReader::Link::GetAttributeFailSafe(const std::string& name, std::string& value) const
149{
150 if (m_linkAttr.find(name) == m_linkAttr.end())
151 {
152 return false;
153 }
154 value = m_linkAttr.find(name)->second;
155 return true;
156}
157
158void
159TopologyReader::Link::SetAttribute(const std::string& name, const std::string& value)
160{
161 m_linkAttr[name] = value;
162}
163
166{
167 return m_linkAttr.begin();
168}
169
172{
173 return m_linkAttr.end();
174}
175
176} /* namespace ns3 */
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
int LinksSize() const
Returns the number of links in this block.
std::list< Link > m_linksList
The container of the links between the nodes.
void AddLink(Link link)
Adds a link to the topology.
ConstLinksIterator LinksEnd() const
Returns an iterator to the the last link in this block.
std::string GetFileName() const
Returns the input file name.
void SetFileName(const std::string &fileName)
Sets the input file name.
ConstLinksIterator LinksBegin() const
Returns an iterator to the the first link in this block.
static TypeId GetTypeId()
Get the type ID.
std::string m_fileName
The name of the input file.
std::list< Link >::const_iterator ConstLinksIterator
Constant iterator to the list of the links.
~TopologyReader() override
bool LinksEmpty() const
Checks if the block contains any links.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TopologyReader declaration.