- Main Page
- Modules
- Classes
- Files
- Directories
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# cTopology Class Reference
[Utility classes]

`#include <ctopo.h>`

Inheritance diagram for cTopology:

List of all members.

## Detailed 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's 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

## 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 cPolymorphic * | dup () const
virtual std::string | info () const
virtual void | netPack (cCommBuffer *buffer)
virtual void | netUnpack (cCommBuffer *buffer)
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.
void | extractFromNetwork (int(*selfunc)(cModule *, void *), void *userdata=NULL)
void | extractByModuleType (const char *type1,...)
void | extractByModuleType (const char **types)
void | extractByModuleType (const std::vector< std::string > types)
void | extractByParameter (const char *parname, cPar *value=NULL)
void | clear ()
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.
int | nodes () const
Node * | node (int i)
Node * | nodeFor (cModule *mod)
Algorithms to find shortest paths.
void | unweightedSingleShortestPathsTo (Node *target)
Node * | targetNode () const
## 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...

## Constructor & Destructor Documentation

cTopology::cTopology | ( | const char * | name = `NULL` | ) | `[explicit]`

| Constructor.

cTopology::cTopology | ( | const cTopology & | topo | ) |

| Copy constructor.

virtual cTopology::~cTopology | ( |  | ) | `[virtual]`

| Destructor.

## Member Function Documentation

void cTopology::clear | ( |  | ) |

| Deletes the topology stored in the object.

virtual cPolymorphic* cTopology::dup | ( |  | ) | const`[inline, virtual]`

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

void cTopology::extractByModuleType | ( | const std::vector< std::string > | types | ) |

| Extracts model topology by module type (classnames). Includes into the graph all modules whose className() is one of the class names in in the 'types' argument.

void cTopology::extractByModuleType | ( | const char ** | types | ) |

| Extracts model topology by module type (classnames). Includes into the graph all modules whose className() is one of the class names in in the 'types' argument. 'types' is a vector of char* pointers, terminated by a NULL pointer.

void cTopology::extractByModuleType | ( | const char * | type1,
|  |  | ...
| ) |

| Extracts model topology by module type (classnames). Includes into the graph all modules whose className() is one of the strings listed as arguments. The argument list must be terminated by a NULL pointer. Example:
     cTopology topo;
     topo.extractByModuleType("Host", "Router", NULL);

void cTopology::extractByParameter | ( | const char * | parname,
|  | cPar * | value = `NULL`
| ) |

| Extracts model topology by parameter value. Includes into the graph modules which have a parameter with the given name and (optionally) the given value.

void cTopology::extractFromNetwork | ( | int(*)(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.

virtual std::string cTopology::info | ( |  | ) | const`[virtual]`

| Produces a one-line description of object contents into the buffer passed as argument. See cObject for more details. Reimplemented from cPolymorphic.

virtual void cTopology::netPack | ( | cCommBuffer * | buffer | ) | `[virtual]`

| Serializes the object into a PVM or MPI send buffer. Used by the simulation kernel for parallel execution. See cObject for more details. Reimplemented from cObject.

virtual void cTopology::netUnpack | ( | cCommBuffer * | buffer | ) | `[virtual]`

| Deserializes the object from a PVM or MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details. Reimplemented from cObject.

Node* cTopology::node | ( | 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.

Node* cTopology::nodeFor | ( | cModule * | mod | ) |

| 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.

int cTopology::nodes | ( |  | ) | const`[inline]`

| Returns the number of nodes in the graph.

cTopology& cTopology::operator= | ( | const cTopology & | topo | ) |

| Assignment operator. The name member doesn't get copied; see cObject's operator=() for more details.

Node* cTopology::targetNode | ( |  | ) | const`[inline]`

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

void cTopology::unweightedSingleShortestPathsTo | ( | 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.

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

- ctopo.h