Gives access to the overlay. More...
#include <OverlayAccess.h>
Public Member Functions | |
BaseOverlay * | get (cModule *refMod) |
Gives access to the overlay.
Definition at line 36 of file OverlayAccess.h.
BaseOverlay* OverlayAccess::get | ( | cModule * | refMod | ) | [inline] |
Definition at line 41 of file OverlayAccess.h.
{ // obtains the overlay related to the module, taking in account the index in case of SMOHs BaseOverlay *overlay = NULL; cModule *tmpMod = refMod; cModule *tmpParent = NULL; // parent of tmpMod // go up from refMod until we get a NotificationBoard module, then we're at root // this will fail if the overlay is not in a container module! while (true) { tmpParent = tmpMod->getParentModule(); // get parent // search for a "notificationBoard" module cModule *notBoard = tmpParent->getSubmodule("notificationBoard"); // is this a real NotificationBoard? then we're at root if (dynamic_cast<NotificationBoard*>(notBoard) != NULL) break; tmpMod = tmpParent; // else keep going up if (!tmpParent) throw cRuntimeError("OverlayAccess::get(): Overlay module not found!"); } // get the overlay container, with the proper index cModule *overlayContainer = tmpParent->getSubmodule("overlay", tmpMod->getIndex()); overlay = dynamic_cast<BaseOverlay*> (overlayContainer->gate("appIn")->getNextGate()->getOwnerModule()); // get the contained overlay module if (!overlay) throw cRuntimeError("OverlayAccess::get(): Overlay module not found!"); return overlay; }