Provides method templates to find omnet modules. More...
#include <FindModule.h>
Static Public Member Functions | |
static T | findSubModule (cModule *top) |
Returns a pointer to a sub module of the passed module with the type of this template. | |
static T | findGlobalModule () |
Returns a pointer to the module with the type of this template. | |
static cModule * | findHost (cModule *m) |
Returns a pointer to the host module of the passed module. |
Provides method templates to find omnet modules.
Definition at line 13 of file FindModule.h.
static T FindModule< T >::findGlobalModule | ( | ) | [inline, static] |
Returns a pointer to the module with the type of this template.
Returns NULL if no module of this type could be found.
Definition at line 44 of file FindModule.h.
References FindModule< T >::findSubModule().
{return findSubModule(simulation.getSystemModule());}
static cModule* FindModule< T >::findHost | ( | cModule * | m | ) | [inline, static] |
Returns a pointer to the host module of the passed module.
Assumes that every host module is a direct sub module of the simulation.
Definition at line 52 of file FindModule.h.
{ cModule *parent = m->getParentModule(); cModule *node = m; // all nodes should be a sub module of the simulation which has no parent module!!! while( parent->getParentModule() != NULL ){ node = parent; parent = node->getParentModule(); } return node; }
static T FindModule< T >::findSubModule | ( | cModule * | top | ) | [inline, static] |
Returns a pointer to a sub module of the passed module with the type of this template.
Returns NULL if no matching submodule could be found.
Definition at line 22 of file FindModule.h.
Referenced by FindModule< T >::findGlobalModule().
{ T ret; for (cModule::SubmoduleIterator i(top); !i.end(); i++) { cModule *sub = i(); ret = dynamic_cast<T>(sub); if (ret!=NULL) return ret; ret = findSubModule(sub); if (ret!=NULL) return ret; } return NULL; }