Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MNPipeNotifier.h

Go to the documentation of this file.
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_PIPENOTIFIER_H 00025 #define MN_OS_NET_PIPENOTIFIER_H 00026 00027 #include <config.h> 00028 #include <assert.h> 00029 00030 #include "mnstream.h" 00031 00032 #include "MNSocketBase.h" 00033 #include "MNValid.h" 00034 00035 class MNSelector; 00036 00037 class MNPipeNotifier 00038 : public MNSocketBase 00039 { 00040 enum RW 00041 { 00042 Read = 0, 00043 Write = 1, 00044 Both = 2 00045 }; 00046 00047 int _notepipe[Both]; 00048 DECLARE_VALID 00049 00050 public: 00051 MNPipeNotifier(); 00052 virtual ~MNPipeNotifier(); 00053 00054 virtual void callback ( MNSelector* select, int fd ); 00055 00056 virtual int get_sockdesc ( ) const; 00057 00058 /* 00059 * To be overloaded by the receiving side of the pipe. 00060 */ 00061 virtual void wokenUp(); 00062 virtual void closedDown(); 00063 00064 /* 00065 * To be used by the sending side of the pipe. 00066 */ 00067 void wakeup(); 00068 void closedown(); 00069 }; 00070 00071 template <class T> 00072 struct PipeNotifier : public MNPipeNotifier 00073 { 00074 typedef void (T::*callback)( ); 00075 00076 T* _client; 00077 callback _wokenup; 00078 callback _closedown; 00079 00080 PipeNotifier( T* client, callback wokenup, callback closedown ) 00081 : _client( client ) 00082 , _wokenup( wokenup ) 00083 , _closedown( closedown ) 00084 { 00085 } 00086 00087 virtual void wokenUp( ) 00088 { 00089 (_client->*_wokenup)( ); 00090 } 00091 00092 virtual void closedDown( ) 00093 { 00094 (_client->*_closedown)( ); 00095 } 00096 }; 00097 00098 #endif /* MN_OS_NET_PIPENOTIFIER_H */ 00099

Generated on Sun Mar 6 13:35:49 2005 for Komssys by doxygen 1.3.8