#include <OverlayAccess.h>
Public Member Functions | |
BaseOverlay * | get (cModule *refMod) |
BaseOverlay* OverlayAccess::get | ( | cModule * | refMod | ) | [inline] |
00042 { 00043 // obtains the overlay related to the module, taking in account the index in case of SMOHs 00044 BaseOverlay *overlay = NULL; 00045 cModule *tmpMod = refMod; 00046 cModule *tmpParent = NULL; // parent of tmpMod 00047 00048 // go up from refMod until we get a NotificationBoard module, then we're at root 00049 // this will fail if the overlay is not in a container module! 00050 while (true) { 00051 tmpParent = tmpMod->parentModule(); // get parent 00052 // search for a "notificationBoard" module 00053 cModule *notBoard = tmpParent->submodule("notificationBoard"); 00054 // is this a real NotificationBoard? then we're at root 00055 if (dynamic_cast<NotificationBoard*>(notBoard) != NULL) break; 00056 tmpMod = tmpParent; // else keep going up 00057 if (!tmpParent) throw new cException("OverlayAccess::get(): Overlay module not found!"); 00058 } 00059 // get the overlay container, with the proper index 00060 cModule *overlayContainer = tmpParent->submodule("overlay", tmpMod->index()); 00061 overlay = dynamic_cast<BaseOverlay*> 00062 (overlayContainer->gate("from_app")->toGate()->ownerModule()); // get the contained overlay module 00063 00064 if (!overlay) throw new cException("OverlayAccess::get(): Overlay module not found!"); 00065 00066 return overlay; 00067 }