![]() |
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/flowseparator/CreatorStrategy.hpp> 00029 #include <WNS/ldk/FUNConfigCreator.hpp> 00030 #include <WNS/ldk/fun/FUN.hpp> 00031 00032 using namespace wns::ldk::flowseparator; 00033 using namespace wns::ldk; 00034 00035 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00036 ConfigCreator, 00037 CreatorStrategy, 00038 "configcreator", 00039 FUNConfigCreator); 00040 00041 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00042 PrototypeCreator, 00043 CreatorStrategy, 00044 "prototypecreator", 00045 FUNConfigCreator); 00046 00047 00048 PrototypeCreator::PrototypeCreator(fun::FUN* fuNet, const pyconfig::View& config) 00049 { 00050 pyconfig::View layerConfig(config, "prototypeConfig"); 00051 std::string prototypeName = layerConfig.get<std::string>("__plugin__"); 00052 prototype = FunctionalUnitFactory::creator(prototypeName)->create(fuNet, layerConfig); 00053 00054 std::string commandName = config.get<std::string>("name"); 00055 std::string fuName = config.get<std::string>("fuName"); 00056 fuNet->addFunctionalUnit(commandName, fuName, prototype); 00057 } 00058 00059 00060 PrototypeCreator::PrototypeCreator(fun::FUN* fuNet, std::string name, FunctionalUnit* _prototype) : 00061 prototype(_prototype) 00062 { 00063 fuNet->addFunctionalUnit(name, prototype); 00064 } 00065 00066 00067 FunctionalUnit* 00068 PrototypeCreator::create() const 00069 { 00070 return dynamic_cast<FunctionalUnit*>(prototype->clone()); 00071 } 00072 00073 00074 FunctionalUnit* 00075 PrototypeCreator::createPrototype() const 00076 { 00077 return dynamic_cast<FunctionalUnit*>(prototype->clone()); 00078 } 00079 00080 00081 ConfigCreator::ConfigCreator(fun::FUN* _fun, const pyconfig::View& _config) : 00082 fun(_fun), 00083 config(_config.get("prototypeConfig")), 00084 creatorName(config.get<std::string>("__plugin__")), 00085 commandName(_config.get<std::string>("name")) 00086 { 00087 // TODO: rename logger such that the index can be seen, e.g. 00088 // ( 0.0187200) [ WNS] BS1.L2.BufferSep BS1: add Instance/Flow Key: UT address: 3, BS address: 1; FU: None 00089 // ( 0.0187521) [WinPr] BS1.L2.PriorityBuffer[BS=1,UT=3] 00090 FunctionalUnit* prototype = FunctionalUnitFactory::creator(creatorName)->create(fun, config); 00091 std::string fuName = _config.get<std::string>("fuName"); 00092 fun->addFunctionalUnit(commandName, fuName, prototype); 00093 } 00094 00095 FunctionalUnit* 00096 ConfigCreator::create() const 00097 { 00098 FunctionalUnit* fu = FunctionalUnitFactory::creator(creatorName)->create(fun, config); 00099 fun->getProxy()->addFunctionalUnit(commandName, fu); 00100 fu->onFUNCreated(); 00101 return fu; 00102 } 00103 00104 FunctionalUnit* 00105 ConfigCreator::createPrototype() const 00106 { 00107 FunctionalUnit* fu = FunctionalUnitFactory::creator(creatorName)->create(fun, config); 00108 return fu; 00109 }
1.5.5