ErrorCountEventHandler.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: ErrorCountEventHandler.h /main/1 1996/07/29 16:51:11 cde-hp $ */
  24. // Copyright (c) 1996 James Clark
  25. // See the file COPYING for copying permission.
  26. #ifndef ErrorCountEventHandler_INCLUDED
  27. #define ErrorCountEventHandler_INCLUDED 1
  28. #ifdef __GNUG__
  29. #pragma interface
  30. #endif
  31. #include <signal.h>
  32. #include "Event.h"
  33. #ifdef SP_NAMESPACE
  34. namespace SP_NAMESPACE {
  35. #endif
  36. class SP_API ErrorCountEventHandler : public EventHandler {
  37. public:
  38. ErrorCountEventHandler(unsigned errorLimit = 0);
  39. void setErrorLimit(unsigned maxErrors);
  40. const sig_atomic_t *cancelPtr() const;
  41. void cancel();
  42. Boolean cancelled() const;
  43. unsigned errorCount() const;
  44. void message(MessageEvent *);
  45. void noteMessage(const Message &);
  46. private:
  47. unsigned maxErrors_;
  48. unsigned errorCount_;
  49. sig_atomic_t cancel_;
  50. };
  51. inline
  52. unsigned ErrorCountEventHandler::errorCount() const
  53. {
  54. return errorCount_;
  55. }
  56. inline
  57. const sig_atomic_t *ErrorCountEventHandler::cancelPtr() const
  58. {
  59. return &cancel_;
  60. }
  61. inline
  62. void ErrorCountEventHandler::cancel()
  63. {
  64. cancel_ = 1;
  65. }
  66. inline
  67. void ErrorCountEventHandler::setErrorLimit(unsigned maxErrors)
  68. {
  69. maxErrors_ = maxErrors;
  70. }
  71. inline
  72. Boolean ErrorCountEventHandler::cancelled() const
  73. {
  74. return cancel_ != 0;
  75. }
  76. #ifdef SP_NAMESPACE
  77. }
  78. #endif
  79. #endif /* not ErrorCountEventHandler_INCLUDED */