HandlerSet.hh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. This library is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  9. more details.
  10. You should have received a copy of the GNU Lesser General Public License
  11. along with this library; if not, write to the Free Software Foundation, Inc.,
  12. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  13. **********/
  14. // Copyright (c) 1996-2019 Live Networks, Inc. All rights reserved.
  15. // Basic Usage Environment: for a simple, non-scripted, console application
  16. // C++ header
  17. #ifndef _HANDLER_SET_HH
  18. #define _HANDLER_SET_HH
  19. #ifndef _BOOLEAN_HH
  20. #include "Boolean.hh"
  21. #endif
  22. ////////// HandlerSet (etc.) definition //////////
  23. class HandlerDescriptor {
  24. HandlerDescriptor(HandlerDescriptor* nextHandler);
  25. virtual ~HandlerDescriptor();
  26. public:
  27. int socketNum;
  28. int conditionSet;
  29. TaskScheduler::BackgroundHandlerProc* handlerProc;
  30. void* clientData;
  31. private:
  32. // Descriptors are linked together in a doubly-linked list:
  33. friend class HandlerSet;
  34. friend class HandlerIterator;
  35. HandlerDescriptor* fNextHandler;
  36. HandlerDescriptor* fPrevHandler;
  37. };
  38. class HandlerSet {
  39. public:
  40. HandlerSet();
  41. virtual ~HandlerSet();
  42. void assignHandler(int socketNum, int conditionSet, TaskScheduler::BackgroundHandlerProc* handlerProc, void* clientData);
  43. void clearHandler(int socketNum);
  44. void moveHandler(int oldSocketNum, int newSocketNum);
  45. private:
  46. HandlerDescriptor* lookupHandler(int socketNum);
  47. private:
  48. friend class HandlerIterator;
  49. HandlerDescriptor fHandlers;
  50. };
  51. class HandlerIterator {
  52. public:
  53. HandlerIterator(HandlerSet& handlerSet);
  54. virtual ~HandlerIterator();
  55. HandlerDescriptor* next(); // returns NULL if none
  56. void reset();
  57. private:
  58. HandlerSet& fOurSet;
  59. HandlerDescriptor* fNextPtr;
  60. };
  61. #endif