INET Framework for OMNeT++/OMNEST
inet::Topology Class Reference

Routing support. More...

#include <Topology.h>

Inheritance diagram for inet::Topology:
inet::L2NetworkConfigurator::L2Topology inet::L3NetworkConfiguratorBase::Topology inet::NetworkConfiguratorBase::Topology inet::Ipv4NetworkConfigurator::Topology inet::StreamRedundancyConfigurator::Topology

Classes

class  Link
 Supporting class for Topology, represents a link in the graph. More...
 
class  Node
 Supporting class for Topology, represents a node in the graph. More...
 
class  Predicate
 Base class for selector objects used in extract...() methods of Topology. More...
 

Public Member Functions

Constructors, destructor, assignment
 Topology (const char *name=nullptr)
 Constructor. More...
 
 Topology (const Topology &topo)
 Copy constructor. More...
 
virtual ~Topology ()
 Destructor. More...
 
Topologyoperator= (const Topology &topo)
 Assignment operator. More...
 
Redefined cObject member functions.
virtual Topologydup () const override
 Creates and returns an exact copy of this object. More...
 
virtual std::string str () const override
 Produces a one-line description of the object's contents. More...
 
virtual void parsimPack (cCommBuffer *buffer) const override
 Serializes the object into an MPI send buffer. More...
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution. More...
 
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 (bool(*selfunc)(cModule *, void *), void *userdata=nullptr)
 Extracts model topology by a user-defined criteria. More...
 
void extractFromNetwork (Predicate *predicate)
 The type safe, object-oriented equivalent of extractFromNetwork(selfunc, userdata). More...
 
void extractByModulePath (const std::vector< std::string > &fullPathPatterns)
 Extracts model topology by module full path. More...
 
void extractByNedTypeName (const std::vector< std::string > &nedTypeNames)
 Extracts model topology by the fully qualified NED type name of the modules. More...
 
void extractByProperty (const char *propertyName, const char *value=nullptr)
 Extracts model topology by a module property. More...
 
void extractByParameter (const char *paramName, const char *paramValue=nullptr)
 Extracts model topology by a module parameter. More...
 
void clear ()
 Deletes the topology stored in the object. More...
 
Manipulating the graph.
int addNode (Node *node)
 Adds the given node to the graph. More...
 
void deleteNode (Node *node)
 Removes the given node from the graph, together with all of its links. More...
 
void addLink (Link *link, Node *srcNode, Node *destNode)
 TODO Note: also serves as reconnectLink() More...
 
void addLink (Link *link, cGate *srcGate, cGate *destGate)
 TODO Note: also serves as reconnectLink() More...
 
void deleteLink (Link *link)
 Removes the given link from the graph. More...
 
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 getNumNodes () const
 Returns the number of nodes in the graph. More...
 
NodegetNode (int i) const
 Returns pointer to the ith node in the graph. More...
 
NodegetNodeFor (cModule *mod) const
 Returns the graph node which corresponds to the given module in the network. More...
 

Protected Member Functions

void unlinkFromSourceNode (Link *link)
 
void unlinkFromDestNode (Link *link)
 
void findNetworks (Node *)
 

Static Protected Member Functions

static bool lessByModuleId (Node *a, Node *b)
 
static bool isModuleIdLess (Node *a, int moduleId)
 

Protected Attributes

std::vector< Node * > nodes
 

Algorithms to find shortest paths.

virtual NodecreateNode (cModule *module)
 Node factory. More...
 
virtual LinkcreateLink ()
 Link factory. More...
 
void calculateUnweightedSingleShortestPathsTo (Node *target) const
 Apply the Dijkstra algorithm to find all shortest paths to the given graph node. More...
 
void calculateWeightedSingleShortestPathsTo (Node *target) const
 Apply the Dijkstra algorithm to find all shortest paths to the given graph node. More...
 

Detailed Description

Routing support.

The Topology class was designed primarily to support routing in telecommunication or multiprocessor networks.

