1 | /********** |
2 | This library is free software; you can redistribute it and/or modify it under |
3 | the terms of the GNU Lesser General Public License as published by the |
4 | Free Software Foundation; either version 3 of the License, or (at your |
5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) |
6 | |
7 | This library is distributed in the hope that it will be useful, but WITHOUT |
8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
10 | more details. |
11 | |
12 | You should have received a copy of the GNU Lesser General Public License |
13 | along with this library; if not, write to the Free Software Foundation, Inc., |
14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
15 | **********/ |
16 | // Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved. |
17 | // Basic Usage Environment: for a simple, non-scripted, console application |
18 | // C++ header |
19 | |
20 | #ifndef _HANDLER_SET_HH |
21 | #define _HANDLER_SET_HH |
22 | |
23 | #ifndef _BOOLEAN_HH |
24 | #include "Boolean.hh" |
25 | #endif |
26 | |
27 | ////////// HandlerSet (etc.) definition ////////// |
28 | |
29 | class HandlerDescriptor { |
30 | HandlerDescriptor(HandlerDescriptor* nextHandler); |
31 | virtual ~HandlerDescriptor(); |
32 | |
33 | public: |
34 | int socketNum; |
35 | int conditionSet; |
36 | TaskScheduler::BackgroundHandlerProc* handlerProc; |
37 | void* clientData; |
38 | |
39 | private: |
40 | // Descriptors are linked together in a doubly-linked list: |
41 | friend class HandlerSet; |
42 | friend class HandlerIterator; |
43 | HandlerDescriptor* fNextHandler; |
44 | HandlerDescriptor* fPrevHandler; |
45 | }; |
46 | |
47 | class HandlerSet { |
48 | public: |
49 | HandlerSet(); |
50 | virtual ~HandlerSet(); |
51 | |
52 | void assignHandler(int socketNum, int conditionSet, TaskScheduler::BackgroundHandlerProc* handlerProc, void* clientData); |
53 | void clearHandler(int socketNum); |
54 | void moveHandler(int oldSocketNum, int newSocketNum); |
55 | |
56 | private: |
57 | HandlerDescriptor* lookupHandler(int socketNum); |
58 | |
59 | private: |
60 | friend class HandlerIterator; |
61 | HandlerDescriptor fHandlers; |
62 | }; |
63 | |
64 | class HandlerIterator { |
65 | public: |
66 | HandlerIterator(HandlerSet& handlerSet); |
67 | virtual ~HandlerIterator(); |
68 | |
69 | HandlerDescriptor* next(); // returns NULL if none |
70 | void reset(); |
71 | |
72 | private: |
73 | HandlerSet& fOurSet; |
74 | HandlerDescriptor* fNextPtr; |
75 | }; |
76 | |
77 | #endif |
78 | |