Static Public Member Functions

FindModule< T > Class Template Reference
[baseUtils - utilities for base MiXiMutils - utility classes]

Provides method templates to find omnet modules. More...

#include <FindModule.h>

List of all members.

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.

Detailed Description

template<typename T = cModule*>
class FindModule< T >

Provides method templates to find omnet modules.

Definition at line 13 of file FindModule.h.


Member Function Documentation

template<typename T = cModule*>
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());}

template<typename T = cModule*>
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;
    }

template<typename T = cModule*>
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;
    }


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