00040 {
00041 BaseOverlay* overlay = NULL;
00042 cModule* tmpMod = refMod;
00043
00044 while (overlay == NULL) {
00045 cModule* subMod = tmpMod->submodule("overlay");
00046 if (subMod != NULL) {
00047 overlay = dynamic_cast<BaseOverlay*>(tmpMod->parentModule()->
00048 submodule("overlay"));
00049 if (overlay == NULL) {
00050 cGate* tmpGate = subMod->gate("from_app");
00051 if (tmpGate != NULL) {
00052 overlay = dynamic_cast<BaseOverlay*>(tmpGate->
00053 destinationGate()->ownerModule());
00054 }
00055 }
00056
00057 }
00058 tmpMod = tmpMod->parentModule();
00059 if (tmpMod == NULL) {
00060 throw new cException("OverlayAccess::get(): Overlay module "
00061 "not found!");
00062 }
00063 }
00064 return overlay;
00065 }