A Topology object stores an abstract representation of the network in graph form:

  • each Topology node corresponds to a module (simple or compound), and
  • each Topology 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
Topology::Node, Topology::Link

Constructor & Destructor Documentation

◆ Topology() [1/2]

inet::Topology::Topology ( const char *  name = nullptr)
explicit

Constructor.

42  : cOwnedObject(name)
43 {
44 }

◆ Topology() [2/2]

inet::Topology::Topology ( const Topology topo)

Copy constructor.

46  : cOwnedObject(topo)
47 {
48  throw cRuntimeError(this, "copy ctor not implemented yet");
49 }

◆ ~Topology()

inet::Topology::~Topology ( )
virtual

Destructor.

Reimplemented in inet::L3NetworkConfiguratorBase::Topology.

52 {
53  clear();
54 }

Member Function Documentation

◆ addLink() [1/2]

void inet::Topology::addLink ( Link link,
cGate *  srcGate,
cGate *  destGate 
)

TODO Note: also serves as reconnectLink()

303 {
304  // remove from graph if it's already in
305  if (link->srcNode)
306  unlinkFromSourceNode(link);
307  if (link->destNode)
308  unlinkFromDestNode(link);
309 
310  // insert
311  Node *srcNode = getNodeFor(srcGate->getOwnerModule());
312  Node *destNode = getNodeFor(destGate->getOwnerModule());
313  if (!srcNode)
314  throw cRuntimeError("cTopology::addLink: module of source gate \"%s\" is not in the graph", srcGate->getFullPath().c_str());
315  if (!destNode)
316  throw cRuntimeError("cTopology::addLink: module of destination gate \"%s\" is not in the graph", destGate->getFullPath().c_str());
317  link->srcNode = srcNode;
318  link->destNode = destNode;
319  link->srcGateId = srcGate->getId();
320  link->destGateId = destGate->getId();
321  srcNode->outLinks.push_back(link);
322  destNode->inLinks.push_back(link);
323 }

◆ addLink() [2/2]

void inet::Topology::addLink ( Link link,
Node srcNode,
Node destNode 
)

TODO Note: also serves as reconnectLink()

284 {
285  // remove from graph if it's already in
286  if (link->srcNode)
287  unlinkFromSourceNode(link);
288  if (link->destNode)
289  unlinkFromDestNode(link);
290 
291  // insert
292  if (link->srcNode != srcNode)
293  link->srcGateId = -1;
294  if (link->destNode != destNode)
295  link->destGateId = -1;
296  link->srcNode = srcNode;
297  link->destNode = destNode;
298  srcNode->outLinks.push_back(link);
299  destNode->inLinks.push_back(link);
300 }

Referenced by inet::L3NetworkConfiguratorBase::extractTopology().

◆ addNode()

int inet::Topology::addNode ( Node node)

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.

243 {
244  if (node->moduleId == -1) {
245  // elements without module ID are stored at the end
246  nodes.push_back(node);
247  return nodes.size() - 1;
248  }
249  else {
250  // must find an insertion point because nodes[] is ordered by module ID
251  auto it = std::lower_bound(nodes.begin(), nodes.end(), node, lessByModuleId);
252  it = nodes.insert(it, node);
253  return it - nodes.begin();
254  }
255 }

◆ calculateUnweightedSingleShortestPathsTo()

void inet::Topology::calculateUnweightedSingleShortestPathsTo ( Node target) const

Apply the Dijkstra algorithm to find all shortest paths to the given graph node.

The paths found can be extracted via Node's methods.

