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-2012 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 00023 #ifndef _BOOLEAN_HH 00024 #include "Boolean.hh" 00025 #endif 00026 00028 00029 class HandlerDescriptor { 00030 HandlerDescriptor(HandlerDescriptor* nextHandler); 00031 virtual ~HandlerDescriptor(); 00032 00033 public: 00034 int socketNum; 00035 int conditionSet; 00036 TaskScheduler::BackgroundHandlerProc* handlerProc; 00037 void* clientData; 00038 00039 private: 00040 // Descriptors are linked together in a doubly-linked list: 00041 friend class HandlerSet; 00042 friend class HandlerIterator; 00043 HandlerDescriptor* fNextHandler; 00044 HandlerDescriptor* fPrevHandler; 00045 }; 00046 00047 class HandlerSet { 00048 public: 00049 HandlerSet(); 00050 virtual ~HandlerSet(); 00051 00052 void assignHandler(int socketNum, int conditionSet, TaskScheduler::BackgroundHandlerProc* handlerProc, void* clientData); 00053 void clearHandler(int socketNum); 00054 void moveHandler(int oldSocketNum, int newSocketNum); 00055 00056 private: 00057 HandlerDescriptor* lookupHandler(int socketNum); 00058 00059 private: 00060 friend class HandlerIterator; 00061 HandlerDescriptor fHandlers; 00062 }; 00063 00064 class HandlerIterator { 00065 public: 00066 HandlerIterator(HandlerSet& handlerSet); 00067 virtual ~HandlerIterator(); 00068 00069 HandlerDescriptor* next(); // returns NULL if none 00070 void reset(); 00071 00072 private: 00073 HandlerSet& fOurSet; 00074 HandlerDescriptor* fNextPtr; 00075 }; 00076 00077 #endif
1.5.2