
* headers.mk: add new header to distribution. * mln/debug/all.hh, * mln/debug/essential.hh: include quiet.hh * mln/debug/println.hh: use debug::quiet. Println prints nothing if debug::quiet is set to true. * mln/debug/quiet.hh: the new global variable. * tests/unit_test/Makefile.am, * tests/unit_test/mln_debug_quiet.cc: new unit test. --- milena/ChangeLog | 17 +++++++++++++ milena/headers.mk | 1 + milena/mln/debug/all.hh | 2 +- milena/mln/debug/essential.hh | 3 +- milena/mln/debug/println.hh | 14 ++++++++--- milena/mln/debug/{essential.hh => quiet.hh} | 34 +++++++++++++++++++++----- milena/tests/unit_test/Makefile.am | 2 + milena/tests/unit_test/mln_debug_quiet.cc | 11 ++++++++ 8 files changed, 71 insertions(+), 13 deletions(-) copy milena/mln/debug/{essential.hh => quiet.hh} (73%) create mode 100644 milena/tests/unit_test/mln_debug_quiet.cc diff --git a/milena/ChangeLog b/milena/ChangeLog index e9ca068..b4040f1 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,22 @@ 2009-01-20 Guillaume Lazzara <z@lrde.epita.fr> + Introduce debug::quiet. + + * headers.mk: add new header to distribution. + + * mln/debug/all.hh, + * mln/debug/essential.hh: include quiet.hh + + * mln/debug/println.hh: use debug::quiet. Println prints nothing if + debug::quiet is set to true. + + * mln/debug/quiet.hh: the new global variable. + + * tests/unit_test/Makefile.am, + * tests/unit_test/mln_debug_quiet.cc: new unit test. + +2009-01-20 Guillaume Lazzara <z@lrde.epita.fr> + Make the use of pw::cst() optional in predicates. * mln/pw/cst.hh: add the proper traits. diff --git a/milena/headers.mk b/milena/headers.mk index a730437..04c0a73 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -1019,6 +1019,7 @@ mln/debug/println.spe.hh \ mln/debug/colorize.hh \ mln/debug/draw_graph.hh \ mln/debug/put_word.hh \ +mln/debug/quiet.hh \ mln/debug/println_with_border.spe.hh \ mln/debug/format.hh \ mln/debug/println.hh \ diff --git a/milena/mln/debug/all.hh b/milena/mln/debug/all.hh index a0a27c6..97f12e9 100644 --- a/milena/mln/debug/all.hh +++ b/milena/mln/debug/all.hh @@ -53,6 +53,6 @@ namespace mln # include <mln/debug/println.hh> # include <mln/debug/println_with_border.hh> # include <mln/debug/put_word.hh> - +# include <mln/debug/quiet.hh> #endif // ! MLN_DEBUG_ALL_HH diff --git a/milena/mln/debug/essential.hh b/milena/mln/debug/essential.hh index a28563b..1851c7a 100644 --- a/milena/mln/debug/essential.hh +++ b/milena/mln/debug/essential.hh @@ -1,4 +1,5 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms diff --git a/milena/mln/debug/println.hh b/milena/mln/debug/println.hh index 29ff7bd..1e3371d 100644 --- a/milena/mln/debug/println.hh +++ b/milena/mln/debug/println.hh @@ -38,6 +38,7 @@ # include <mln/core/concept/image.hh> # include <mln/core/concept/window.hh> # include <mln/geom/bbox.hh> +# include <mln/debug/quiet.hh> # include <mln/debug/format.hh> // Specializations are in: @@ -89,16 +90,21 @@ namespace mln println(const Image<I>& input) { trace::entering("debug::println"); - impl::println(geom::bbox(exact(input).domain()), - exact(input)); + + if (!quiet) + impl::println(geom::bbox(exact(input).domain()), + exact(input)); trace::exiting("debug::println"); } template <typename I> void println(const std::string& msg, const Image<I>& input) { - std::cout << msg << std::endl; - println(input); + if (!quiet) + { + std::cout << msg << std::endl; + println(input); + } } # endif // ! MLN_INCLUDE_ONLY diff --git a/milena/mln/debug/essential.hh b/milena/mln/debug/quiet.hh similarity index 73% copy from milena/mln/debug/essential.hh copy to milena/mln/debug/quiet.hh index a28563b..ab54a48 100644 --- a/milena/mln/debug/essential.hh +++ b/milena/mln/debug/quiet.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -25,13 +25,33 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_DEBUG_ESSENTIAL_HH -# define MLN_DEBUG_ESSENTIAL_HH +#ifndef MLN_DEBUG_QUIET_HH +# define MLN_DEBUG_QUIET_HH -/// \file mln/debug/essential.hh +/// \file mln/debug/quiet.hh /// -/// File that includes essential debug-related routines. +/// global variable telling whether the debug should be printed or not. -# include <mln/debug/all.hh> -#endif // ! MLN_DEBUG_ESSENTIAL_HH +namespace mln +{ + + namespace debug + { + + extern bool quiet; + + + +# ifndef MLN_INCLUDE_ONLY + + bool quiet = false; + +# endif // ! MLN_INCLUDE_ONLY + + + } // end of namespace mln::debug + +} // end of namespace mln + +#endif // ! MLN_DEBUG_QUIET_HH diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am index b5dd047..f7886cd 100644 --- a/milena/tests/unit_test/Makefile.am +++ b/milena/tests/unit_test/Makefile.am @@ -983,6 +983,7 @@ mln_debug_println_with_border \ mln_debug_colorize \ mln_debug_draw_graph \ mln_debug_put_word \ +mln_debug_quiet \ mln_debug_format \ mln_debug_println \ mln_debug_essential \ @@ -1998,6 +1999,7 @@ mln_debug_println_with_border_SOURCES = mln_debug_println_with_border.cc mln_debug_colorize_SOURCES = mln_debug_colorize.cc mln_debug_draw_graph_SOURCES = mln_debug_draw_graph.cc mln_debug_put_word_SOURCES = mln_debug_put_word.cc +mln_debug_quiet_SOURCES = mln_debug_quiet.cc mln_debug_format_SOURCES = mln_debug_format.cc mln_debug_println_SOURCES = mln_debug_println.cc mln_debug_essential_SOURCES = mln_debug_essential.cc diff --git a/milena/tests/unit_test/mln_debug_quiet.cc b/milena/tests/unit_test/mln_debug_quiet.cc new file mode 100644 index 0000000..baa5c09 --- /dev/null +++ b/milena/tests/unit_test/mln_debug_quiet.cc @@ -0,0 +1,11 @@ +// Unit test for mln/debug/quiet.hh. +// Generated by ./build_unit_test.sh, do not modify. + +// Include the file twice, so we detect missing inclusion guards. +#include <mln/debug/quiet.hh> +#include <mln/debug/quiet.hh> + +int main() +{ + // Nothing. +} -- 1.5.6.5