365 {
366  // multiple paths not supported :-(
367 
368  if (!_target)
369  throw cRuntimeError(this, "..ShortestPathTo(): target node is nullptr");
370  auto target = _target;
371 
372  for (auto& elem : nodes) {
373  elem->dist = INFINITY;
374  elem->outPaths.clear();
375  }
376  target->dist = 0;
377 
378  std::deque<Node *> q;
379 
380  q.push_back(target);
381 
382  while (!q.empty()) {
383  Node *v = q.front();
384  q.pop_front();
385 
386  // for each w adjacent to v...
387  for (size_t i = 0; i < v->inLinks.size(); i++) {
388  if (!v->inLinks[i]->enabled)
389  continue;
390 
391  Node *w = v->inLinks[i]->srcNode;
392  if (!w->enabled)
393  continue;
394 
395  if (w->dist == INFINITY) {
396  w->dist = v->dist + 1;
397  q.push_back(w);
398  }
399  // the first one will be the shortest
400  if (!contains(w->outPaths, v->inLinks[i]))
401  w->outPaths.push_back(v->inLinks[i]);
402  }
403  }
404 }

Referenced by inet::NetworkConfiguratorBase::computeShortestLinkPath(), and inet::NetworkConfiguratorBase::computeShortestNodePath().

◆ calculateWeightedSingleShortestPathsTo()

void inet::Topology::calculateWeightedSingleShortestPathsTo ( Node target) const

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.

407 {
408  if (!_target)
409  throw cRuntimeError(this, "..ShortestPathTo(): target node is nullptr");
410  auto target = _target;
411 
412  // clean path infos
413  for (auto& elem : nodes) {
414  elem->dist = INFINITY;
415  elem->outPaths.clear();
416  }
417 
418  target->dist = 0;
419 
420  std::list<Node *> q;
421 
422  q.push_back(target);
423 
424  while (!q.empty()) {
425  Node *dest = q.front();
426  q.pop_front();
427 
428  ASSERT(dest->getWeight() >= 0.0);
429 
430  // for each w adjacent to v...
431  for (int i = 0; i < dest->getNumInLinks(); i++) {
432  if (!(dest->getLinkIn(i)->isEnabled()))
433  continue;
434 
435  Node *src = dest->getLinkIn(i)->getLinkInRemoteNode();
436  if (!src->isEnabled())
437  continue;
438 
439  double linkWeight = dest->getLinkIn(i)->getWeight();
440 
441  // links with linkWeight == 0 might induce circles
442  ASSERT(linkWeight > 0.0);
443 
444  double newdist = dest->dist + linkWeight;
445  if (dest != target)
446  newdist += dest->getWeight(); // dest is not the target, uses weight of dest node as price of routing (infinity means dest node doesn't route between interfaces)
447  if (newdist != INFINITY && src->dist > newdist) { // it's a valid shorter path from src to target node
448  if (src->dist != INFINITY)
449  q.remove(src); // src is in the queue
450  src->dist = newdist;
451  // the first one will be the shortest
452  src->outPaths.erase(std::remove(src->outPaths.begin(), src->outPaths.end(), dest->inLinks[i]), src->outPaths.end());
453  src->outPaths.insert(src->outPaths.begin(), dest->inLinks[i]);
454 
455  // insert src node to ordered list
456  auto it = q.begin();
457  for (; it != q.end(); ++it)
458  if ((*it)->dist > newdist)
459  break;
460 
461  q.insert(it, src);
462  }
463  else if (!contains(src->outPaths, dest->inLinks[i]))
464  src->outPaths.push_back(dest->inLinks[i]);
465  }
466  }
467 }

Referenced by inet::NextHopNetworkConfigurator::addStaticRoutes(), inet::Ipv4NetworkConfigurator::addStaticRoutes(), and inet::MacForwardingTableConfigurator::extendConfiguration().

◆ clear()

void inet::Topology::clear ( )

Deletes the topology stored in the object.

79 {
80  for (auto& elem : nodes) {
81  for (auto& _j : elem->outLinks)
82  delete _j; // delete links from their source side
83  delete elem;
84  }
85  nodes.clear();
86 }

Referenced by inet::StreamRedundancyConfigurator::clearConfiguration(), inet::GateScheduleConfiguratorBase::clearConfiguration(), inet::Ipv4NetworkConfigurator::computeConfiguration(), extractFromNetwork(), and ~Topology().

◆ createLink()

virtual Link* inet::Topology::createLink ( )
inlineprotectedvirtual

◆ createNode()

virtual Node* inet::Topology::createNode ( cModule *  module)
inlineprotectedvirtual

◆ deleteLink()

void inet::Topology::deleteLink ( Link link)

Removes the given link from the graph.

Indices of existing links in the source and destination nodes may change.

326 {
327  unlinkFromSourceNode(link);
328  unlinkFromDestNode(link);
329  delete link;
330 }

◆ deleteNode()

void inet::Topology::deleteNode ( Node node)

Removes the given node from the graph, together with all of its links.

Indices of existing graph nodes may change.

258 {
259  // remove outgoing links
260  for (auto& elem : node->outLinks) {
261  Link *link = elem;
262  unlinkFromDestNode(link);
263  delete link;
264  }
265  node->outLinks.clear();
266 
267  // remove incoming links
268  for (auto& elem : node->inLinks) {
269  Link *link = elem;
270  unlinkFromSourceNode(link);
271  delete link;
272  }
273  node->inLinks.clear();
274 
275  // remove from nodes[]
276  auto it = find(nodes, node);
277  ASSERT(it != nodes.end());
278  nodes.erase(it);
279 
280  delete node;
281 }

◆ dup()

virtual Topology* inet::Topology::dup ( ) const
inlineoverridevirtual

Creates and returns an exact copy of this object.

See cObject for more details.

369 { return new Topology(*this); }

◆ extractByModulePath()

void inet::Topology::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());

140 {
141  extractFromNetwork(selectByModulePath, (void *)&fullPathPatterns);
142 }

◆ extractByNedTypeName()

void inet::Topology::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());

145 {
146  extractFromNetwork(selectByNedTypeName, (void *)&nedTypeNames);
147 }

◆ extractByParameter()

void inet::Topology::extractByParameter ( const char *  paramName,
const char *  paramValue = nullptr 
)

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.

161 {
162  struct {
163  const char *name;
164  const char *value;
165  } data = {
166  paramName, paramValue
167  };
168  extractFromNetwork(selectByParameter, (void *)&data);
169 }

◆ extractByProperty()

void inet::Topology::extractByProperty ( const char *  propertyName,
const char *  value = nullptr 
)

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("networkNode"); would extract all modules that contain the @networkNode property, like the following one:

module X {
    @networkNode;
}
150 {
151  struct {
152  const char *name;
153  const char *value;
154  } data = {
155  propertyName, value
156  };
157  extractFromNetwork(selectByProperty, (void *)&data);
158 }

Referenced by inet::StpTester::depthFirstSearch(), inet::NetworkConfiguratorBase::extractTopology(), inet::L2NetworkConfigurator::extractTopology(), and inet::L3NetworkConfiguratorBase::extractTopology().

◆ extractFromNetwork() [1/2]

void inet::Topology::extractFromNetwork ( bool(*)(cModule *, void *)  selfunc,
void *  userdata = nullptr 
)

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.

185 {
186  clear();
187 
188  // Loop through all modules and find those that satisfy the criteria
189  int networkId = 0;
190  for (int modId = 0; modId <= getSimulation()->getLastComponentId(); modId++) {
191  cModule *module = getSimulation()->getModule(modId);
192  if (module && predicate(module, data)) {
193  Node *node = createNode(module);
194  node->setNetworkId(++networkId);
195  nodes.push_back(node);
196  }
197  }
198 
199  // Discover out neighbors too.
200  for (auto& elem : nodes) {
201  // Loop through all its gates and find those which come
202  // from or go to modules included in the topology.
203 
204  Node *node = elem;
205  cModule *mod = getSimulation()->getModule(node->moduleId);
206 
207  for (cModule::GateIterator i(mod); !i.end(); i++) {
208  cGate *gate = *i;
209  if (gate->getType() != cGate::OUTPUT)
210  continue;
211 
212  // follow path
213  cGate *srcGate = gate;
214  do {
215  gate = gate->getNextGate();
216  } while (gate && !predicate(gate->getOwnerModule(), data));
217 
218  // if we arrived at a module in the topology, record it.
219  if (gate) {
220  Link *link = createLink();
221  link->srcNode = node;
222  link->srcGateId = srcGate->getId();
223  link->destNode = getNodeFor(gate->getOwnerModule());
224  link->destGateId = gate->getId();
225  node->outLinks.push_back(link);
226  }
227  }
228  }
229 
230  // fill inLinks vectors
231  for (auto& elem : nodes) {
232  for (auto& _l : elem->outLinks) {
233  Topology::Link *link = _l;
234  link->destNode->inLinks.push_back(link);
235  }
236  }
237 
238  for (auto& elem : nodes)
239  findNetworks(elem);
240 }

Referenced by extractByModulePath(), extractByNedTypeName(), extractByParameter(), extractByProperty(), and extractFromNetwork().

◆ extractFromNetwork() [2/2]

void inet::Topology::extractFromNetwork ( Predicate predicate)

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

180 {
181  extractFromNetwork(selectByPredicate, (void *)predicate);
182 }

◆ findNetworks()

void inet::Topology::findNetworks ( Node node)
protected
470 {
471  if (node->isVisited())
472  return;
473 
474  cModule *mod = getSimulation()->getModule(node->moduleId);
475  if (!mod)
476  return;
477 
478  for (cModule::GateIterator i(mod); !i.end(); i++) {
479  cGate *gate = *i;
480  if (gate->getType() != cGate::OUTPUT)
481  continue;
482 
483  // follow path
484  do {
485  gate = gate->getNextGate();
486  } while (gate && !gate->getOwnerModule());
487 
488  // if we arrived at a module in the topology, record it.
489  if (gate) {
490  node->setVisited(true);
491  Node *nextNode = getNodeFor(gate->getOwnerModule());
492  if (nextNode) {
493  if (!nextNode->isVisited()) {
494  nextNode->setNetworkId(node->getNetworkId());
495  findNetworks(nextNode);
496  }
497  }
498  }
499  }
500 }

Referenced by extractFromNetwork().

◆ getNode()

Topology::Node * inet::Topology::getNode ( int  i) const

Returns pointer to the ith node in the graph.

Node's methods can be used to further examine the node's connectivity, etc.

349 {
350  if (i < 0 || i >= (int)nodes.size())
351  throw cRuntimeError(this, "invalid node index %d", i);
352  return nodes[i];
353 }

Referenced by inet::GateScheduleConfiguratorBase::addDevices(), inet::GateScheduleConfiguratorBase::addFlows(), inet::GateScheduleConfiguratorBase::addPorts(), inet::NextHopNetworkConfigurator::addStaticRoutes(), inet::Ipv4NetworkConfigurator::addStaticRoutes(), inet::GateScheduleConfiguratorBase::addSwitches(), inet::MacForwardingTableConfigurator::computeMacForwardingTables(), inet::FailureProtectionConfigurator::computeStream(), inet::StreamRedundancyConfigurator::computeStreamEncodings(), inet::StreamRedundancyConfigurator::computeStreamPolicyConfigurations(), inet::StreamRedundancyConfigurator::computeStreamSendersAndReceivers(), inet::Ipv4NetworkConfigurator::configureAllInterfaces(), inet::Ipv4NetworkConfigurator::configureAllRoutingTables(), inet::GateScheduleConfiguratorBase::configureGateScheduling(), inet::L2NetworkConfigurator::configureInterface(), inet::Ipv4NetworkConfigurator::configureRoutingTable(), inet::StreamRedundancyConfigurator::configureStreams(), inet::StpTester::depthFirstSearch(), inet::Ipv4NetworkConfigurator::dumpConfig(), inet::NextHopNetworkConfigurator::dumpRoutes(), inet::Ipv4NetworkConfigurator::dumpRoutes(), inet::L3NetworkConfiguratorBase::dumpTopology(), inet::MacForwardingTableConfigurator::extendConfiguration(), inet::NetworkConfiguratorBase::extractTopology(), inet::L2NetworkConfigurator::extractTopology(), inet::L3NetworkConfiguratorBase::extractTopology(), inet::L3NetworkConfiguratorBase::extractWirelessNeighbors(), inet::Ipv4NetworkConfigurator::readManualMulticastRouteConfiguration(), and inet::Ipv4NetworkConfigurator::readManualRouteConfiguration().

◆ getNodeFor()

Topology::Node * inet::Topology::getNodeFor ( cModule *  mod) const

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.

356 {
357  // binary search because nodes[] is ordered by module ID
358  Node tmpNode(mod->getId());
359  auto it = std::lower_bound(nodes.begin(), nodes.end(), &tmpNode, lessByModuleId);
360  // TODO this does not compile with VC9 (VC10 is OK): auto it = std::lower_bound(nodes.begin(), nodes.end(), mod->getId(), isModuleIdLess);
361  return it == nodes.end() || (*it)->moduleId != mod->getId() ? nullptr : *it;
362 }

Referenced by addLink(), inet::GateScheduleConfiguratorBase::addPorts(), inet::EagerGateScheduleConfigurator::computeStartOffsetForPathFragments(), inet::FailureProtectionConfigurator::computeStream(), extractFromNetwork(), findNetworks(), inet::StreamRedundancyConfigurator::getPathFragments(), and inet::MacForwardingTableConfigurator::receiveSignal().

◆ getNumNodes()

int inet::Topology::getNumNodes ( ) const
inline

Returns the number of nodes in the graph.

516 { return nodes.size(); }

Referenced by inet::GateScheduleConfiguratorBase::addDevices(), inet::GateScheduleConfiguratorBase::addFlows(), inet::GateScheduleConfiguratorBase::addPorts(), inet::NextHopNetworkConfigurator::addStaticRoutes(), inet::Ipv4NetworkConfigurator::addStaticRoutes(), inet::GateScheduleConfiguratorBase::addSwitches(), inet::MacForwardingTableConfigurator::computeMacForwardingTables(), inet::FailureProtectionConfigurator::computeStream(), inet::StreamRedundancyConfigurator::computeStreamEncodings(), inet::StreamRedundancyConfigurator::computeStreamPolicyConfigurations(), inet::StreamRedundancyConfigurator::computeStreamSendersAndReceivers(), inet::Ipv4NetworkConfigurator::configureAllInterfaces(), inet::Ipv4NetworkConfigurator::configureAllRoutingTables(), inet::GateScheduleConfiguratorBase::configureGateScheduling(), inet::L2NetworkConfigurator::configureInterface(), inet::Ipv4NetworkConfigurator::configureRoutingTable(), inet::StreamRedundancyConfigurator::configureStreams(), inet::StpTester::depthFirstSearch(), inet::Ipv4NetworkConfigurator::dumpConfig(), inet::NextHopNetworkConfigurator::dumpRoutes(), inet::Ipv4NetworkConfigurator::dumpRoutes(), inet::L3NetworkConfiguratorBase::dumpTopology(), inet::L2NetworkConfigurator::ensureConfigurationComputed(), inet::Ipv4NetworkConfigurator::ensureConfigurationComputed(), inet::MacForwardingTableConfigurator::extendConfiguration(), inet::NetworkConfiguratorBase::extractTopology(), inet::L2NetworkConfigurator::extractTopology(), inet::L3NetworkConfiguratorBase::extractTopology(), inet::L3NetworkConfiguratorBase::extractWirelessNeighbors(), inet::Ipv4NetworkConfigurator::readManualMulticastRouteConfiguration(), and inet::Ipv4NetworkConfigurator::readManualRouteConfiguration().

