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 #include "topology-reader.h"
24 
25 
26 namespace ns3 {
27 
28 NS_LOG_COMPONENT_DEFINE ("TopologyReader");
29 
30 NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
31 
33 {
34  static TypeId tid = TypeId ("ns3::TopologyReader")
35  .SetParent<Object> ()
36  .SetGroupName ("TopologyReader")
37  ;
38  return tid;
39 }
40 
42 {
43  NS_LOG_FUNCTION (this);
44 }
45 
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
59 {
60  return m_fileName;
61 }
62 
63 /* Manipulating the address block */
64 
67 {
68  return m_linksList.begin ();
69 }
70 
73 {
74  return m_linksList.end ();
75 }
76 
77 int
79 {
80  return m_linksList.size ();
81 }
82 
83 bool
85 {
86  return m_linksList.empty ();
87 }
88 
89 void
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 
106 {
107 }
108 
109 
111 {
112  return m_fromPtr;
113 }
114 
115 std::string
117 {
118  return m_fromName;
119 }
120 
121 Ptr<Node>
123 {
124  return m_toPtr;
125 }
126 
127 std::string
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 
159 {
160  return m_linkAttr.begin ();
161 }
164 {
165  return m_linkAttr.end ();
166 }
167 
168 
169 } /* 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:204
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