cTopology Class Reference¶
|
API
|
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...() methods of cTopology. More... | |
Public Member Functions | |
Constructors, destructor, assignment | |
| cTopology (const char *name=nullptr) | |
| cTopology (const cTopology &topo) | |
| virtual | ~cTopology () |
| cTopology & | operator= (const cTopology &topo) |
Redefined cObject member functions. | |
| virtual cTopology * | dup () const override |
| virtual std::string | str () const override |
Extracting the topology from a network. | |
extract...() functions build topology from the model. User can select which modules to include. All connections between those modules will be in the topology. Connections can cross compound module boundaries. | |
| virtual void | extractFromNetwork (bool(*selfunc)(cModule *, void *), void *userdata=nullptr) |
| virtual void | extractFromNetwork (Predicate *predicate) |
| virtual void | extractFromNetwork (std::function< bool(cModule *)> predicate) |
| virtual void | extractByModulePath (const std::vector< std::string > &fullPathPatterns) |
| virtual void | extractByNedTypeName (const std::vector< std::string > &nedTypeNames) |
| virtual void | extractByProperty (const char *propertyName, const char *value=nullptr) |
| virtual void | extractByParameter (const char *paramName, const char *paramValue=nullptr) |
| virtual void | clear () |
Manipulating the graph. | |
| virtual int | addNode (Node *node) |
| virtual void | deleteNode (Node *node) |
| virtual void | addLink (Link *link, Node *srcNode, Node *destNode) |
| virtual void | addLink (Link *link, cGate *srcGate, cGate *destGate) |
| virtual void | deleteLink (Link *link) |
Functions to examine topology by hand. | |
| virtual int | getNumNodes () const |
| virtual Node * | getNode (int i) const |
| virtual Node * | getNodeFor (cModule *mod) const |
| Public Member Functions inherited from cOwnedObject | |
| cOwnedObject () | |
| cOwnedObject (const char *name, bool namepooling=true) | |
| cOwnedObject (const cOwnedObject &obj) | |
| virtual | ~cOwnedObject () |
| cOwnedObject & | operator= (const cOwnedObject &o) |
| virtual cObject * | getOwner () const override |
| virtual bool | isOwnedObject () const override |
| Public Member Functions inherited from cNamedObject | |
| cNamedObject () | |
| cNamedObject (const char *name, bool namepooling=true) | |
| cNamedObject (const cNamedObject &obj) | |
| virtual | ~cNamedObject () |
| cNamedObject & | operator= (const cNamedObject &o) |
| virtual void | setName (const char *s) |
| virtual const char * | getName () const override |
| virtual void | setNamePooling (bool b) |
| virtual bool | getNamePooling () |
| Public Member Functions inherited from cObject | |
| cObject () | |
| cObject (const cObject &other)=default | |
| virtual | ~cObject () |
| virtual const char * | getClassName () const |
| bool | isName (const char *s) const |
| virtual const char * | getFullName () const |
| virtual std::string | getFullPath () const |
| virtual std::string | getClassAndFullName () const |
| virtual std::string | getClassAndFullPath () const |
| const cObject * | getThisPtr () const |
| virtual std::ostream & | printOn (std::ostream &os) const |
| virtual bool | isSoftOwner () const |
| virtual void | forEachChild (cVisitor *v) |
| cObject * | findObject (const char *name, bool deep=true) |
| virtual cClassDescriptor * | getDescriptor () const |
| void | copyNotSupported () const |
Algorithms to find shortest paths. | |
| virtual Node * | createNode (cModule *module) |
| virtual Link * | createLink () |
| virtual void | calculateUnweightedSingleShortestPathsTo (Node *target) |
| virtual void | calculateWeightedSingleShortestPathsTo (Node *target) |
| virtual Node * | getTargetNode () const |
Additional Inherited Members | |
| Static Public Member Functions inherited from cOwnedObject | |
| static long | getTotalObjectCount () |
| static long | getLiveObjectCount () |
| static void | resetObjectCounters () |
| static cSoftOwner * | getOwningContext () |
| Protected Member Functions inherited from cObject | |
| virtual void | take (cOwnedObject *obj) |
| virtual void | drop (cOwnedObject *obj) |
| void | dropAndDelete (cOwnedObject *obj) |
Description
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:
- each cTopology node corresponds to a module (simple or compound), and
- each cTopology edge corresponds to a link or series of connecting links.
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.
Constructor & Destructor Documentation
◆ cTopology() [1/2]
|
explicit |
Constructor.
Referenced by cTopology(), dup(), and operator=().
◆ cTopology() [2/2]
Copy constructor.
References cTopology().
◆ ~cTopology()
|
virtual |
Destructor.
Member Function Documentation
◆ operator=()
Assignment operator. The name member is not copied; see cNamedObject::operator=() for details.
References cTopology().
◆ dup()
|
inlineoverridevirtual |
Creates and returns an exact copy of this object. See cObject for more details.
Reimplemented from cObject.
References cTopology().
◆ str()
|
overridevirtual |
◆ extractFromNetwork() [1/3]
|
virtual |
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.
◆ extractFromNetwork() [2/3]
|
virtual |
The type safe, object-oriented equivalent of extractFromNetwork(selfunc, userdata).
◆ extractFromNetwork() [3/3]
|
virtual |
The version of extractFromNetwork() that accepts the predicate as a lambda function.
◆ extractByModulePath()
|
virtual |
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 wildcards in the same syntax as in ini files.
An example:
topo.extractByModulePath(cStringTokenizer("**.host[*] **.router*").asVector());
◆ extractByNedTypeName()
|
virtual |
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());
◆ extractByProperty()
|
virtual |
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 nullptr, 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:
◆ extractByParameter()
|
virtual |
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 nullptr, only the parameter's existence is checked but not its value.
◆ clear()
|
virtual |
Deletes the topology stored in the object.
◆ addNode()
|
virtual |
Adds the given node to the graph. Returns the index of the new graph node (see getNode(int)). Indices of existing graph nodes may change.
◆ deleteNode()
|
virtual |
Removes the given node from the graph, together with all of its links. Indices of existing graph nodes may change.
◆ addLink() [1/2]
Adds the given link to the graph, between the specified nodes. If the link is already part of the graph it is removed first, i.e. this method also serves as reconnectLink().
◆ addLink() [2/2]
Adds the given link to the graph, between the nodes that correspond to the specified gates. It is an error if the modules that contain the gates are not parts of the graph. If the link is already part of the graph it is removed first, i.e. this method also serves as reconnectLink().
◆ deleteLink()
|
virtual |
Removes the given link from the graph. Indices of existing links in the source and destination nodes may change.
◆ getNumNodes()
|
inlinevirtual |
Returns the number of nodes in the graph.
◆ getNode()
|
virtual |
Returns pointer to the ith node in the graph. Node's methods can be used to further examine the node's connectivity, etc.
◆ getNodeFor()
Returns the graph node which corresponds to the given module in the network. If no graph node corresponds to the module, the method returns nullptr. This method assumes that the topology corresponds to the network, that is, it was probably created with one of the extract...() functions.
◆ calculateUnweightedSingleShortestPathsTo()
|
virtual |
Apply the Dijkstra algorithm to find all shortest paths to the given graph node. The paths found can be extracted via Node's methods.
◆ calculateWeightedSingleShortestPathsTo()
|
virtual |
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.
◆ getTargetNode()
|
inlinevirtual |
Returns the node that was passed to the most recently called shortest path finding function.
◆ createNode()
Node factory.
References cComponent::getId().
◆ createLink()
Generated on for API by