1 // -*- mode: c++ -*-
2 //
3 // This file is part of libyacurs.
4 // Copyright (C) 2013  Rafael Ostertag
5 //
6 // This program is free software: you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation, either version 3 of the
9 // License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program.  If not, see
18 // <http://www.gnu.org/licenses/>.
19 //
20 //
21 // $Id$
22 
23 #ifndef YACURSDBG_H
24 #define YACURSDBG_H 1
25 
26 #include <fstream>
27 #include <sstream>
28 
29 #if defined(DEBUG)
30 namespace YACURS {
31 enum DBGTYPE { DBG_EVT, DBG_FOCUSGRP, DBG_FOCUSMGR };
32 
33 class Debug {
34    private:
35     static std::ofstream _debugfile;
36 
37    public:
38     static void out(DBGTYPE dt, const std::string& c);
39     static void out(DBGTYPE dt, const std::ostringstream& os);
40 };
41 }  // namespace YACURS
42 #define DEBUGOUT(t, x)                                     \
43     {                                                      \
44         std::ostringstream _tmp_debug_ostring_stream;     \
45         _tmp_debug_ostring_stream << x;                   \
46         YACURS::Debug::out(t, _tmp_debug_ostring_stream); \
47     }
48 #else
49 #define DEBUGOUT(t, x)
50 #endif
51 
52 #endif  // YACURSDBG_H
53