aRts audio server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.8KB

  1. /*
  2. Copyright (C) 1999-2001 Stefan Westerfeld
  3. stefan@space.twc.de
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. /*
  18. * BC - Status (2002-03-08): QIOManager.
  19. *
  20. * QIOManager is kept binary compatible.
  21. */
  22. #ifndef QIOMANAGER_H
  23. #define QIOMANAGER_H
  24. #include "iomanager.h"
  25. #include <tqobject.h>
  26. #include <tqtimer.h>
  27. #include <tqsocketnotifier.h>
  28. #include <list>
  29. #include "arts_export.h"
  30. namespace Arts {
  31. class QIOWatch;
  32. class QTimeWatch;
  33. /**
  34. * QIOManager performs MCOP I/O inside the Qt event loop. This way, you will
  35. * be able to receive requests and notifications inside Qt application. The
  36. * usual way to set it up is:
  37. *
  38. * <pre>
  39. * TDEApplication app(argc, argv); // as usual
  40. *
  41. * Arts::QIOManager qiomanager;
  42. * Arts::Dispatcher dispatcher(&qiomanager);
  43. * ...
  44. * return app.exec(); // as usual
  45. * </pre>
  46. */
  47. class ARTS_EXPORT QIOManager : public IOManager {
  48. protected:
  49. friend class QIOWatch;
  50. friend class QTimeWatch;
  51. std::list<QIOWatch *> fdList;
  52. std::list<QTimeWatch *> timeList;
  53. void dispatch(QIOWatch *ioWatch);
  54. void dispatch(QTimeWatch *timeWatch);
  55. public:
  56. QIOManager();
  57. ~QIOManager();
  58. void processOneEvent(bool blocking);
  59. void run();
  60. void terminate();
  61. void watchFD(int fd, int types, IONotify *notify);
  62. void remove(IONotify *notify, int types);
  63. void addTimer(int milliseconds, TimeNotify *notify);
  64. void removeTimer(TimeNotify *notify);
  65. /**
  66. * This controls what QIOManager will do while waiting for the result
  67. * of an MCOP request, the possibilities are:
  68. *
  69. * @li block until the request is completed (true)
  70. * @li open a local event loop (false)
  71. *
  72. * It is much easier to write working and reliable code with blocking
  73. * enabled, so this is the default. If you disable blocking, you have
  74. * to deal with the fact that timers, user interaction and similar
  75. * "unpredictable" things will possibly influence your code in all
  76. * places where you make a remote MCOP call (which is quite often in
  77. * MCOP applications).
  78. */
  79. void setBlocking(bool blocking);
  80. /**
  81. * Query whether blocking is enabled.
  82. */
  83. bool blocking();
  84. };
  85. }
  86. #endif