TIVI-153: Add as dependency for iputils
[profile/ivi/opensp.git] / lib / ErrorCountEventHandler.cxx
1 // Copyright (c) 1996 James Clark
2 // See the file COPYING for copying permission.
3
4 #ifdef __GNUG__
5 #pragma implementation
6 #endif
7 #include "splib.h"
8 #include "ErrorCountEventHandler.h"
9
10 #ifdef SP_NAMESPACE
11 namespace SP_NAMESPACE {
12 #endif
13
14 ErrorCountEventHandler::ErrorCountEventHandler(unsigned errorLimit)
15 : errorCount_(0), maxErrors_(errorLimit), cancel_(0)
16 {
17 }
18
19 void ErrorCountEventHandler::message(MessageEvent *event)
20 {
21   noteMessage(event->message());
22   delete event;
23 }
24
25 void ErrorCountEventHandler::noteMessage(const Message &message)
26 {
27   if (message.isError() && ++errorCount_ == maxErrors_)
28     cancel_ = 1;
29 }
30
31 #ifdef SP_NAMESPACE
32 }
33 #endif