![]() |
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 <APPLICATIONS/node/component/server/Component.hpp> 00029 00030 using namespace applications::node::component::server; 00031 00032 STATIC_FACTORY_REGISTER_WITH_CREATOR(applications::node::component::server::Component, 00033 wns::node::component::Interface, 00034 "applications.component.Server", 00035 wns::node::component::ConfigCreator); 00036 00037 Component::Component(wns::node::Interface* _node, 00038 const wns::pyconfig::View& _pyco) : 00039 applications::node::component::Component(_node, _pyco), 00040 pyco(_pyco), 00041 logger(_pyco.get("logger")) 00042 { 00043 } 00044 00045 Component::~Component() 00046 { 00047 } 00048 00049 void 00050 Component::onNodeCreated() 00051 { 00052 for(int i = 0; i < pyco.len("listenerBindings"); ++i) 00053 { 00054 // create the listener's binding, either TCP or UDP 00055 wns::pyconfig::View listenerBindingConfig = pyco.get("listenerBindings", i); 00056 std::string plugin = listenerBindingConfig.get<std::string>("__plugin__"); 00057 applications::session::Binding::Creator* listenerBindingCreator = 00058 applications::session::Binding::Factory::creator(plugin); 00059 listenerBinding = listenerBindingCreator->create(listenerBindingConfig); 00060 00061 listenerBinding->registerComponent(this, i); 00062 00063 registerListeners(i, listenerBinding); 00064 } 00065 } 00066 00067 00068 void 00069 Component::registerListeners(int _i, applications::session::Binding* _binding) 00070 { 00071 bindingMap[_i] = _binding; 00072 } 00073 00074 void 00075 Component::onShutdown() 00076 { 00077 for(mapType::const_iterator it = bindingMap.begin(); it != bindingMap.end(); ++it) 00078 { 00079 (it->second)->onShutdown(); 00080 } 00081 00082 for(mapType::const_iterator it = bindingMap.begin(); it != bindingMap.end(); ++it) 00083 { 00084 delete (it->second); 00085 } 00086 }
1.5.5