Classes | Functions

ModuleAccess.h File Reference

#include <omnetpp.h>
#include "INETDefs.h"

Go to the source code of this file.

Classes

class  ModuleAccess< T >

Functions

INET_API cModule * findModuleWherever (const char *name, cModule *from)
INET_API cModule * findModuleWhereverInNode (const char *name, cModule *from)
INET_API cModule * findModuleSomewhereUp (const char *name, cModule *from)

Function Documentation

INET_API cModule* findModuleSomewhereUp ( const char *  name,
cModule *  from 
)

Find a module with given name, and "closest" to module "from".

Operation: gradually rises in the module hierarchy, and looks for a submodule of the given name.

Definition at line 61 of file ModuleAccess.cc.

{
    cModule *mod = NULL;
    for (cModule *curmod=from; !mod && curmod; curmod=curmod->getParentModule())
        mod = curmod->getSubmodule(name);
    return mod;
}

INET_API cModule* findModuleWherever ( const char *  name,
cModule *  from 
)

Find a module with given name, and "closest" to module "from".

Operation: gradually rises in the module hierarchy, and searches recursively among all submodules at every level.

Definition at line 41 of file ModuleAccess.cc.

{
    cModule *mod = NULL;
    for (cModule *curmod=from; !mod && curmod; curmod=curmod->getParentModule())
        mod = findSubmodRecursive(curmod, name);
    return mod;
}

INET_API cModule* findModuleWhereverInNode ( const char *  name,
cModule *  from 
)

Find a module with given name, and "closest" to module "from".

Operation: gradually rises in the module hierarchy up to the module, and searches recursively among all submodules at every level.

Definition at line 49 of file ModuleAccess.cc.

Referenced by ModuleAccess< ICMP >::get(), ModuleAccess< ICMP >::getIfExists(), and PPP::~PPP().

{
    cModule *mod = NULL;
    for (cModule *curmod=from; curmod; curmod=curmod->getParentModule())
    {
        mod = findSubmodRecursive(curmod, name);
        if (mod || isNode(curmod))
            break;
    }
    return mod;
}