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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
7 * Author: Valerio Sartini (valesar@gmail.com)
8 */
9
10#include "topology-reader.h"
11
12#include "ns3/log.h"
13
14/**
15 * \file
16 * \ingroup topology
17 * ns3::TopologyReader implementation.
18 */
19
20namespace ns3
21{
22
23NS_LOG_COMPONENT_DEFINE("TopologyReader");
24
25NS_OBJECT_ENSURE_REGISTERED(TopologyReader);
26
27TypeId
29{
30 static TypeId tid =
31 TypeId("ns3::TopologyReader").SetParent<Object>().SetGroupName("TopologyReader");
32 return tid;
33}
34
39
44
45void
46TopologyReader::SetFileName(const std::string& fileName)
47{
48 m_fileName = fileName;
49}
50
51std::string
53{
54 return m_fileName;
55}
56
57/* Manipulating the address block */
58
61{
62 return m_linksList.begin();
63}
64
67{
68 return m_linksList.end();
69}
70
71int
73{
74 return m_linksList.size();
75}
76
77bool
79{
80 return m_linksList.empty();
81}
82
83void
85{
86 m_linksList.push_back(link);
87}
88
90 const std::string& fromName,
91 Ptr<Node> toPtr,
92 const std::string& toName)
93{
94 m_fromPtr = fromPtr;
95 m_fromName = fromName;
96 m_toPtr = toPtr;
97 m_toName = toName;
98}
99
103
106{
107 return m_fromPtr;
108}
109
110std::string
112{
113 return m_fromName;
114}
115
118{
119 return m_toPtr;
120}
121
122std::string
124{
125 return m_toName;
126}
127
128std::string
129TopologyReader::Link::GetAttribute(const std::string& name) const
130{
131 NS_ASSERT_MSG(m_linkAttr.find(name) != m_linkAttr.end(),
132 "Requested topology link attribute not found");
133 return m_linkAttr.find(name)->second;
134}
135
136bool
137TopologyReader::Link::GetAttributeFailSafe(const std::string& name, std::string& value) const
138{
139 if (m_linkAttr.find(name) == m_linkAttr.end())
140 {
141 return false;
142 }
143 value = m_linkAttr.find(name)->second;
144 return true;
145}
146
147void
148TopologyReader::Link::SetAttribute(const std::string& name, const std::string& value)
149{
150 m_linkAttr[name] = value;
151}
152
155{
156 return m_linkAttr.begin();
157}
158
161{
162 return m_linkAttr.end();
163}
164
165} /* namespace ns3 */
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
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.
bool LinksEmpty() const
Checks if the block contains any links.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#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:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TopologyReader declaration.