Routing support. More...
#include <ctopology.h>
Classes | |
class | Link |
Supporting class for cTopology, represents a link in the graph. More... | |
class | LinkIn |
Supporting class for cTopology. More... | |
class | LinkOut |
Supporting class for cTopology. More... | |
class | Node |
Supporting class for cTopology, represents a node in the graph. More... | |
class | Predicate |
Base class for selector objects used in extract. More... | |
Public Member Functions | |
Constructors, destructor, assignment | |
cTopology (const char *name=NULL) | |
cTopology (const cTopology &topo) | |
virtual | ~cTopology () |
cTopology & | operator= (const cTopology &topo) |
Redefined cObject member functions. | |
virtual cTopology * | dup () const |
virtual std::string | info () const |
virtual void | parsimPack (cCommBuffer *buffer) |
virtual void | parsimUnpack (cCommBuffer *buffer) |
Extracting the topology from a network. | |
void | extractFromNetwork (bool(*selfunc)(cModule *, void *), void *userdata=NULL) |
void | extractFromNetwork (Predicate *predicate) |
void | extractByModulePath (const std::vector< std::string > &fullPathPatterns) |
void | extractByNedTypeName (const std::vector< std::string > &nedTypeNames) |
void | extractByProperty (const char *propertyName, const char *value=NULL) |
void | extractByParameter (const char *paramName, const char *paramValue=NULL) |
void | clear () |
Functions to examine topology by hand. | |
int | getNumNodes () const |
Node * | getNode (int i) |
Node * | getNodeFor (cModule *mod) |
Algorithms to find shortest paths. | |
void | calculateUnweightedSingleShortestPathsTo (Node *target) |
void | calculateWeightedSingleShortestPathsTo (Node *target) |
Node * | getTargetNode () const |
Routing support.
The cTopology class was designed primarily to support routing in telecommunication or multiprocessor networks.
A cTopology object stores an abstract representation of the network in graph form:
You can specify which modules (either simple or compound) you want to include in the graph. The graph will include all connections among the selected modules. In the graph, all nodes are at the same level, there is no submodule nesting. Connections which span across compound module boundaries are also represented as one graph edge. Graph edges are directed, just as module gates are.
void cTopology::calculateUnweightedSingleShortestPathsTo | ( | Node * | target | ) |
Apply the Dijkstra algorithm to find all shortest paths to the given graph node.
The paths found can be extracted via Node's methods.
void cTopology::calculateWeightedSingleShortestPathsTo | ( | Node * | target | ) |
Apply the Dijkstra algorithm to find all shortest paths to the given graph node.
The paths found can be extracted via Node's methods. Uses weights in nodes and links.
virtual cTopology* cTopology::dup | ( | ) | const [inline, virtual] |
void cTopology::extractByModulePath | ( | const std::vector< std::string > & | fullPathPatterns | ) |
Extracts model topology by module full path.
All modules whole getFullPath() matches one of the patterns in given string vector will get included. The patterns may contain wilcards in the same syntax as in ini files.
An example:
topo.extractByModulePath(cStringTokenizer("**.host[*] **.router*").asVector());
void cTopology::extractByNedTypeName | ( | const std::vector< std::string > & | nedTypeNames | ) |
Extracts model topology by the fully qualified NED type name of the modules.
All modules whose getNedTypeName() is listed in the given string vector will get included.
Note: If you have all class names as a single, space-separated string, you can use cStringTokenizer to turn it into a string vector:
topo.extractByNedTypeName(cStringTokenizer("some.package.Host other.package.Router").asVector());
void cTopology::extractByParameter | ( | const char * | paramName, | |
const char * | paramValue = NULL | |||
) |
Extracts model topology by a module parameter.
All modules get included that have a parameter with the given name, and the parameter's str() method returns the paramValue string. If paramValue is NULL, only the parameter's existence is checked but not its value.
void cTopology::extractByProperty | ( | const char * | propertyName, | |
const char * | value = NULL | |||
) |
Extracts model topology by a module property.
All modules get included that have a property with the given name and the given value (more precisely, the first value of its default key being the specified value). If value is NULL, the property's value may be anything except "false" (i.e. the first value of the default key may not be "false").
For example, topo.extractByProperty("node");
would extract all modules that contain the @node
property, like the following one:
module X { @node; }
void cTopology::extractFromNetwork | ( | bool(*)(cModule *, void *) | selfunc, | |
void * | userdata = NULL | |||
) |
Extracts model topology by a user-defined criteria.
Includes into the graph modules for which the passed selfunc() returns nonzero. The userdata parameter may take any value you like, and it is passed back to selfunc() in its second argument.
Node* cTopology::getNode | ( | int | i | ) |
Returns pointer to the ith node in the graph.
Node's methods can be used to further examine the node's connectivity, etc.
Returns the graph node which corresponds to the given module in the network.
If no graph node corresponds to the module, the method returns NULL. This method assumes that the topology corresponds to the network, that is, it was probably created with one of the extract...() functions.
virtual std::string cTopology::info | ( | ) | const [virtual] |
Assignment operator.
The name member is not copied; see cNamedObject's operator=() for more details.
virtual void cTopology::parsimPack | ( | cCommBuffer * | buffer | ) | [virtual] |
Serializes the object into an MPI send buffer.
Used by the simulation kernel for parallel execution. See cObject for more details.
Reimplemented from cOwnedObject.
virtual void cTopology::parsimUnpack | ( | cCommBuffer * | buffer | ) | [virtual] |
Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution.
See cObject for more details.
Reimplemented from cOwnedObject.