31 #include "fastjet/LimitedWarning.hh"
37 FASTJET_BEGIN_NAMESPACE
39 ostream * LimitedWarning::_default_ostr = &cerr;
40 std::list< LimitedWarning::Summary > LimitedWarning::_global_warnings_summary;
41 int LimitedWarning::_max_warn_default = 5;
49 void LimitedWarning::warn(
const char * warning, std::ostream * ostr) {
50 if (_this_warning_summary == 0) {
52 _global_warnings_summary.push_back(Summary(warning, 0));
53 _this_warning_summary = & (_global_warnings_summary.back());
55 if (_n_warn_so_far < _max_warn) {
57 ostringstream warnstr;
58 warnstr <<
"WARNING from FastJet: ";
61 if (_n_warn_so_far == _max_warn) warnstr <<
" (LAST SUCH WARNING)";
67 (*ostr) << warnstr.str();
73 if (_this_warning_summary->second < numeric_limits<unsigned>::max()) {
74 _this_warning_summary->second++;
79 string LimitedWarning::summary() {
81 for (list<Summary>::const_iterator it = _global_warnings_summary.begin();
82 it != _global_warnings_summary.end(); it++) {
83 str << it->second <<
" times: " << it->first << endl;