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

RefCountedSocketFactory.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_RTP_REF_COUNTED_SOCKET_FACTORY_H 00025 #define MN_RTP_REF_COUNTED_SOCKET_FACTORY_H 00026 00027 #include <assert.h> 00028 #include <stdio.h> 00029 #include <sys/types.h> 00030 00031 #include "MNArrayList.h" 00032 #include "MNUDPServerSocket.h" 00033 #include "MNMutex.h" 00034 #include "dictionary.h" 00035 00036 class RefCountedSocket; 00037 class RefCountedSocketFactory; 00038 class RefCountingSocket; 00039 00040 /**********************************************************************/ 00041 /* RefCountedSocketFactory */ 00042 /**********************************************************************/ 00043 00050 class RefCountedSocketFactory 00051 { 00052 struct dict_entry 00053 { 00054 MNMutex lck; 00055 int port; 00056 RefCountedSocket* ptr; 00057 00058 dict_entry( int p ) 00059 { 00060 ptr = NULL; 00061 port = p; 00062 } 00063 00064 ~dict_entry() 00065 { 00066 lck.lock(); 00067 lck.unlock(); 00068 } 00069 }; 00070 00091 RefCountedSocket* find( int port, dict_entry*& newentry ); 00092 00093 MNMutex _lock; 00094 dictionary<int,dict_entry*> _existing; 00095 public: 00098 RefCountedSocket* get( MNSelector& sel, int port ); 00099 00102 RefCountedSocket* get( MNSelector& sel, MNSocket& sock ); 00103 00114 void release( void* v ); 00115 00116 void del( RefCountedSocket* r ); 00117 00118 static RefCountedSocketFactory& factory( ); 00119 }; 00120 00121 00122 #endif /* MN_RTP_REF_COUNTED_SOCKET_FACTORY_H */ 00123

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