A Discrete-Event Network Simulator
API
topology-reader.h
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 #ifndef TOPOLOGY_READER_H
23 #define TOPOLOGY_READER_H
24 
25 #include <string>
26 #include <map>
27 #include <list>
28 #include "ns3/object.h"
29 #include "ns3/node.h"
30 
31 
38 namespace ns3 {
39 
40 class NodeContainer;
41 
50 class TopologyReader : public Object
51 {
52 
53 public:
61  class Link
62  {
63 public:
67  typedef std::map<std::string, std::string>::const_iterator ConstAttributesIterator;
68 
76  Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName );
77 
82  Ptr<Node> GetFromNode (void) const;
87  std::string GetFromNodeName (void) const;
92  Ptr<Node> GetToNode (void) const;
97  std::string GetToNodeName (void) const;
103  std::string GetAttribute (const std::string &name) const;
111  bool GetAttributeFailSafe (const std::string &name, std::string &value) const;
117  void SetAttribute (const std::string &name, const std::string &value);
128 
129 private:
130  Link ();
131  std::string m_fromName;
133  std::string m_toName;
135  std::map<std::string, std::string> m_linkAttr;
136  };
137 
141  typedef std::list< Link >::const_iterator ConstLinksIterator;
142 
147  static TypeId GetTypeId (void);
148 
149  TopologyReader ();
150  virtual ~TopologyReader ();
151 
152  // Delete copy constructor and assignment operator to avoid misuse
153  TopologyReader (const TopologyReader &) = delete;
155 
167  virtual NodeContainer Read (void) = 0;
168 
173  void SetFileName (const std::string &fileName);
174 
179  std::string GetFileName (void) const;
180 
185  ConstLinksIterator LinksBegin (void) const;
186 
191  ConstLinksIterator LinksEnd (void) const;
192 
197  int LinksSize (void) const;
198 
203  bool LinksEmpty (void) const;
204 
209  void AddLink (Link link);
210 
211 private:
215  std::string m_fileName;
216 
220  std::list<Link> m_linksList;
221 
222  // end class TopologyReader
223 };
224 
225 // end namespace ns3
226 };
227 
228 
229 #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:88
Interface for input file readers management.
std::list< Link > m_linksList
The container of the links between the nodes.
ConstLinksIterator LinksBegin(void) const
Returns an iterator to the the first link in this block.
void AddLink(Link link)
Adds a link to the topology.
TopologyReader & operator=(const TopologyReader &)=delete
std::list< Link >::const_iterator ConstLinksIterator
Constant iterator to the list of the links.
int LinksSize(void) const
Returns the number of links in this block.
bool LinksEmpty(void) const
Checks if the block contains any links.
ConstLinksIterator LinksEnd(void) const
Returns an iterator to the the last link in this block.
std::string GetFileName(void) const
Returns the input file name.
static TypeId GetTypeId(void)
Get the type ID.
void SetFileName(const std::string &fileName)
Sets the input file name.
TopologyReader(const TopologyReader &)=delete
std::string m_fileName
The name of the input file.
virtual NodeContainer Read(void)=0
Main topology reading function.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.