FNSS C++ library
C++ API for the Fast Network Simulation Setup (FNSS) toolchain
|
#include <topology.h>
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 |
Models a network topology.
fnss::Topology::Topology | ( | bool | directed = false | ) |
Constructor.
directed | whether 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")). |
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.
id1 | the id of the first node. |
id2 | the id of the second node. |
edge | the 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.
nodes | the pair of nodes. |
edge | the Edge object. |
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.
nodes | the pair of nodes. The method ignores the commutativity property of the pair. |
edge | the 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.
id | the id of the node to be added. |
node | the node object to add. |
unsigned int fnss::Topology::edgeCount | ( | ) | const |
Get the number of edges in the topology.
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.
std::set< std::string > fnss::Topology::getAllNodes | ( | ) | const |
Get a std::set<std::string> containing all the existing nodes' 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.
id1 | the id of the first node. |
id2 | the 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.
nodes | the pair of nodes. a copy of the requested edge. |
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.
nodes | the 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.
id | the id 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.
id1 | the id of the first node. |
id2 | the id of the second node. |
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.
nodes | the pair of nodes. |
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.
nodes | the pair of nodes. The method ignores the commutativity property of the pair. |
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.
id | the id of the node to lookup. |
true
if the node was found, false
otherwise. bool fnss::Topology::isDirected | ( | ) | const |
Get method for the topology's edge type.
true
if the edges are directed, false
otherwise. unsigned int fnss::Topology::nodeCount | ( | ) | const |
Get the number of nodes in the topology.
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.
id1 | the id of the first node. |
id2 | the id of the second node. |
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.
nodes | the pair of nodes. |
Edge
object. 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.
nodes | the pair of nodes. The method ignores the commutativity property of the pair. |
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.
id | the id of the node to be removed. |
pruneEdges | set to false to prevent the method from removing the edges connected to the erased node. |
Node
object.