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 3, 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
53 class gr_error_handler {
56 ERR_DEBUG = 0x00000000,
57 ERR_MESSAGE = 0x00010000,
58 ERR_WARNING = 0x00020000,
59 ERR_ERROR = 0x00030000,
60 ERR_FATAL = 0x00040000
64 virtual ~gr_error_handler();
66 static gr_error_handler *default_handler();
67 static gr_error_handler *silent_handler();
69 static bool has_default_handler();
70 static void set_default_handler(gr_error_handler *errh);
72 void debug(const char *format, ...);
73 void message(const char *format, ...);
74 void warning(const char *format, ...);
75 void error(const char *format, ...);
76 void fatal(const char *format, ...);
78 virtual int nwarnings() const = 0;
79 virtual int nerrors() const = 0;
80 virtual void reset_counts() = 0;
82 void verror(seriousness s, const char *format, va_list);
83 void verror_text(seriousness s, const std::string &text);
86 virtual void count_error(seriousness s) = 0;
87 virtual void handle_text(seriousness s, const std::string &str) = 0;
88 std::string make_text(seriousness s, const char *format, va_list);
92 class gr_base_error_handler : public gr_error_handler {
97 gr_base_error_handler() : d_nwarnings(0), d_nerrors(0) {}
98 int nwarnings() const { return d_nwarnings; }
99 int nerrors() const { return d_nerrors; }
100 void reset_counts() { d_nwarnings = d_nerrors = 0; }
101 void count_error(seriousness s);
104 class gr_file_error_handler : public gr_base_error_handler {
108 gr_file_error_handler(FILE *file);
109 gr_file_error_handler(int file_descriptor);
110 ~gr_file_error_handler();
112 void handle_text(seriousness s, const std::string &str);
115 #endif /* INCLUDED_GR_ERROR_HANDLER_H */