![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * WiMeMac * 00003 * This file is part of openWNS (open Wireless Network Simulator) 00004 * _____________________________________________________________________________ 00005 * 00006 * Copyright (C) 2004-2011 00007 * Chair of Communication Networks (ComNets) 00008 * Kopernikusstr. 5, D-52074 Aachen, Germany 00009 * phone: ++49-241-80-27910, 00010 * fax: ++49-241-80-22242 00011 * email: info@openwns.org 00012 * www: http://www.openwns.org 00013 * _____________________________________________________________________________ 00014 * 00015 * openWNS is free software; you can redistribute it and/or modify it under the 00016 * terms of the GNU Lesser General Public License version 2 as published by the 00017 * Free Software Foundation; 00018 * 00019 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00020 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00021 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00022 * details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00026 * 00027 ******************************************************************************/ 00028 00029 #ifndef WIMEMAC_CONVERGENCE_ICHANNELSTATE_HPP 00030 #define WIMEMAC_CONVERGENCE_ICHANNELSTATE_HPP 00031 00032 #include <WNS/Subject.hpp> 00033 00034 namespace wimemac { namespace convergence { 00035 00036 // The indicator for the channel state 00037 enum CS { 00038 idle, 00039 busy 00040 }; 00041 00043 class IChannelState 00044 { 00045 public: 00046 virtual ~IChannelState(){}; 00047 00048 virtual void onChannelBusy() = 0; 00049 virtual void onChannelIdle() = 0; 00050 }; 00051 00052 class ChannelStateNotification : 00053 virtual public wns::Subject<IChannelState> 00054 { 00055 public: 00056 // @brief functor for IChannelState::onChangedCS calls 00057 struct OnChangedCS 00058 { 00059 OnChangedCS(const CS _newCS): 00060 newCS(_newCS) 00061 {} 00062 00063 void operator()(IChannelState* cs) 00064 { 00065 // The functor calls the onChannelBusy/onChannelIdle implemented by the 00066 // Observer 00067 if (newCS == idle) 00068 cs->onChannelIdle(); 00069 else 00070 cs->onChannelBusy(); 00071 } 00072 private: 00073 CS newCS; 00074 }; 00075 00076 }; 00077 00078 00079 } 00080 } 00081 00082 #endif // not defined WIMEMAC_CONVERGENCE_ICHANNELSTATE_HPP
1.5.5