OverlayAccess.h
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
00024 #ifndef __OVERLAY_ACCESS_H__
00025 #define __OVERLAY_ACCESS_H__
00026
00027
00028 #include <omnetpp.h>
00029
00030 #include <BaseOverlay.h>
00031 #include <NotificationBoard.h>
00032
00036 class OverlayAccess
00037 {
00038 public:
00039
00040 BaseOverlay* get
00041 (cModule* refMod)
00042 {
00043
00044 BaseOverlay *overlay = NULL;
00045 cModule *tmpMod = refMod;
00046 cModule *tmpParent = NULL;
00047
00048
00049
00050 while (true) {
00051 tmpParent = tmpMod->getParentModule();
00052
00053 cModule *notBoard = tmpParent->getSubmodule("notificationBoard");
00054
00055 if (dynamic_cast<NotificationBoard*>(notBoard) != NULL) break;
00056 tmpMod = tmpParent;
00057 if (!tmpParent) throw cRuntimeError("OverlayAccess::get(): Overlay module not found!");
00058 }
00059
00060 cModule *overlayContainer = tmpParent->getSubmodule("overlay", tmpMod->getIndex());
00061 overlay = dynamic_cast<BaseOverlay*>
00062 (overlayContainer->gate("appIn")->getNextGate()->getOwnerModule());
00063
00064 if (!overlay) throw cRuntimeError("OverlayAccess::get(): Overlay module not found!");
00065
00066 return overlay;
00067 }
00068 };
00069
00070 #endif