FNSS C++ library
C++ API for the Fast Network Simulation Setup (FNSS) toolchain
 All Classes Functions Typedefs Pages
Classes | Public Member Functions | List of all members
fnss::Topology Class Reference

#include <topology.h>

+ Inheritance diagram for fnss::Topology:

Classes

class  EdgeNotFoundException
 
class  NodeNotFoundException
 

Public Member Functions

 Topology (bool directed=false)
 
bool isDirected () const
 
void addNode (const std::string &id, const Node &node)
 
Node removeNode (const std::string &id, bool pruneEdges=true)
 
Node getNode (const std::string &id) const
 
bool hasNode (const std::string &id) const
 
std::set< std::string > getAllNodes () const
 
void addEdge (const std::string &id1, const std::string &id2, const Edge &edge)
 
void addEdge (const std::pair< std::string, std::string > &nodes_, const Edge &edge)
 
void addEdge (const Pair< std::string, std::string > &nodes_, const Edge &edge)
 
Edge removeEdge (const std::string &id1, const std::string &id2)
 
Edge removeEdge (const std::pair< std::string, std::string > &nodes_)
 
Edge removeEdge (const Pair< std::string, std::string > &nodes_)
 
Edge getEdge (const std::string &id1, const std::string &id2) const
 
Edge getEdge (const std::pair< std::string, std::string > &nodes_) const
 
Edge getEdge (const Pair< std::string, std::string > &nodes_) const
 
bool hasEdge (const std::string &id1, const std::string &id2) const
 
bool hasEdge (const std::pair< std::string, std::string > &nodes_) const
 
bool hasEdge (const Pair< std::string, std::string > &nodes_) const
 
std::set< std::pair
< std::string, std::string > > 
getAllEdges () const
 
unsigned int nodeCount () const
 
unsigned int edgeCount () const
 
- Public Member Functions inherited from fnss::PropertyContainer
std::string getProperty (const std::string &name) const
 
void setProperty (const std::string &name, const std::string &value="")
 
bool hasProperty (const std::string &name) const
 
void addProperties (const PropertyContainer &other)
 
std::string removeProperty (const std::string &name)
 
std::set< std::string > getAllProperties () const
 

Detailed Description

Models a network topology.

Author
Cosmin Cocora

Constructor & Destructor Documentation

fnss::Topology::Topology ( bool  directed = false)

Constructor.

Parameters
directedwhether the topology's edges are directed. For an undirected topology, all methods related to edges will treat the given node pairs as commutative(eg. removeEdge("node1", "node2") has the same effect as removeEdge("node2", "node2")).

Member Function Documentation

void fnss::Topology::addEdge ( const std::string &  id1,
const std::string &  id2,
const Edge edge 
)

Add an edge between the specified nodes.

If the topology is directed, the edge is created from the first specified node to the second. If one of the nodes doesn't exist, an exception is thrown.

Parameters
id1the id of the first node.
id2the id of the second node.
edgethe Edge object.
void fnss::Topology::addEdge ( const std::pair< std::string, std::string > &  nodes_,
const Edge edge 
)

Add an edge between the specified nodes.

If the topology is directed, the edge is created from the first node in the pair to the second. If one of the nodes doesn't exist, an exception is thrown.

Parameters
nodesthe pair of nodes.
edgethe Edge object.
void fnss::Topology::addEdge ( const Pair< std::string, std::string > &  nodes_,
const Edge edge 
)

Add an edge between the specified nodes.

If the topology is directed, the edge is created from the first node in the pair to the second. If one of the nodes doesn't exist, an exception is thrown.

Parameters
nodesthe pair of nodes. The method ignores the commutativity property of the pair.
edgethe Edge object.
void fnss::Topology::addNode ( const std::string &  id,
const Node node 
)

Add a node to the topology.

If the ID of the node already exists it is overwritten.

Parameters
idthe id of the node to be added.
nodethe node object to add.
unsigned int fnss::Topology::edgeCount ( ) const

Get the number of edges in the topology.

Returns
the number of edges.
std::set< std::pair< std::string, std::string > > fnss::Topology::getAllEdges ( ) const

Get a std::set containing all the edges in the topology, represented as std::pairs containing the ids of the endpoints of each edge.

Returns
a set with all edge endpoint pairs of the topology.
std::set< std::string > fnss::Topology::getAllNodes ( ) const

