00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef MN_OS_NET_TIMERCALL_H 00025 #define MN_OS_NET_TIMERCALL_H 00026 00027 /************************************************************* 00028 * Name: MNTimerCall 00029 * Short: call back for Timer 00030 */ 00031 00032 class MNTimer; 00033 class MNSelector; 00034 00035 class TimerCallBase 00036 { 00037 public: 00038 static const bool DoClean = true; 00039 static const bool DontClean = false; 00040 00050 TimerCallBase( bool clean ) : _clean(clean) { } 00051 00056 virtual ~TimerCallBase( ) { } 00057 00062 virtual void timer_callback ( void* data, TimerCallBase* self ) = 0; 00063 00074 virtual inline bool cleanup( ) const { 00075 return _clean; 00076 } 00077 00078 private: 00079 bool _clean; 00080 }; 00081 00082 template <class T> 00083 struct TimerCall : public TimerCallBase 00084 { 00085 typedef void (T::*callback)( void* data, TimerCallBase* self ); 00086 00087 T* _client; 00088 callback _fun; 00089 00090 TimerCall( bool clean, T* client, callback fun ) 00091 : TimerCallBase( clean ) 00092 , _client( client ) 00093 , _fun( fun ) 00094 { 00095 } 00096 00097 void timer_callback( void* data, TimerCallBase* self ) 00098 { 00099 (_client->*_fun)( data, self ); 00100 } 00101 }; 00102 00103 #endif /* MN_OS_NET_SOCKETBASE_H */ 00104