Fork me on GitHub

source: git/external/fastjet/LimitedWarning.hh@ e70228d

Timing
Last change on this file since e70228d was b7b836a, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

update FastJet library to 3.3.1 and FastJet Contrib library to 1.036

  • Property mode set to 100644
File size: 3.8 KB
Line 
1#ifndef __FASTJET_LIMITEDWARNING_HH__
2#define __FASTJET_LIMITEDWARNING_HH__
3
4//FJSTARTHEADER
5// $Id: LimitedWarning.hh 4354 2018-04-22 07:12:37Z salam $
6//
7// Copyright (c) 2005-2018, 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. They are described in the original FastJet paper,
19// hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use
20// FastJet as part of work towards a scientific publication, please
21// quote the version you use and include a citation to the manual and
22// optionally also to hep-ph/0512210.
23//
24// FastJet is distributed in the hope that it will be useful,
25// but WITHOUT ANY WARRANTY; without even the implied warranty of
26// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27// GNU General Public License for more details.
28//
29// You should have received a copy of the GNU General Public License
30// along with FastJet. If not, see <http://www.gnu.org/licenses/>.
31//----------------------------------------------------------------------
32//FJENDHEADER
33
34
35#include "fastjet/internal/base.hh"
36#include <iostream>
37#include <string>
38#include <list>
39
40FASTJET_BEGIN_NAMESPACE
41
42/// @ingroup error_handling
43/// \class LimitedWarning
44/// class to provide facilities for giving warnings up to some maximum
45/// number of times and to provide global summaries of warnings that have
46/// been issued.
47class LimitedWarning {
48public:
49
50 /// constructor that provides a default maximum number of warnings
51 LimitedWarning() : _max_warn(_max_warn_default), _n_warn_so_far(0), _this_warning_summary(0) {}
52
53 /// constructor that provides a user-set max number of warnings
54 LimitedWarning(int max_warn_in) : _max_warn(max_warn_in), _n_warn_so_far(0), _this_warning_summary(0) {}
55
56 /// outputs a warning to standard error (or the user's default
57 /// warning stream if set)
58 void warn(const char * warning) {warn(warning, _default_ostr);}
59
60 /// outputs a warning to standard error (or the user's default
61 /// warning stream if set)
62 void warn(const std::string & warning) {warn(warning.c_str(), _default_ostr);}
63
64 /// outputs a warning to the specified stream
65 void warn(const char * warning, std::ostream * ostr);
66
67 /// outputs a warning to the specified stream
68 void warn(const std::string & warning, std::ostream * ostr) {warn(warning.c_str(), ostr);}
69
70 /// sets the default output stream for all warnings (by default
71 /// cerr; passing a null pointer prevents warnings from being output)
72 static void set_default_stream(std::ostream * ostr) {
73 _default_ostr = ostr;
74 }
75
76 /// sets the default maximum number of warnings of a given kind
77 /// before warning messages are silenced.
78 static void set_default_max_warn(int max_warn) {
79 _max_warn_default = max_warn;
80 }
81
82 /// the maximum number of warning messages that will be printed
83 /// by this instance of the class
84 int max_warn() const {return _max_warn;}
85
86 /// the number of times so far that a warning has been registered
87 /// with this instance of the class.
88 int n_warn_so_far() const {return _n_warn_so_far;}
89
90 /// returns a summary of all the warnings that came through the
91 /// LimiteWarning class
92 static std::string summary();
93
94private:
95 int _max_warn, _n_warn_so_far;
96 static int _max_warn_default;
97 static std::ostream * _default_ostr;
98 typedef std::pair<std::string, unsigned int> Summary;
99 static std::list< Summary > _global_warnings_summary;
100 Summary * _this_warning_summary;
101
102};
103
104FASTJET_END_NAMESPACE
105
106#endif // __FASTJET_LIMITEDWARNING_HH__
Note: See TracBrowser for help on using the repository browser.