![]() |
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_SERVICES_ASSOCIATION_HPP 00029 #define DLL_SERVICES_ASSOCIATION_HPP 00030 00031 #include <WNS/ldk/ControlServiceInterface.hpp> 00032 #include <WNS/service/dll/Address.hpp> 00033 #include <WNS/pyconfig/View.hpp> 00034 #include <WNS/logger/Logger.hpp> 00035 #include <WNS/Subject.hpp> 00036 #include <WNS/Observer.hpp> 00037 00038 #include <vector> 00039 #include <list> 00040 00041 namespace dll { 00042 class ILayer2; 00043 class StationManager; 00044 } 00045 namespace dll { namespace services { namespace control { 00046 00047 class AssociationObserverInterface 00048 { 00049 public: 00050 virtual 00051 void onAssociated(wns::service::dll::UnicastAddress userAdr, 00052 wns::service::dll::UnicastAddress dstAdr) = 0; 00053 00054 virtual 00055 void onDisassociated(wns::service::dll::UnicastAddress userAdr, 00056 wns::service::dll::UnicastAddress dstAdr) = 0; 00057 00058 virtual 00059 ~AssociationObserverInterface(){}; 00060 }; 00061 00062 00063 class AssociationFunctor 00064 { 00065 typedef void (AssociationObserverInterface::*fPtr)(wns::service::dll::UnicastAddress, wns::service::dll::UnicastAddress); 00066 00067 fPtr f; 00068 wns::service::dll::UnicastAddress user; 00069 wns::service::dll::UnicastAddress dst; 00070 public: 00071 AssociationFunctor(fPtr _f, 00072 wns::service::dll::UnicastAddress _user, 00073 wns::service::dll::UnicastAddress _dst) : 00074 f(_f), 00075 user(_user), 00076 dst(_dst) 00077 {} 00078 00079 void 00080 operator()(AssociationObserverInterface* observer) 00081 { 00082 (*observer.*f)(user, dst); 00083 } 00084 }; 00085 00086 typedef wns::Subject<AssociationObserverInterface> AssociationInfo; 00087 typedef wns::Observer<AssociationObserverInterface> AssociationObserver; 00088 00090 class Association : 00091 public wns::ldk::ControlService, 00092 public AssociationInfo 00093 { 00094 public: 00095 Association( wns::ldk::ControlServiceRegistry* csr, const wns::pyconfig::View& config); 00096 virtual ~Association(){} 00097 00101 wns::service::dll::UnicastAddress 00102 getAssociation(); 00104 bool 00105 hasAssociation(); 00107 bool 00108 hasAssociated(const wns::service::dll::UnicastAddress& slave) const; 00111 std::vector<wns::service::dll::UnicastAddress> 00112 getAssociated(); 00114 00118 void 00119 associate(wns::service::dll::UnicastAddress slave, wns::service::dll::UnicastAddress master); 00121 void 00122 associate(dll::ILayer2* slave, dll::ILayer2* master); 00124 void 00125 releaseFromMaster(); 00126 00128 void 00129 releaseClient(dll::ILayer2*); 00131 void 00132 releaseClient(wns::service::dll::UnicastAddress slave); 00134 00135 private: 00137 void 00138 registerAssociation(wns::service::dll::UnicastAddress slave, wns::service::dll::UnicastAddress master); 00139 00140 wns::ldk::ControlServiceRegistry* csr_; 00141 00143 std::string serviceName_; 00144 00146 wns::service::dll::UnicastAddress masterStation_; 00148 std::list<wns::service::dll::UnicastAddress> slaveStations_; 00149 00151 //std::list<AssociationObserver*> observers; 00152 00154 wns::logger::Logger logger_; 00155 00157 dll::StationManager* stationManager_; 00158 }; 00159 } 00160 } 00161 } 00162 00163 #endif // NOT defined DLL_SERVICES_ASSOCIATION_HPP 00164 00165 00166
1.5.5