A Discrete-Event Network Simulator
API
 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 
32 NS_OBJECT_ENSURE_REGISTERED (TopologyReader)
33  ;
34 
36 {
37  static TypeId tid = TypeId ("ns3::TopologyReader")
38  .SetParent<Object> ()
39  ;
40  return tid;
41 }
42 
44 {
45  NS_LOG_FUNCTION (this);
46 }
47 
49 {
50  NS_LOG_FUNCTION (this);
51 }
52 
53 void
54 TopologyReader::SetFileName (const std::string &fileName)
55 {
56  m_fileName = fileName;
57 }
58 
59 std::string
61 {
62  return m_fileName;
63 }
64 
65 /* Manipulating the address block */
66 
69 {
70  return m_linksList.begin ();
71 }
72 
75 {
76  return m_linksList.end ();
77 }
78 
79 int
81 {
82  return m_linksList.size ();
83 }
84 
85 bool
87 {
88  return m_linksList.empty ();
89 }
90 
91 void
93 {
94  m_linksList.push_back (link);
95  return;
96 }
97 
98 
99 TopologyReader::Link::Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName )
100 {
101  m_fromPtr = fromPtr;
102  m_fromName = fromName;
103  m_toPtr = toPtr;
104  m_toName = toName;
105 }
106 
108 {
109 }
110 
111 
113 {
114  return m_fromPtr;
115 }
116 
117 std::string
119 {
120  return m_fromName;
121 }
122 
123 Ptr<Node>
125 {
126  return m_toPtr;
127 }
128 
129 std::string
131 {
132  return m_toName;
133 }
134 
135 std::string
136 TopologyReader::Link::GetAttribute (const std::string &name) const
137 {
138  NS_ASSERT_MSG (m_linkAttr.find (name) != m_linkAttr.end (), "Requested topology link attribute not found");
139  return m_linkAttr.find (name)->second;
140 }
141 
142 bool
143 TopologyReader::Link::GetAttributeFailSafe (const std::string &name, std::string &value) const
144 {
145  if ( m_linkAttr.find (name) == m_linkAttr.end () )
146  {
147  return false;
148  }
149  value = m_linkAttr.find (name)->second;
150  return true;
151 }
152 
153 void
154 TopologyReader::Link::SetAttribute (const std::string &name, const std::string &value)
155 {
156  m_linkAttr[name] = value;
157 }
158 
161 {
162  return m_linkAttr.begin ();
163 }
166 {
167  return m_linkAttr.end ();
168 }
169 
170 
171 } /* namespace ns3 */
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
static TypeId GetTypeId(void)
Get the type ID.
ConstLinksIterator LinksBegin(void) const
Returns an iterator to the the first link in this block.
std::string GetFileName(void) const
Returns the input file name.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
std::list< Link > m_linksList
the container of the links between the nodes
bool LinksEmpty(void) const
Checks if the block contains any links.
void AddLink(Link link)
Adds a link to the topology.
int LinksSize(void) const
Returns the number of links in this block.
void SetFileName(const std::string &fileName)
Sets the input file name.
std::list< Link >::const_iterator ConstLinksIterator
Constant iterator to the list of the links.
std::string m_fileName
the name of the input file
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
ConstLinksIterator LinksEnd(void) const
Returns an iterator to the the last link in this block.