![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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 <WNS/ldk/multiplexer/Dispatcher.hpp> 00029 #include <WNS/ldk/multiplexer/OpcodeSetter.hpp> 00030 00031 using namespace wns::ldk; 00032 using namespace wns::ldk::multiplexer; 00033 00034 STATIC_FACTORY_REGISTER_WITH_CREATOR(Dispatcher, wns::ldk::FunctionalUnit, 00035 "wns.multiplexer.Dispatcher", 00036 wns::ldk::FUNConfigCreator); 00037 00038 Dispatcher::Dispatcher(fun::FUN* fuNet, const pyconfig::View& _config) : 00039 CommandTypeSpecifier<OpcodeCommand>(fuNet), 00040 HasReceptor<RoundRobinReceptor>(), 00041 HasConnector<>(), 00042 HasDeliverer<OpcodeDeliverer>(), 00043 Processor<Dispatcher>(), 00044 Cloneable<Dispatcher>(), 00045 config(_config), 00046 opcodeSetters(), 00047 opcodeSize(config.get<int>("opcodeSize")), 00048 opcode(), 00049 logger(_config.get("logger")) 00050 { 00051 getDeliverer()->setOpcodeProvider(this); 00052 } 00053 00054 00055 Dispatcher::~Dispatcher() 00056 { 00057 // Call destructor for all opcodeSetters 00058 for(std::list<OpcodeSetter*>::const_iterator it = opcodeSetters.begin(); 00059 it != opcodeSetters.end();) 00060 { 00061 OpcodeSetter* opcodeSetter; 00062 opcodeSetter = (*it); 00063 ++it; 00064 00065 delete opcodeSetter; 00066 } 00067 00068 } 00069 00070 00071 FunctionalUnit* 00072 Dispatcher::whenConnecting() 00073 { 00074 MESSAGE_BEGIN(NORMAL, logger, m, getFUN()->getName()); 00075 m << " adding new OpcodeSetter for opcode " 00076 << opcode; 00077 MESSAGE_END(); 00078 00079 OpcodeSetter *opcodeSetter = new OpcodeSetter(getFUN(), this, config, opcode++); 00080 00081 opcodeSetters.push_front(opcodeSetter); 00082 00083 opcodeSetter->getConnector()->add(this); 00084 this->getReceptor()->add(opcodeSetter); 00085 00086 this->getDeliverer()->add(opcodeSetter); 00087 00088 return opcodeSetter; 00089 } // whenConnecting 00090 00091 00092 void 00093 Dispatcher::processOutgoing(const CompoundPtr& compound) 00094 { 00095 OpcodeCommand* command = getCommand(compound->getCommandPool()); 00096 00097 MESSAGE_BEGIN(NORMAL, logger, m, getFUN()->getName()); 00098 m << " sending opcode " 00099 << command->peer.opcode; 00100 MESSAGE_END(); 00101 } // processOutgoing 00102 00103 00104 void 00105 Dispatcher::processIncoming(const CompoundPtr& compound) 00106 { 00107 OpcodeCommand* command = getCommand(compound->getCommandPool()); 00108 00109 MESSAGE_BEGIN(NORMAL, logger, m, getFUN()->getName()); 00110 m << " delivering opcode " 00111 << command->peer.opcode; 00112 MESSAGE_END(); 00113 } // processIncoming 00114 00115 00116 void 00117 Dispatcher::calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& sduSize) const 00118 { 00119 getFUN()->calculateSizes(commandPool, commandPoolSize, sduSize, this); 00120 00121 commandPoolSize += opcodeSize; 00122 } // calculateSizes 00123 00124 00125
1.5.5