Get a std::set<std::string> containing all the existing nodes' ids.

Returns
a set containing the ids.
Edge fnss::Topology::getEdge ( const std::string &  id1,
const std::string &  id2 
) const

Get a copy of the edge between the specified nodes.

If the topology is directed, the edge from the first specified node to the second is returned. Throws an exception if the edge is not found.

Parameters
id1the id of the first node.
id2the id of the second node. a copy of the requested edge.
Edge fnss::Topology::getEdge ( const std::pair< std::string, std::string > &  nodes_) const

Get a copy of the edge between the specified nodes.

If the topology is directed, the edge from the first node in the pair to the second is returned. Throws an exception if the edge is not found.

Parameters
nodesthe pair of nodes. a copy of the requested edge.
Edge fnss::Topology::getEdge ( const Pair< std::string, std::string > &  nodes_) const

Get a copy of the edge between the specified nodes.

If the topology is directed, the edge from the first node in the pair to the second is returned. Throws an exception if the edge is not found.

Parameters
nodesthe pair of nodes. The method ignores the commutativity property of the pair. a copy of the requested edge.
Node fnss::Topology::getNode ( const std::string &  id) const

Get a copy of the node with the specified id.

Throws an exception if the given node id isn't found.

Parameters
idthe id of the requested node.
Returns
a copy of the requested node.
bool fnss::Topology::hasEdge ( const std::string &  id1,
const std::string &  id2 
) const

Check whether the topology contains an edge between the specified nodes.

If the topology is directed, the edge from the first specified node to the second is checked.

Parameters
id1the id of the first node.
id2the id of the second node.
Returns
true if an edge exists, false otherwise.
bool fnss::Topology::hasEdge ( const std::pair< std::string, std::string > &  nodes_) const

Check whether the topology contains an edge between the specified nodes.

If the topology is directed, the edge from the first node in the pair to the second is checked.

Parameters
nodesthe pair of nodes.
Returns
true if an edge exists, false otherwise.
bool fnss::Topology::hasEdge ( const Pair< std::string, std::string > &  nodes_) const

Check whether the topology contains an edge between the specified nodes.

If the topology is directed, the edge from the first node in the pair to the second is checked.

Parameters
nodesthe pair of nodes. The method ignores the commutativity property of the pair.
Returns
true if an edge exists, false otherwise.
bool fnss::Topology::hasNode ( const std::string &  id) const

Check whether the topology contains the node with the specified id.

Parameters
idthe id of the node to lookup.
Returns
true if the node was found, false otherwise.
bool fnss::Topology::isDirected ( ) const

Get method for the topology's edge type.

Returns
true if the edges are directed, false otherwise.
unsigned int fnss::Topology::nodeCount ( ) const

Get the number of nodes in the topology.

Returns
the number of nodes.
Edge fnss::Topology::removeEdge ( const std::string &  id1,
const std::string &  id2 
)

Remove an edge from the topology.

If the topology is directed, the edge from the first specified node to the second is removed. Throws an exception if the edge is not found.

Parameters
id1the id of the first node.
id2the id of the second node.
Returns
a copy of the removed Edge object.
Edge fnss::Topology::removeEdge ( const std::pair< std::string, std::string > &  nodes_)

Remove an edge from the topology.

If the topology is directed, the edge from the first node in the pair to the second is removed. Throws an exception if the edge is not found.

Parameters
nodesthe pair of nodes.
Returns
a copy of the removed Edge object.
Edge fnss::Topology::removeEdge ( const Pair< std::string, std::string > &  nodes_)

Remove an edge from the topology.

If the topology is directed, the edge from the first node in the pair to the second is removed. Throws an exception if the edge is not found.

Parameters
nodesthe pair of nodes. The method ignores the commutativity property of the pair.
Returns
a copy of the removed Edge object.
Node fnss::Topology::removeNode ( const std::string &  id,
bool  pruneEdges = true 
)

Remove a node from the topology.

Also removes all the edges connected to the node unless explicitly told not to. Throws an exception if the given node id isn't found.

Parameters
idthe id of the node to be removed.
pruneEdgesset to false to prevent the method from removing the edges connected to the erased node.
Returns
a copy of the erased Node object.

The documentation for this class was generated from the following files: