OMNeT++ Simulation Library  5.6.1
cModule::ChannelIterator Class Reference

#include <cmodule.h>

Description

Walks along the channels inside a module, that is, the channels among the module and its submodules.

This is the same set of channels whose getParentModule() would return the iterated module.

Implementation note:

This iterator precollects the channels into an internal std::vector, then iterates over that. This means that (1) changes made during the iterator's lifetime will not be reflected in the iterator, and (2) copying the iterator is expensive. As a result of (2), no postfix increment/decrement iterators are provided to prevent their accidental use instead of the prefix operators. (Their lack can be trivially circumvented where needed.)

Usage:

for (cModule::ChannelIterator it(module); !it.end(); ++it) {
cChannel *channel = *it;
...
}

Public Member Functions

 ChannelIterator (const cModule *parentModule)
 
void init (const cModule *parentModule)
 
cChanneloperator* () const
 
_OPPDEPRECATED cChanneloperator() () const
 
bool end () const
 
ChannelIteratoroperator++ ()
 
ChannelIteratoroperator-- ()
 

Constructor & Destructor Documentation

◆ ChannelIterator()

ChannelIterator ( const cModule parentModule)

Constructor. The iterator will walk on the module passed as argument.

Member Function Documentation

◆ init()

void init ( const cModule parentModule)

Reinitializes the iterator object.

◆ operator*()

cChannel* operator* ( ) const
inline

Returns a pointer to the current channel. Returns nullptr if the iterator has reached the end of the list.

◆ operator()()

_OPPDEPRECATED cChannel* operator() ( ) const
inline

DEPRECATED. Use the * operator to access the object the iterator is at.

◆ end()

bool end ( ) const
inline

Returns true if the iterator has reached the end.

◆ operator++()

ChannelIterator& operator++ ( )
inline

Prefix increment operator (++it). Moves the iterator to the next channel in the list. It has no effect if the iterator has reached either end of the list.

Note: postfix increment/decrement operators are not provided, to avoid large unnecessary copying overhead resulting from accidental use.

◆ operator--()

ChannelIterator& operator-- ( )
inline

Prefix decrement operator (–it). Moves the iterator to the previous channel in the list. It has no effect if the iterator has reached either end of the list.

Note: postfix increment/decrement operators are not provided, to avoid large unnecessary copying overhead resulting from accidental use.


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