Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "ModuleAccess.h"
00020
00021 inline bool isNode(cModule *mod)
00022 {
00023 cProperties *props = mod->getProperties();
00024 return props && props->getAsBool("node");
00025 }
00026
00027 static cModule *findSubmodRecursive(cModule *curmod, const char *name)
00028 {
00029 for (cModule::SubmoduleIterator i(curmod); !i.end(); i++)
00030 {
00031 cModule *submod = i();
00032 if (!strcmp(submod->getFullName(), name))
00033 return submod;
00034 cModule *foundmod = findSubmodRecursive(submod, name);
00035 if (foundmod)
00036 return foundmod;
00037 }
00038 return NULL;
00039 }
00040
00041 cModule *findModuleWherever(const char *name, cModule *from)
00042 {
00043 cModule *mod = NULL;
00044 for (cModule *curmod=from; !mod && curmod; curmod=curmod->getParentModule())
00045 mod = findSubmodRecursive(curmod, name);
00046 return mod;
00047 }
00048
00049 cModule *findModuleWhereverInNode(const char *name, cModule *from)
00050 {
00051 cModule *mod = NULL;
00052 for (cModule *curmod=from; curmod; curmod=curmod->getParentModule())
00053 {
00054 mod = findSubmodRecursive(curmod, name);
00055 if (mod || isNode(curmod))
00056 break;
00057 }
00058 return mod;
00059 }
00060
00061 cModule *findModuleSomewhereUp(const char *name, cModule *from)
00062 {
00063 cModule *mod = NULL;
00064 for (cModule *curmod=from; !mod && curmod; curmod=curmod->getParentModule())
00065 mod = curmod->getSubmodule(name);
00066 return mod;
00067 }
00068