OMNeT++ Simulation Library  5.6.1
cTopology Class Reference

#include <ctopology.h>

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.

See also
cTopology::Node, cTopology::Link, cTopology::LinkIn, cTopology::LinkOut
Inheritance diagram for cTopology:
cOwnedObject cNamedObject cObject

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 ()
 
cTopologyoperator= (const cTopology &topo)
 
Redefined cObject member functions.
virtual cTopologydup () const override
 
virtual std::string str () const override
 
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) 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 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.

Users also need to rely on Node and Link member functions to explore the graph stored in the object.

virtual int getNumNodes () const
 
virtual NodegetNode (int i)
 
virtual NodegetNodeFor (cModule *mod)
 
Algorithms to find shortest paths.
virtual void calculateUnweightedSingleShortestPathsTo (Node *target)
 
virtual void calculateWeightedSingleShortestPathsTo (Node *target)
 
virtual NodegetTargetNode () const
 
- Public Member Functions inherited from cOwnedObject
 cOwnedObject ()
 
 cOwnedObject (const char *name, bool namepooling=true)
 
 cOwnedObject (const cOwnedObject &obj)
 
virtual ~cOwnedObject ()
 
cOwnedObjectoperator= (const cOwnedObject &o)
 
virtual cObjectgetOwner () const override
 
virtual bool isOwnedObject () const override
 
virtual bool isSoftOwner () const
 
- Public Member Functions inherited from cNamedObject
 cNamedObject ()
 
 cNamedObject (const char *name, bool namepooling=true)
 
 cNamedObject (const cNamedObject &obj)
 
virtual ~cNamedObject ()
 
cNamedObjectoperator= (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)
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
const cObjectgetThisPtr () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
void copyNotSupported () const
 

Protected Member Functions

virtual NodecreateNode (cModule *module)
 
virtual LinkcreateLink ()
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Additional Inherited Members

- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cDefaultListgetDefaultOwner ()
 

Constructor & Destructor Documentation

◆ cTopology() [1/2]

cTopology ( const char *  name = nullptr)
explicit

Constructor.

◆ cTopology() [2/2]

cTopology ( const cTopology topo)

Copy constructor.

◆ ~cTopology()

virtual ~cTopology ( )
virtual

Destructor.

Member Function Documentation

◆ operator=()

cTopology& operator= ( const cTopology topo)

Assignment operator. The name member is not copied; see cNamedObject's operator=() for more details.

◆ dup()

virtual cTopology* dup ( ) const
inlineoverridevirtual

Creates and returns an exact copy of this object. See cObject for more details.

Reimplemented from cObject.

◆ str()

virtual std::string str ( ) const
overridevirtual

Produces a one-line description of the object's contents. See cObject for more details.

Reimplemented from cObject.

◆ parsimPack()

virtual void parsimPack ( cCommBuffer buffer) const
overridevirtual

Serializes the object into an MPI send buffer. Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cOwnedObject.

◆ parsimUnpack()

virtual void parsimUnpack ( cCommBuffer buffer)
overridevirtual

Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details.

Reimplemented from cOwnedObject.

◆ extractFromNetwork() [1/2]

virtual void extractFromNetwork ( bool(*)(cModule *, void *)  selfunc,
void *  userdata = nullptr 
)
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/2]

virtual void extractFromNetwork ( Predicate predicate)
virtual

The type safe, object-oriented equivalent of extractFromNetwork(selfunc, userdata).

◆ extractByModulePath()

virtual void extractByModulePath ( const std::vector< std::string > &  fullPathPatterns)
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 wilcards in the same syntax as in ini files.

An example:

topo.extractByModulePath(cStringTokenizer("**.host[*] **.router*").asVector());

◆ extractByNedTypeName()

virtual void extractByNedTypeName ( const std::vector< std::string > &  nedTypeNames)
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 void extractByProperty ( const char *  propertyName,
const char *  value = nullptr 
)
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:

module X {
    @node;
}

◆ extractByParameter()

virtual void extractByParameter ( const char *  paramName,
const char *  paramValue = nullptr 
)
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 void clear ( )
virtual

Deletes the topology stored in the object.

◆ addNode()

virtual int addNode ( Node node)
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 void deleteNode ( Node node)
virtual

Removes the given node from the graph, together with all of its links. Indices of existing graph nodes may change.

◆ addLink() [1/2]

virtual void addLink ( Link link,
Node srcNode,
Node destNode 
)
virtual

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]

virtual void addLink ( Link link,
cGate srcGate,
cGate destGate 
)
virtual

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 void deleteLink ( Link link)
virtual

Removes the given link from the graph. Indices of existing links in the source and destination nodes may change.

◆ getNumNodes()

virtual int getNumNodes ( ) const
inlinevirtual

Returns the number of nodes in the graph.

◆ getNode()

virtual Node* getNode ( int  i)
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()

virtual Node* getNodeFor ( cModule mod)
virtual

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 void calculateUnweightedSingleShortestPathsTo ( Node target)
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 void calculateWeightedSingleShortestPathsTo ( Node target)
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()

virtual Node* getTargetNode ( ) const
inlinevirtual

Returns the node that was passed to the most recently called shortest path finding function.

◆ createNode()

virtual Node* createNode ( cModule module)
inlineprotectedvirtual

Node factory.

References cComponent::getId().

◆ createLink()

virtual Link* createLink ( )
inlineprotectedvirtual

Link factory.


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