![]() |
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 DLL_LAYER2_HPP 00029 #define DLL_LAYER2_HPP 00030 00031 #include <DLL/services/control/Association.hpp> 00032 #include <DLL/UpperConvergence.hpp> 00033 00034 #include <WNS/logger/Logger.hpp> 00035 #include <WNS/Enum.hpp> 00036 #include <WNS/ldk/fun/Main.hpp> 00037 #include <WNS/ldk/Layer.hpp> 00038 #include <WNS/node/component/Component.hpp> 00039 #include <WNS/pyconfig/View.hpp> 00040 #include <WNS/service/dll/Address.hpp> 00041 #include <WNS/container/Registry.hpp> 00042 00043 namespace dll { 00044 00045 class StationManager; 00046 class UpperConvergence; 00047 00048 class ILayer2: 00049 virtual public wns::ldk::ILayer 00050 { 00051 public: 00052 typedef long int StationIDType; 00053 00055 typedef long int StationType; 00056 00057 typedef std::vector<dll::services::control::AssociationInfo*> AssociationInfoContainer; 00058 00059 typedef wns::container::Registry< std::string, AssociationInfoContainer > AssociationInfoRegistry; 00060 00061 static StationIDType invalidStationID; 00062 static StationIDType broadcastStationID; 00063 00065 virtual StationIDType 00066 getID() const = 0; 00067 00069 virtual wns::service::dll::UnicastAddress 00070 getDLLAddress() const = 0; 00071 00073 virtual StationManager* 00074 getStationManager() = 0; 00075 00077 virtual StationType 00078 getStationType() const = 0; 00079 00081 virtual wns::ldk::fun::FUN* 00082 getFUN() const = 0; 00083 00088 virtual std::string 00089 getName() const = 0; 00090 00092 virtual wns::node::Interface* 00093 getNode() const = 0; 00094 00095 virtual void 00096 addAssociationInfoProvider( const std::string& id, dll::services::control::AssociationInfo* provider ) = 0; 00097 00098 virtual const AssociationInfoContainer& 00099 getAssociationInfoProvider(const std::string& id) const = 0; 00100 00101 virtual void 00102 updateContext(const std::string& key, int value) = 0; 00103 00104 virtual void 00105 setContext(const std::string& key, int value) = 0; 00106 }; 00107 00113 class Layer2 : 00114 public ILayer2, 00115 public wns::ldk::Layer, 00116 public wns::node::component::Component 00117 { 00118 public: 00119 00121 Layer2(wns::node::Interface*, const wns::pyconfig::View&, StationManager* sm); 00123 virtual ~Layer2(); 00124 00126 StationIDType getID() const; 00127 00129 wns::service::dll::UnicastAddress getDLLAddress() const; 00130 00132 virtual StationManager* getStationManager(); 00133 00135 StationType getStationType() const; 00136 00138 wns::ldk::fun::FUN* 00139 getFUN() const 00140 { 00141 return fun; 00142 } 00143 00148 virtual std::string getName() const; 00149 00151 virtual wns::node::Interface* getNode() const { return wns::node::component::Component::getNode(); }; 00152 00153 void 00154 addAssociationInfoProvider( const std::string& id, dll::services::control::AssociationInfo* provider ); 00155 00156 const AssociationInfoContainer& 00157 getAssociationInfoProvider(const std::string& id) const; 00158 00159 void 00160 updateContext(const std::string& key, int value) 00161 { 00162 agent.updateContext(key, value); 00163 } 00164 00165 void 00166 setContext(const std::string& key, int value) 00167 { 00168 agent.setContext(key, value); 00169 } 00170 00171 protected: 00172 Layer2(const Layer2&); // disallow copy constructor 00173 Layer2& operator=(const Layer2&); // disallow assignment 00174 00175 virtual void 00176 doStartup(); 00177 dll::UpperConvergence* dllUpperConvergence; 00178 00179 wns::ldk::fun::Main* fun; 00180 wns::pyconfig::View config; 00181 wns::logger::Logger logger; 00182 00183 StationManager* stationManager; 00184 00186 StationIDType stationID; 00188 StationType type; 00189 00191 wns::service::dll::UnicastAddress address; 00207 unsigned long int ring; 00208 00210 AssociationInfoRegistry air; 00211 00220 class ContextAgent : 00221 public wns::probe::bus::ContextProvider 00222 { 00226 wns::container::Registry<std::string, int> myContextInfo; 00227 typedef wns::container::Registry<std::string, int>::const_iterator ContextIterator; 00228 public: 00229 void 00230 updateContext(const std::string& key, int value) 00231 { 00232 myContextInfo.update(key, value); 00233 } 00234 00235 void 00236 setContext(const std::string& key, int value) 00237 { 00238 myContextInfo.insert(key, value); 00239 } 00240 bool 00241 knows(const std::string& key) 00242 { 00243 return myContextInfo.knows(key); 00244 } 00245 private: 00249 virtual void 00250 doVisit(wns::probe::bus::IContext&) const; 00251 00252 }; 00253 00254 ContextAgent agent; 00255 }; // Layer2 00256 } 00257 00258 #endif // NOT defined DLL_LAYER2_HPP 00259 00260
1.5.5