00001 /********** 00002 This library is free software; you can redistribute it and/or modify it under 00003 the terms of the GNU Lesser General Public License as published by the 00004 Free Software Foundation; either version 2.1 of the License, or (at your 00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) 00006 00007 This library is distributed in the hope that it will be useful, but WITHOUT 00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00009 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00010 more details. 00011 00012 You should have received a copy of the GNU Lesser General Public License 00013 along with this library; if not, write to the Free Software Foundation, Inc., 00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00015 **********/ 00016 // Copyright (c) 1996-2008 Live Networks, Inc. All rights reserved. 00017 // Basic Usage Environment: for a simple, non-scripted, console application 00018 // C++ header 00019 00020 #ifndef _HANDLER_SET_HH 00021 #define _HANDLER_SET_HH 00022 00024 00025 class HandlerDescriptor { 00026 HandlerDescriptor(HandlerDescriptor* nextHandler); 00027 virtual ~HandlerDescriptor(); 00028 00029 public: 00030 int socketNum; 00031 TaskScheduler::BackgroundHandlerProc* handlerProc; 00032 void* clientData; 00033 00034 private: 00035 // Descriptors are linked together in a doubly-linked list: 00036 friend class HandlerSet; 00037 friend class HandlerIterator; 00038 HandlerDescriptor* fNextHandler; 00039 HandlerDescriptor* fPrevHandler; 00040 }; 00041 00042 class HandlerSet { 00043 public: 00044 HandlerSet(); 00045 virtual ~HandlerSet(); 00046 00047 void assignHandler(int socketNum, 00048 TaskScheduler::BackgroundHandlerProc* handlerProc, 00049 void* clientData); 00050 void removeHandler(int socketNum); 00051 00052 private: 00053 friend class HandlerIterator; 00054 HandlerDescriptor fHandlers; 00055 }; 00056 00057 class HandlerIterator { 00058 public: 00059 HandlerIterator(HandlerSet& handlerSet); 00060 virtual ~HandlerIterator(); 00061 00062 HandlerDescriptor* next(); // returns NULL if none 00063 void reset(); 00064 00065 private: 00066 HandlerSet& fOurSet; 00067 HandlerDescriptor* fNextPtr; 00068 }; 00069 00070 #endif
1.5.2