![]() |
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 #ifndef WNS_LDK_LAYER_HPP 00029 #define WNS_LDK_LAYER_HPP 00030 00031 #include <WNS/node/Interface.hpp> 00032 #include <WNS/node/component/Interface.hpp> 00033 #include <WNS/ldk/ControlServiceInterface.hpp> 00034 #include <WNS/ldk/ManagementServiceInterface.hpp> 00035 00036 #include <string> 00037 00038 namespace wns { namespace ldk { 00039 00113 class ILayer : 00114 public virtual wns::node::component::Interface 00115 { 00116 public: 00117 virtual std::string 00118 getNodeName() const = 0; 00119 00120 virtual ControlServiceRegistry* 00121 getCSR() = 0; 00122 00123 virtual void 00124 addControlService(const std::string& name, ControlServiceInterface* csi) = 0; 00125 00126 virtual ManagementServiceRegistry* 00127 getMSR() = 0; 00128 00129 virtual void 00130 addManagementService(const std::string& name, ManagementServiceInterface* msi) = 0; 00131 00132 virtual ManagementServiceInterface* 00133 findManagementService(std::string) const = 0; 00134 00135 virtual ControlServiceInterface* 00136 findControlServiceInterface(std::string) const = 0; 00137 00138 template <typename MANAGEMENTSERVICE> 00139 MANAGEMENTSERVICE* 00140 getManagementService(const std::string& name) const 00141 { 00142 ManagementServiceInterface* msi = findManagementService(name); 00143 assureType(msi, MANAGEMENTSERVICE*); 00144 // we can't use C-Style downcasts here! 00145 return dynamic_cast<MANAGEMENTSERVICE*>(msi); 00146 } 00147 00148 template <typename CONTROLSERVICE> 00149 CONTROLSERVICE* 00150 getControlService(const std::string& name) const 00151 { 00152 ControlServiceInterface* csi = findControlServiceInterface(name); 00153 assureType(csi, CONTROLSERVICE*); 00154 // we can't use C-Style downcasts here! 00155 return dynamic_cast<CONTROLSERVICE*>(csi); 00156 } 00157 }; 00158 00166 class Layer : 00167 virtual public ILayer, 00168 public virtual wns::node::component::Interface 00169 { 00170 public: 00171 Layer() : managementServices( this ), controlServices( this ) {} 00172 00173 virtual std::string 00174 getNodeName() const 00175 { 00176 return getNode()->getName(); 00177 } 00178 00179 ControlServiceRegistry* 00180 getCSR() 00181 { 00182 return &controlServices; 00183 } 00184 00185 void 00186 addControlService(const std::string& name, ControlServiceInterface* csi) 00187 { 00188 controlServices.insert(name, csi); 00189 } 00190 00191 ManagementServiceRegistry* 00192 getMSR() 00193 { 00194 return &managementServices; 00195 } 00196 00197 void 00198 addManagementService(const std::string& name, ManagementServiceInterface* msi) 00199 { 00200 managementServices.insert(name, msi); 00201 } 00202 00203 virtual ManagementServiceInterface* 00204 findManagementService(std::string name) const 00205 { 00206 return managementServices.find(name); 00207 } 00208 00209 virtual ControlServiceInterface* 00210 findControlServiceInterface(std::string name) const 00211 { 00212 return controlServices.find(name); 00213 } 00214 00215 private: 00216 ManagementServiceRegistry managementServices; 00217 ControlServiceRegistry controlServices; 00218 00219 }; 00220 }} 00221 00222 00223 #endif // NOT defined WNS_LDK_LAYER_HPP 00224 00225
1.5.5