1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 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
29class HandlerDescriptor {
30 HandlerDescriptor(HandlerDescriptor* nextHandler);
31 virtual ~HandlerDescriptor();
32
33public:
34 int socketNum;
35 int conditionSet;
36 TaskScheduler::BackgroundHandlerProc* handlerProc;
37 void* clientData;
38
39private:
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
47class HandlerSet {
48public:
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
56private:
57 HandlerDescriptor* lookupHandler(int socketNum);
58
59private:
60 friend class HandlerIterator;
61 HandlerDescriptor fHandlers;
62};
63
64class HandlerIterator {
65public:
66 HandlerIterator(HandlerSet& handlerSet);
67 virtual ~HandlerIterator();
68
69 HandlerDescriptor* next(); // returns NULL if none
70 void reset();
71
72private:
73 HandlerSet& fOurSet;
74 HandlerDescriptor* fNextPtr;
75};
76
77#endif
78