A Discrete-Event Network Simulator
API
topology-reader.h
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 #ifndef TOPOLOGY_READER_H
22 #define TOPOLOGY_READER_H
23 
24 #include "ns3/node.h"
25 #include "ns3/object.h"
26 
27 #include <list>
28 #include <map>
29 #include <string>
30 
37 namespace ns3
38 {
39 
40 class NodeContainer;
41 
50 class TopologyReader : public Object
51 {
52  public:
60  class Link
61  {
62  public:
66  typedef std::map<std::string, std::string>::const_iterator ConstAttributesIterator;
67 
75  Link(Ptr<Node> fromPtr,
76  const std::string& fromName,
77  Ptr<Node> toPtr,
78  const std::string& toName);
79 
84  Ptr<Node> GetFromNode() const;
89  std::string GetFromNodeName() const;
94  Ptr<Node> GetToNode() const;
99  std::string GetToNodeName() const;
105  std::string GetAttribute(const std::string& name) const;
113  bool GetAttributeFailSafe(const std::string& name, std::string& value) const;
119  void SetAttribute(const std::string& name, const std::string& value);
130 
131  private:
132  Link();
133  std::string m_fromName;
135  std::string m_toName;
137  std::map<std::string, std::string>
139  };
140 
144  typedef std::list<Link>::const_iterator ConstLinksIterator;
145 
150  static TypeId GetTypeId();
151 
152  TopologyReader();
153  ~TopologyReader() override;
154 
155  // Delete copy constructor and assignment operator to avoid misuse
156  TopologyReader(const TopologyReader&) = delete;
158 
170  virtual NodeContainer Read() = 0;
171 
176  void SetFileName(const std::string& fileName);
177 
182  std::string GetFileName() const;
183 
189 
195 
200  int LinksSize() const;
201 
206  bool LinksEmpty() const;
207 
212  void AddLink(Link link);
213 
214  private:
218  std::string m_fileName;
219 
223  std::list<Link> m_linksList;
224 
225  // end class TopologyReader
226 };
227 
228 // end namespace ns3
229 }; // namespace ns3
230 
231 #endif /* TOPOLOGY_READER_H */
keep track of a set of node pointers.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Interface for input file readers management.
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.
TopologyReader & operator=(const TopologyReader &)=delete
virtual NodeContainer Read()=0
Main topology reading function.
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.
TopologyReader(const TopologyReader &)=delete
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.