Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / lib / runtime / gr_error_handler.i
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2005 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
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)
10  * any later version.
11  * 
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.
16  * 
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.
21  */
22
23 %rename(error_handler) gr_error_handler;
24 %rename(file_error_handler) gr_file_error_handler;
25
26 class gr_error_handler {
27 public:
28   enum seriousness {
29     ERR_DEBUG           = 0x00000000,
30     ERR_MESSAGE         = 0x00010000,
31     ERR_WARNING         = 0x00020000,
32     ERR_ERROR           = 0x00030000,
33     ERR_FATAL           = 0x00040000
34   };
35
36   gr_error_handler() {}
37   virtual ~gr_error_handler();
38
39   static gr_error_handler *default_handler();
40   static gr_error_handler *silent_handler();
41
42   static bool has_default_handler();
43   static void set_default_handler(gr_error_handler *errh);
44
45   virtual int nwarnings() const = 0;
46   virtual int nerrors() const = 0;
47   virtual void reset_counts() = 0;
48
49   void verror_text(seriousness s, const std::string &text);
50 };
51
52 %ignore gr_base_error_handler;
53 class gr_base_error_handler : public gr_error_handler {
54   int   d_nwarnings;
55   int   d_nerrors;
56
57 public:
58   gr_base_error_handler() : d_nwarnings(0), d_nerrors(0) {}
59   int nwarnings() const { return d_nwarnings; }
60   int nerrors() const   { return d_nerrors; }
61   void reset_counts()   { d_nwarnings = d_nerrors = 0; }
62   void count_error(seriousness s);
63 };
64
65 class gr_file_error_handler : public gr_base_error_handler {
66 public:
67   gr_file_error_handler(int file_descriptor);
68   ~gr_file_error_handler();
69 };