1 // Copyright (c) 1996 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident	"%Z%%M%	%I%	%E% SMI"
4 
5 #ifndef ErrorCountEventHandler_INCLUDED
6 #define ErrorCountEventHandler_INCLUDED 1
7 
8 #ifdef __GNUG__
9 #pragma interface
10 #endif
11 
12 #include <signal.h>
13 #include "Event.h"
14 
15 #ifdef SP_NAMESPACE
16 namespace SP_NAMESPACE {
17 #endif
18 
19 class SP_API ErrorCountEventHandler : public EventHandler {
20 public:
21   ErrorCountEventHandler(unsigned errorLimit = 0);
22   void setErrorLimit(unsigned maxErrors);
23   const sig_atomic_t *cancelPtr() const;
24   void cancel();
25   Boolean cancelled() const;
26   unsigned errorCount() const;
27   void message(MessageEvent *);
28   void noteMessage(const Message &);
29 private:
30   unsigned maxErrors_;
31   unsigned errorCount_;
32   sig_atomic_t cancel_;
33 };
34 
35 inline
errorCount()36 unsigned ErrorCountEventHandler::errorCount() const
37 {
38   return errorCount_;
39 }
40 
41 inline
cancelPtr()42 const sig_atomic_t *ErrorCountEventHandler::cancelPtr() const
43 {
44   return &cancel_;
45 }
46 
47 inline
cancel()48 void ErrorCountEventHandler::cancel()
49 {
50   cancel_ = 1;
51 }
52 
53 inline
setErrorLimit(unsigned maxErrors)54 void ErrorCountEventHandler::setErrorLimit(unsigned maxErrors)
55 {
56   maxErrors_ = maxErrors;
57 }
58 
59 inline
cancelled()60 Boolean ErrorCountEventHandler::cancelled() const
61 {
62   return cancel_ != 0;
63 }
64 
65 #ifdef SP_NAMESPACE
66 }
67 #endif
68 
69 #endif /* not ErrorCountEventHandler_INCLUDED */
70