User Manual, Developers Guide and API Documentation

SimpleLinkHandler.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #include "SimpleLinkHandler.hpp"
00029 
00030 #include <WNS/ldk/fun/FUN.hpp>
00031 #include <WNS/ldk/FunctionalUnit.hpp>
00032 #include <WNS/ldk/PyConfigCreator.hpp>
00033 
00034 #include <WNS/module/Base.hpp>
00035 
00036 using namespace wns::ldk;
00037 
00038 STATIC_FACTORY_REGISTER_WITH_CREATOR(SimpleLinkHandler,
00039                                      LinkHandlerInterface,
00040                                      "wns.ldk.SimpleLinkHandler",
00041                                      wns::ldk::PyConfigCreator);
00042 
00043 SimpleLinkHandler::SimpleLinkHandler(const wns::pyconfig::View& _config) :
00044     config(_config),
00045     traceCompoundJourney(config.get<bool>("traceCompoundJourney")),
00046     isAcceptingLogger(config.get<wns::pyconfig::View>("isAcceptingLogger")),
00047     sendDataLogger(config.get<wns::pyconfig::View>("sendDataLogger")),
00048     wakeupLogger(config.get<wns::pyconfig::View>("wakeupLogger")),
00049     onDataLogger(config.get<wns::pyconfig::View>("onDataLogger"))
00050 {
00051 } // SimpleLinkHandler
00052 
00053 bool
00054 SimpleLinkHandler::isAccepting(IConnectorReceptacle* cr, const CompoundPtr& compound)
00055 {
00056     MESSAGE_BEGIN(VERBOSE, isAcceptingLogger, m, cr->getFU()->getFUN()->getName());
00057     m << " calling doIsAccepting of FU "
00058       << cr->getFU()->getName();
00059     MESSAGE_END();
00060 
00061     bool isAccepting = doIsAccepting(cr, compound);
00062 
00063     MESSAGE_BEGIN(VERBOSE, isAcceptingLogger, m, cr->getFU()->getFUN()->getName());
00064     m << " function isAccepting(...) of FU "
00065       << cr->getFU()->getName() << " called: FU is ";
00066     if (isAccepting)
00067         m << "accepting";
00068     else
00069         m << "not accepting";
00070     m << "\ncompound: " << compound.getPtr();
00071     MESSAGE_END();
00072 
00073     return isAccepting;
00074 } // isAcceptingForwarded
00075 
00076 void
00077 SimpleLinkHandler::sendData(IConnectorReceptacle* cr, const CompoundPtr& compound)
00078 {
00079     MESSAGE_BEGIN(VERBOSE, sendDataLogger, m, cr->getFU()->getFUN()->getName());
00080     m << " function sendData(...) of FU "
00081       << cr->getFU()->getName() << " called"
00082       << "\ncompound: " << compound.getPtr();
00083     MESSAGE_END();
00084 
00085 #ifndef WNS_NO_LOGGING
00086     if (traceCompoundJourney && compound)
00087         compound->visit(cr->getFU()); // JOURNEY
00088 #endif
00089 
00090     doSendData(cr, compound);
00091 } // sendDataForwarded
00092 
00093 void
00094 SimpleLinkHandler::wakeup(IReceptorReceptacle* rr)
00095 {
00096     MESSAGE_BEGIN(VERBOSE, wakeupLogger, m, rr->getFU()->getFUN()->getName());
00097     m << " function wakeup(...) of FU "
00098       << rr->getFU()->getName() << " called";
00099     MESSAGE_END();
00100 
00101     doWakeup(rr);
00102 } // wakeupForwarded
00103 
00104 void
00105 SimpleLinkHandler::onData(IDelivererReceptacle* dr, const CompoundPtr& compound)
00106 {
00107     MESSAGE_BEGIN(VERBOSE, onDataLogger, m, dr->getFU()->getFUN()->getName());
00108     m << " function onData(...) of FU "
00109       << dr->getFU()->getName() << " called"
00110       << "\ncompound: " << compound.getPtr();
00111     MESSAGE_END();
00112 
00113 #ifndef WNS_NO_LOGGING
00114     if (traceCompoundJourney && compound)
00115         compound->visit(dr->getFU()); // JOURNEY
00116 #endif
00117 
00118     doOnData(dr, compound);
00119 } // onDataForwarded
00120 
00121 

Generated on Fri May 25 03:31:47 2012 for openWNS by  doxygen 1.5.5