◆ isModuleIdLess()

static bool inet::Topology::isModuleIdLess ( Node a,
int  moduleId 
)
inlinestaticprotected
331 { return (unsigned int)a->moduleId < (unsigned int)moduleId; }

◆ lessByModuleId()

static bool inet::Topology::lessByModuleId ( Node a,
Node b 
)
inlinestaticprotected
330 { return (unsigned int)a->moduleId < (unsigned int)b->moduleId; }

Referenced by addNode(), and getNodeFor().

◆ operator=()

Topology & inet::Topology::operator= ( const Topology topo)

Assignment operator.

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

74 {
75  throw cRuntimeError(this, "operator= not implemented yet");
76 }

◆ parsimPack()

void inet::Topology::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.

64 {
65  throw cRuntimeError(this, "parsimPack() not implemented");
66 }

◆ parsimUnpack()

void inet::Topology::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.

69 {
70  throw cRuntimeError(this, "parsimUnpack() not implemented");
71 }

◆ str()

std::string inet::Topology::str ( ) const
overridevirtual

Produces a one-line description of the object's contents.

See cObject for more details.

57 {
58  std::stringstream out;
59  out << "n=" << nodes.size();
60  return out.str();
61 }

◆ unlinkFromDestNode()

void inet::Topology::unlinkFromDestNode ( Link link)
protected
341 {
342  std::vector<Link *>& destInLinks = link->destNode->inLinks;
343  auto it = find(destInLinks, link);
344  ASSERT(it != destInLinks.end());
345  destInLinks.erase(it);
346 }

Referenced by addLink(), deleteLink(), and deleteNode().

◆ unlinkFromSourceNode()

void inet::Topology::unlinkFromSourceNode ( Link link)
protected
333 {
334  std::vector<Link *>& srcOutLinks = link->srcNode->outLinks;
335  auto it = find(srcOutLinks, link);
336  ASSERT(it != srcOutLinks.end());
337  srcOutLinks.erase(it);
338 }

Referenced by addLink(), deleteLink(), and deleteNode().

Member Data Documentation

◆ nodes


The documentation for this class was generated from the following files:
inet::math::mod
double mod(double dividend, double divisor)
Returns the rest of a whole-numbered division.
Definition: INETMath.h:96
inet::Topology::lessByModuleId
static bool lessByModuleId(Node *a, Node *b)
Definition: Topology.h:330
inet::Topology::createLink
virtual Link * createLink()
Link factory.
Definition: Topology.h:565
inet::Topology::Topology
Topology(const char *name=nullptr)
Constructor.
Definition: Topology.cc:42
inet::Topology::unlinkFromDestNode
void unlinkFromDestNode(Link *link)
Definition: Topology.cc:340
inet::Topology::getNodeFor
Node * getNodeFor(cModule *mod) const
Returns the graph node which corresponds to the given module in the network.
Definition: Topology.cc:355
inet::remove
void remove(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:107
inet::find
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
inet::Topology::clear
void clear()
Deletes the topology stored in the object.
Definition: Topology.cc:78
inet::Topology::nodes
std::vector< Node * > nodes
Definition: Topology.h:327
inet::contains
bool contains(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:65
INFINITY
#define INFINITY
Definition: Topology.h:20
inet::Topology::unlinkFromSourceNode
void unlinkFromSourceNode(Link *link)
Definition: Topology.cc:332
inet::Topology::findNetworks
void findNetworks(Node *)
Definition: Topology.cc:469
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::Topology::createNode
virtual Node * createNode(cModule *module)
Node factory.
Definition: Topology.h:560
inet::Topology::extractFromNetwork
void extractFromNetwork(bool(*selfunc)(cModule *, void *), void *userdata=nullptr)
Extracts model topology by a user-defined criteria.
Definition: Topology.cc:184