3 * Copyright 2005 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 * This code is based on error.hh from the "Click Modular Router".
24 * Original copyright follows:
27 * error.{cc,hh} -- flexible classes for error reporting
30 * Copyright (c) 1999-2000 Massachusetts Institute of Technology
32 * Permission is hereby granted, free of charge, to any person obtaining a
33 * copy of this software and associated documentation files (the "Software"),
34 * to deal in the Software without restriction, subject to the conditions
35 * listed in the Click LICENSE file. These conditions include: you must
36 * preserve this copyright notice, and you cannot mention the copyright
37 * holders in advertising related to the Software without their permission.
38 * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
39 * notice is a summary of the Click LICENSE file; the license in that file is
43 #ifndef INCLUDED_GR_ERROR_HANDLER_H
44 #define INCLUDED_GR_ERROR_HANDLER_H
50 * \brief abstract error handler
52 class gr_error_handler {
55 ERR_DEBUG = 0x00000000,
56 ERR_MESSAGE = 0x00010000,
57 ERR_WARNING = 0x00020000,
58 ERR_ERROR = 0x00030000,
59 ERR_FATAL = 0x00040000
63 virtual ~gr_error_handler();
65 static gr_error_handler *default_handler();
66 static gr_error_handler *silent_handler();
68 static bool has_default_handler();
69 static void set_default_handler(gr_error_handler *errh);
71 void debug(const char *format, ...);
72 void message(const char *format, ...);
73 void warning(const char *format, ...);
74 void error(const char *format, ...);
75 void fatal(const char *format, ...);
77 virtual int nwarnings() const = 0;
78 virtual int nerrors() const = 0;
79 virtual void reset_counts() = 0;
81 void verror(seriousness s, const char *format, va_list);
82 void verror_text(seriousness s, const std::string &text);
85 virtual void count_error(seriousness s) = 0;
86 virtual void handle_text(seriousness s, const std::string &str) = 0;
87 std::string make_text(seriousness s, const char *format, va_list);
91 class gr_base_error_handler : public gr_error_handler {
96 gr_base_error_handler() : d_nwarnings(0), d_nerrors(0) {}
97 int nwarnings() const { return d_nwarnings; }
98 int nerrors() const { return d_nerrors; }
99 void reset_counts() { d_nwarnings = d_nerrors = 0; }
100 void count_error(seriousness s);
103 class gr_file_error_handler : public gr_base_error_handler {
107 gr_file_error_handler(FILE *file);
108 gr_file_error_handler(int file_descriptor);
109 ~gr_file_error_handler();
111 void handle_text(seriousness s, const std::string &str);
114 #endif /* INCLUDED_GR_ERROR_HANDLER_H */