A Discrete-Event Network Simulator
API
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 
34 {
35  static TypeId tid = TypeId ("ns3::TopologyReader")
36  .SetParent<Object> ()
37  .SetGroupName ("TopologyReader")
38  ;
39  return tid;
40 }
41 
43 {
44  NS_LOG_FUNCTION (this);
45 }
46 
48 {
49  NS_LOG_FUNCTION (this);
50 }
51 
52 void
53 TopologyReader::SetFileName (const std::string &fileName)
54 {
55  m_fileName = fileName;
56 }
57 
58 std::string
60 {
61  return m_fileName;
62 }
63 
64 /* Manipulating the address block */
65 
68 {
69  return m_linksList.begin ();
70 }
71 
74 {
75  return m_linksList.end ();
76 }
77 
78 int
80 {
81  return m_linksList.size ();
82 }
83 
84 bool
86 {
87  return m_linksList.empty ();
88 }
89 
90 void
92 {
93  m_linksList.push_back (link);
94  return;
95 }
96 
97 
98 TopologyReader::Link::Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName )
99 {
100  m_fromPtr = fromPtr;
101  m_fromName = fromName;
102  m_toPtr = toPtr;
103  m_toName = toName;
104 }
105 
107 {
108 }
109 
110 
112 {
113  return m_fromPtr;
114 }
115 
116 std::string
118 {
119  return m_fromName;
120 }
121 
122 Ptr<Node>
124 {
125  return m_toPtr;
126 }
127 
128 std::string
130 {
131  return m_toName;
132 }
133 
134 std::string
135 TopologyReader::Link::GetAttribute (const std::string &name) const
136 {
137  NS_ASSERT_MSG (m_linkAttr.find (name) != m_linkAttr.end (), "Requested topology link attribute not found");
138  return m_linkAttr.find (name)->second;
139 }
140 
141 bool
142 TopologyReader::Link::GetAttributeFailSafe (const std::string &name, std::string &value) const
143 {
144  if ( m_linkAttr.find (name) == m_linkAttr.end () )
145  {
146  return false;
147  }
148  value = m_linkAttr.find (name)->second;
149  return true;
150 }
151 
152 void
153 TopologyReader::Link::SetAttribute (const std::string &name, const std::string &value)
154 {
155  m_linkAttr[name] = value;
156 }
157 
160 {
161  return m_linkAttr.begin ();
162 }
165 {
166  return m_linkAttr.end ();
167 }
168 
169 
170 } /* namespace ns3 */
#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:45
static TypeId GetTypeId(void)
Get the type ID.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
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(void) const
Returns an iterator to the the last link in this block.
bool LinksEmpty(void) const
Checks if the block contains any links.
void SetFileName(const std::string &fileName)
Sets the input file name.
int LinksSize(void) const
Returns the number of links in this block.
std::list< Link >::const_iterator ConstLinksIterator
Constant iterator to the list of the links.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string m_fileName
The name of the input file.
std::string GetFileName(void) const
Returns the input file name.
A base class which provides memory management and object aggregation.
Definition: object.h:87
a unique identifier for an interface.
Definition: type-id.h:58
ConstLinksIterator LinksBegin(void) const
Returns an iterator to the the first link in this block.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915