INET Framework for OMNeT++/OMNEST
inet::FindModule< T > Class Template Reference

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

#include <FindModule.h>

Static Public Member Functions

static T findSubModule (const cModule *const top)
 Returns a pointer to a sub module of the passed module with the type of this template. More...
 
static T findGlobalModule ()
 Returns a pointer to the module with the type of this template. More...
 
static cModule * findHost (cModule *m)
 Returns a pointer to the host module of the passed module. More...
 
static cModule * findNetwork (cModule *m)
 
static const cModule * findHost (const cModule *const m)
 
static const cModule * findNetwork (const cModule *const m)
 

Detailed Description

template<typename T = cModule *const>
class inet::FindModule< T >

Provides method templates to find omnet modules.

Member Function Documentation

template<typename T = cModule *const>
static T inet::FindModule< T >::findGlobalModule ( )
inlinestatic

Returns a pointer to the module with the type of this template.

Returns nullptr if no module of this type could be found.

47  {
48  return findSubModule(getSimulation()->getSystemModule());
49  }
static T findSubModule(const cModule *const top)
Returns a pointer to a sub module of the passed module with the type of this template.
Definition: FindModule.h:24
template<typename T = cModule *const>
static cModule* inet::FindModule< T >::findHost ( cModule *  m)
inlinestatic

Returns a pointer to the host module of the passed module.

Assumes that every host module is a direct sub module of the simulation.

Referenced by inet::FindModule< T >::findNetwork(), and inet::LMacLayer::handleSelfMessage().

58  {
59  return findContainingNode(m);
60  }
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:56
value< double, units::m > m
Definition: Units.h:1047
template<typename T = cModule *const>
static const cModule* inet::FindModule< T >::findHost ( const cModule *const  m)
inlinestatic
71  {
72  return const_cast<cModule *>(findContainingNode(m));
73  }
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:56
value< double, units::m > m
Definition: Units.h:1047
template<typename T = cModule *const>
static cModule* inet::FindModule< T >::findNetwork ( cModule *  m)
inlinestatic
63  {
64  cModule *node = findHost(m);
65 
66  return node ? node->getParentModule() : node;
67  }
static cModule * findHost(cModule *m)
Returns a pointer to the host module of the passed module.
Definition: FindModule.h:57
value< double, units::m > m
Definition: Units.h:1047
template<typename T = cModule *const>
static const cModule* inet::FindModule< T >::findNetwork ( const cModule *const  m)
inlinestatic
76  {
77  const cModule *node = findHost(m);
78 
79  return node ? node->getParentModule() : node;
80  }
static cModule * findHost(cModule *m)
Returns a pointer to the host module of the passed module.
Definition: FindModule.h:57
value< double, units::m > m
Definition: Units.h:1047
template<typename T = cModule *const>
static T inet::FindModule< T >::findSubModule ( const cModule *const  top)
inlinestatic

Returns a pointer to a sub module of the passed module with the type of this template.

Returns nullptr if no matching submodule could be found.

Referenced by inet::FindModule< T >::findGlobalModule(), and inet::AccessModuleWrap< T >::get().

25  {
26  for (cModule::SubmoduleIterator i(top); !i.end(); i++) {
27  cModule *const sub = *i;
28  // this allows also a return type of read only pointer: const cModule *const
29  T dCastRet = dynamic_cast<T>(sub);
30  if (dCastRet != nullptr)
31  return dCastRet;
32  // this allows also a return type of read only pointer: const cModule *const
33  T recFnd = findSubModule(sub);
34  if (recFnd != nullptr)
35  return recFnd;
36  }
37  return nullptr;
38  }
compose< Wb, pow< m,-2 > > T
Definition: Units.h:781
static T findSubModule(const cModule *const top)
Returns a pointer to a sub module of the passed module with the type of this template.
Definition: FindModule.h:24

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