![]() |
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. 16, 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_EVENTS_MEMBERFUNCTION_HPP 00029 #define WNS_EVENTS_MEMBERFUNCTION_HPP 00030 00031 #include <WNS/Functor.hpp> 00032 #include <WNS/PythonicOutput.hpp> 00033 #include <WNS/events/scheduler/Interface.hpp> 00034 #include <WNS/simulator/ISimulator.hpp> 00035 00036 #include <boost/bind.hpp> 00037 00038 namespace wns { namespace events { 00039 00046 template <typename T> 00047 class MemberFunction : 00048 public TFunctor<T>, 00049 public virtual PythonicOutput 00050 { 00051 public: 00052 MemberFunction(T* obj, typename TFunctor<T>::functionPointer fptr) : 00053 wns::TFunctor<T>(obj, fptr) 00054 { 00055 } 00056 00060 virtual 00061 ~MemberFunction() 00062 { 00063 } 00064 }; 00065 00073 template <typename T> 00074 class DelayedMemberFunction 00075 { 00076 public: 00080 DelayedMemberFunction( 00081 typename TFunctor<T>::functionPointer _fptr, 00082 wns::simulator::Time _delay) : 00083 fptr(_fptr), 00084 delay(_delay) 00085 { 00086 } 00087 00091 virtual 00092 ~DelayedMemberFunction() 00093 { 00094 } 00095 00099 virtual void 00100 operator()(T* obj) 00101 { 00102 wns::simulator::getInstance()->getEventScheduler()->scheduleDelay(boost::bind(fptr, obj), this->delay); 00103 } 00104 00108 virtual void 00109 operator()(T& obj) 00110 { 00111 wns::simulator::getInstance()->getEventScheduler()->scheduleDelay(boost::bind(fptr, &obj), this->delay); 00112 } 00113 private: 00114 typename TFunctor<T>::functionPointer fptr; 00115 wns::simulator::Time delay; 00116 }; 00117 00118 } // events 00119 } // wns 00120 00121 #endif // NOT defined WNS_EVENTS_MEMBERFUNCTION_HPP
1.5.5