/usr/include/ns3.26/ns3/topology-reader.h is in libns3-dev 3.26+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2010 Universita' di Firenze, Italy
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
* Author: Valerio Sartini (valesar@gmail.com)
*/
#ifndef TOPOLOGY_READER_H
#define TOPOLOGY_READER_H
#include <string>
#include <map>
#include <list>
#include "ns3/object.h"
#include "ns3/node-container.h"
namespace ns3 {
/**
* \ingroup topology
*
* \brief Interface for input file readers management.
*
* This interface perform the shared tasks among all possible input file readers.
* Each different file format is handled by its own topology reader.
*/
class TopologyReader : public Object
{
public:
/**
* \brief Inner class holding the details about a link between two nodes.
*
* The link is not described in terms of technology. Rather it is only stating
* an association between two nodes. The nodes are characterized also with names
* reflecting how the nodes are called in the original topology file.
*/
class Link
{
public:
/**
* \brief Constant iterator to scan the map of link attributes.
*/
typedef std::map<std::string, std::string>::const_iterator ConstAttributesIterator;
/**
* \brief Constructor.
* \param [in] fromPtr Ptr to the node the link is originating from.
* \param [in] fromName Name of the node the link is originating from.
* \param [in] toPtr Ptr to the node the link is directed to.
* \param [in] toName Name of the node the link is directed to.
*/
Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName );
/**
* \brief Returns a Ptr<Node> to the "from" node of the link.
* \return A Ptr<Node> to the "from" node of the link.
*/
Ptr<Node> GetFromNode (void) const;
/**
* \brief Returns the name of the "from" node of the link.
* \return The name of the "from" node of the link.
*/
std::string GetFromNodeName (void) const;
/**
* \brief Returns a Ptr<Node> to the "to" node of the link.
* \return A Ptr<Node> to the "to" node of the link.
*/
Ptr<Node> GetToNode (void) const;
/**
* \brief Returns the name of the "to" node of the link.
* \return The name of the "to" node of the link.
*/
std::string GetToNodeName (void) const;
/**
* \brief Returns the value of a link attribute. The attribute must exist.
* \param [in] name the name of the attribute.
* \return The value of the attribute.
*/
std::string GetAttribute (const std::string &name) const;
/**
* \brief Returns the value of a link attribute.
* \param [in] name The name of the attribute.
* \param [out] value The value of the attribute.
*
* \return True if the attribute was defined, false otherwise.
*/
bool GetAttributeFailSafe (const std::string &name, std::string &value) const;
/**
* \brief Sets an arbitrary link attribute.
* \param [in] name The name of the attribute.
* \param [in] value The value of the attribute.
*/
void SetAttribute (const std::string &name, const std::string &value);
/**
* \brief Returns an iterator to the begin of the attributes.
* \return A const iterator to the first attribute of a link.
*/
ConstAttributesIterator AttributesBegin (void) const;
/**
* \brief Returns an iterator to the end of the attributes.
* \return A const iterator to the last attribute of a link.
*/
ConstAttributesIterator AttributesEnd (void) const;
private:
Link ();
std::string m_fromName; //!< Name of the node the links originates from.
Ptr< Node > m_fromPtr; //!< The node the links originates from.
std::string m_toName; //!< Name of the node the links is directed to.
Ptr< Node > m_toPtr; //!< The node the links is directed to.
std::map<std::string, std::string> m_linkAttr; //!< Container of the link attributes (if any).
};
/**
* \brief Constant iterator to the list of the links.
*/
typedef std::list< Link >::const_iterator ConstLinksIterator;
/**
* \brief Get the type ID.
* \return The object TypeId.
*/
static TypeId GetTypeId (void);
TopologyReader ();
virtual ~TopologyReader ();
/**
* \brief Main topology reading function.
*
* The data is parsed and the results are returned in the passed lists.
* The rationale behind this choice is to allow non-progressive node IDs
* in the topology files, as well as to separate the topology
* reader from the choices about actual IP number assignment and
* kind of links between nodes.
*
* \return The container of the nodes created (or null if there was an error).
*/
virtual NodeContainer Read (void) = 0;
/**
* \brief Sets the input file name.
* \param [in] fileName The input file name.
*/
void SetFileName (const std::string &fileName);
/**
* \brief Returns the input file name.
* \return The input file name.
*/
std::string GetFileName (void) const;
/**
* \brief Returns an iterator to the the first link in this block.
* \return A const iterator to the first link in this block.
*/
ConstLinksIterator LinksBegin (void) const;
/**
* \brief Returns an iterator to the the last link in this block.
* \return A const iterator to the last link in this block.
*/
ConstLinksIterator LinksEnd (void) const;
/**
* \brief Returns the number of links in this block.
* \return The number of links in this block.
*/
int LinksSize (void) const;
/**
* \brief Checks if the block contains any links.
* \return True if there are no links in this block, false otherwise.
*/
bool LinksEmpty (void) const;
/**
* \brief Adds a link to the topology.
* \param link [in] The link to be added.
*/
void AddLink (Link link);
private:
/**
* \brief Copy constructor
*
* Defined and unimplemented to avoid misuse.
*/
TopologyReader (const TopologyReader&);
/**
* \brief Copy constructor
*
* Defined and unimplemented to avoid misuse.
* \returns
*/
TopologyReader& operator= (const TopologyReader&);
/**
* The name of the input file.
*/
std::string m_fileName;
/**
* The container of the links between the nodes.
*/
std::list<Link> m_linksList;
// end class TopologyReader
};
// end namespace ns3
};
#endif /* TOPOLOGY_READER_H */
|