![]() |
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_MANAGEMENTSERVICEINTERFACE_HPP 00029 #define WNS_LDK_MANAGEMENTSERVICEINTERFACE_HPP 00030 00031 #include <WNS/container/Registry.hpp> 00032 #include <WNS/StaticFactory.hpp> 00033 #include <WNS/PyConfigViewCreator.hpp> 00034 00035 #include <string> 00036 00037 namespace wns { namespace ldk { 00038 00039 class ManagementServiceInterface; 00040 class ILayer; 00041 00045 class ManagementServiceRegistry : 00046 public wns::container::Registry<std::string, ManagementServiceInterface*, wns::container::registry::DeleteOnErase> 00047 { 00048 public: 00049 ManagementServiceRegistry( wns::ldk::ILayer* _layer ) 00050 : layer( _layer ) {} 00051 00052 virtual wns::ldk::ILayer* 00053 getLayer() const { return layer; } 00054 00058 template <typename LAYERTYPE> 00059 LAYERTYPE 00060 getLayer() const 00061 { 00062 wns::ldk::ILayer* aLayer = getLayer(); 00063 assureType(aLayer, LAYERTYPE); 00064 // we can't use C-Style downcasts here! 00065 return dynamic_cast<LAYERTYPE>(aLayer); 00066 } 00067 00072 void 00073 onMSRCreated(); 00074 00075 private: 00076 wns::ldk::ILayer* layer; 00077 }; 00078 00083 class ManagementServiceInterface 00084 { 00085 public: 00086 virtual ManagementServiceRegistry* 00087 getMSR() const = 0; 00088 00089 virtual 00090 ~ManagementServiceInterface() 00091 {} 00092 00093 virtual void 00094 onMSRCreated() = 0; 00095 }; 00096 00097 class ManagementService : 00098 public virtual ManagementServiceInterface 00099 { 00100 public: 00101 ManagementService( ManagementServiceRegistry* _msr) 00102 : msr( _msr ) 00103 {} 00104 00105 ManagementServiceRegistry* 00106 getMSR() const 00107 { return msr; } 00108 00109 virtual void 00110 onMSRCreated(){} 00111 00112 private: 00113 ManagementServiceRegistry* msr; 00114 }; 00115 00122 template <typename T, typename KIND = T> 00123 struct MSRConfigCreator : 00124 public MSRConfigCreator<KIND, KIND> 00125 { 00126 virtual KIND* create(ManagementServiceRegistry* msr, wns::pyconfig::View& config) 00127 { 00128 return new T(msr, config); 00129 } 00130 }; 00131 00132 template <typename KIND> 00133 struct MSRConfigCreator<KIND, KIND> 00134 { 00135 public: 00136 virtual KIND* create(ManagementServiceRegistry*, wns::pyconfig::View&) = 0; 00137 00138 virtual ~MSRConfigCreator() 00139 {} 00140 }; 00141 00142 00143 typedef MSRConfigCreator<ManagementServiceInterface> ManagementServiceCreator; 00144 typedef StaticFactory<ManagementServiceCreator> ManagementServiceFactory; 00145 00146 } // ldk 00147 } // wns 00148 00149 00150 #endif // NOT defined WNS_LDK_MANAGEMENTSERVICEINTERFACE_HPP 00151 00152
1.5.5