![]() |
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_CONTROLSERVICEINTERFACE_HPP 00029 #define WNS_LDK_CONTROLSERVICEINTERFACE_HPP 00030 00031 #include <WNS/container/Registry.hpp> 00032 #include <WNS/StaticFactory.hpp> 00033 #include <WNS/PyConfigViewCreator.hpp> 00034 00035 00036 #include <string> 00037 00038 namespace wns { namespace ldk { 00039 00040 class ControlServiceInterface; 00041 class ILayer; 00042 00043 00047 class ControlServiceRegistry : 00048 public wns::container::Registry<std::string, ControlServiceInterface*, wns::container::registry::DeleteOnErase> 00049 { 00050 public: 00051 ControlServiceRegistry( wns::ldk::ILayer* _layer) 00052 : layer( _layer ) {} 00053 00054 virtual wns::ldk::ILayer* 00055 getLayer() const { return layer; } 00056 00060 template <typename LAYERTYPE> 00061 LAYERTYPE 00062 getLayer() const 00063 { 00064 wns::ldk::ILayer* aLayer = getLayer(); 00065 assureType(aLayer, LAYERTYPE); 00066 // we can't use C-Style downcasts here! 00067 return dynamic_cast<LAYERTYPE>(aLayer); 00068 } 00069 00070 void 00071 onCSRCreated(); 00072 private: 00073 wns::ldk::ILayer* layer; 00074 }; 00075 00076 00081 class ControlServiceInterface 00082 { 00083 public: 00084 virtual ControlServiceRegistry* 00085 getCSR() const = 0; 00086 00087 virtual 00088 ~ControlServiceInterface() 00089 {} 00090 00091 virtual void 00092 onCSRCreated() = 0; 00093 00094 }; 00095 00099 class ControlService : 00100 public virtual ControlServiceInterface 00101 { 00102 public: 00103 ControlService( ControlServiceRegistry* _csr) 00104 : csr( _csr ) {} 00105 00106 ControlServiceRegistry* 00107 getCSR() const 00108 { return csr; } 00109 00110 virtual void 00111 onCSRCreated(){}; 00112 00113 private: 00114 ControlServiceRegistry* csr; 00115 }; 00116 00123 template <typename T, typename KIND = T> 00124 struct CSRConfigCreator : 00125 public CSRConfigCreator<KIND, KIND> 00126 { 00127 virtual KIND* create(ControlServiceRegistry* csr, wns::pyconfig::View& config) 00128 { 00129 return new T(csr, config); 00130 } 00131 }; 00132 00133 template <typename KIND> 00134 struct CSRConfigCreator<KIND, KIND> 00135 { 00136 public: 00137 virtual KIND* create(ControlServiceRegistry*, wns::pyconfig::View&) = 0; 00138 00139 virtual ~CSRConfigCreator() 00140 {} 00141 }; 00142 00143 00144 typedef CSRConfigCreator<ControlServiceInterface> ControlServiceCreator; 00145 typedef StaticFactory<ControlServiceCreator> ControlServiceFactory; 00146 00147 }} 00148 00149 00150 #endif // NOT defined WNS_LDK_CONTROLSERVICEINTERFACE_HPP 00151 00152
1.5.5