Fork me on GitHub

source: svn/trunk/external/fastjet/LimitedWarning.hh@ 1188

Last change on this file since 1188 was 859, checked in by Pavel Demin, 12 years ago

update fastjet to version 3.0.3

File size: 3.1 KB
Line 
1#ifndef __FASTJET_LIMITEDWARNING_HH__
2#define __FASTJET_LIMITEDWARNING_HH__
3
4//STARTHEADER
5// $Id: LimitedWarning.hh 2577 2011-09-13 15:11:38Z salam $
6//
7// Copyright (c) 2005-2011, Matteo Cacciari, Gavin P. Salam and Gregory Soyez
8//
9//----------------------------------------------------------------------
10// This file is part of FastJet.
11//
12// FastJet is free software; you can redistribute it and/or modify
13// it under the terms of the GNU General Public License as published by
14// the Free Software Foundation; either version 2 of the License, or
15// (at your option) any later version.
16//
17// The algorithms that underlie FastJet have required considerable
18// development and are described in hep-ph/0512210. If you use
19// FastJet as part of work towards a scientific publication, please
20// include a citation to the FastJet paper.
21//
22// FastJet is distributed in the hope that it will be useful,
23// but WITHOUT ANY WARRANTY; without even the implied warranty of
24// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25// GNU General Public License for more details.
26//
27// You should have received a copy of the GNU General Public License
28// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
29//----------------------------------------------------------------------
30//ENDHEADER
31
32
33#include "fastjet/internal/base.hh"
34#include <iostream>
35#include <string>
36#include <list>
37
38FASTJET_BEGIN_NAMESPACE
39
40/// @ingroup error_handling
41/// \class LimitedWarning
42/// class to provide facilities for giving warnings up to some maximum
43/// number of times and to provide global summaries of warnings that have
44/// been issued.
45class LimitedWarning {
46public:
47
48 /// constructor that provides a default maximum number of warnings
49 LimitedWarning() : _max_warn(_max_warn_default), _n_warn_so_far(0), _this_warning_summary(0) {}
50
51 /// constructor that provides a user-set max number of warnings
52 LimitedWarning(int max_warn) : _max_warn(max_warn), _n_warn_so_far(0), _this_warning_summary(0) {}
53
54 /// outputs a warning to standard error (or the user's default
55 /// warning stream if set)
56 void warn(const std::string & warning);
57
58 /// outputs a warning to the specified stream
59 void warn(const std::string & warning, std::ostream * ostr);
60
61 /// sets the default output stream for all warnings (by default
62 /// cerr; passing a null pointer prevents warnings from being output)
63 static void set_default_stream(std::ostream * ostr) {
64 _default_ostr = ostr;
65 }
66
67 /// sets the default maximum number of warnings of a given kind
68 /// before warning messages are silenced.
69 static void set_default_max_warn(int max_warn) {
70 _max_warn_default = max_warn;
71 }
72
73 /// returns a summary of all the warnings that came through the
74 /// LimiteWarning class
75 static std::string summary();
76
77private:
78 int _max_warn, _n_warn_so_far;
79 static int _max_warn_default;
80 static std::ostream * _default_ostr;
81 typedef std::pair<std::string, unsigned int> Summary;
82 static std::list< Summary > _global_warnings_summary;
83 Summary * _this_warning_summary;
84
85};
86
87FASTJET_END_NAMESPACE
88
89#endif // __FASTJET_LIMITEDWARNING_HH__
Note: See TracBrowser for help on using the repository browser.