|
INET Framework for OMNeT++/OMNEST
|
00001 /*************************************************************************** 00002 * file: ChannelAccess.cc 00003 * 00004 * author: Marc Loebbers 00005 * 00006 * copyright: (C) 2004 Telecommunication Networks Group (TKN) at 00007 * Technische Universitaet Berlin, Germany. 00008 * 00009 * This program is free software; you can redistribute it 00010 * and/or modify it under the terms of the GNU General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2 of the License, or (at your option) any later 00013 * version. 00014 * For further information see file COPYING 00015 * in the top level directory 00016 *************************************************************************** 00017 * part of: framework implementation developed by tkn 00018 **************************************************************************/ 00019 00020 00021 #include "ChannelAccess.h" 00022 00023 00024 #define coreEV (ev.isDisabled()||!coreDebug) ? ev : ev << logName() << "::ChannelAccess: " 00025 00030 void ChannelAccess::initialize(int stage) 00031 { 00032 BasicModule::initialize(stage); 00033 00034 if (stage == 0) 00035 { 00036 cc = ChannelControl::get(); 00037 00038 // register to get a notification when position changes 00039 nb->subscribe(this, NF_HOSTPOSITION_UPDATED); 00040 } 00041 else if (stage == 2) 00042 { 00043 cModule *hostModule = findHost(); 00044 myHostRef = cc->lookupHost(hostModule); 00045 if (myHostRef==0) 00046 error("host not registered yet in ChannelControl (this should be done by " 00047 "the Mobility module -- maybe this host doesn't have one?)"); 00048 } 00049 } 00050 00051 00059 void ChannelAccess::sendToChannel(AirFrame *msg) 00060 { 00061 coreEV << "sendToChannel: sending to gates\n"; 00062 00063 // delegate it to ChannelControl 00064 cc->sendToChannel(this, myHostRef, msg); 00065 }