ARB
arb_msg_nospam.h
Go to the documentation of this file.
1 // ========================================================= //
2 // //
3 // File : arb_msg_nospam.h //
4 // Purpose : provide suppression for repeated warnings //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in Oct 22 //
7 // http://www.arb-home.de/ //
8 // //
9 // ========================================================= //
10 
11 #ifndef ARB_MSG_NOSPAM_H
12 #define ARB_MSG_NOSPAM_H
13 
14 #ifndef ARBTOOLS_H
15 #include <arbtools.h>
16 #endif
17 #ifndef _GLIBCXX_STRING
18 #include <string>
19 #endif
20 
21 class MessageSpamFilter : virtual Noncopyable {
22  // When instantiated -> suppresses messages sent via GB_warning(),
23  // if more than 'acceptedMessages' get shown while instance exists.
24  //
25  // * should be installed by all callers that might cause dozens or hundreds of warnings!
26  // * warnings will still be logged into logfile via console.
27 
28  MessageSpamFilter *previous_spamfilter;
29  std::string what_is_filtered;
30 
31  // message counters:
32  int shown;
33  int suppressed;
34  int accepted;
35 
36  static MessageSpamFilter *current_spamfilter;
37 
38  void filter_warning(const char *message);
39  bool is_spam();
40 
41 public:
42  MessageSpamFilter(std::string what_is_filtered_, int acceptedMessages = 5);
44 
45  // same as arb_handlers inferface:
46  static void show_warning(const char *message);
47 };
48 
49 
50 #else
51 #error arb_msg_nospam.h included twice
52 #endif // ARB_MSG_NOSPAM_H
53 
MessageSpamFilter(std::string what_is_filtered_, int acceptedMessages=5)
Definition: arb_msg.cxx:428
return string(buffer, length)
static void show_warning(const char *message)
Definition: arb_msg.cxx:473
void message(char *errortext)