Fork me on GitHub

source: svn/trunk/Utilities/Fastjet/include/fastjet/internal/LimitedWarning.hh@ 444

Last change on this file since 444 was 11, checked in by severine ovyn, 16 years ago

Fastjet added; CDFCones directory has been changed

File size: 2.2 KB
Line 
1//STARTHEADER
2// $Id: LimitedWarning.hh,v 1.1 2008-11-06 14:32:09 ovyn Exp $
3//
4// Copyright (c) 2005-2006, Matteo Cacciari and Gavin Salam
5//
6//----------------------------------------------------------------------
7// This file is part of FastJet.
8//
9// FastJet is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; either version 2 of the License, or
12// (at your option) any later version.
13//
14// The algorithms that underlie FastJet have required considerable
15// development and are described in hep-ph/0512210. If you use
16// FastJet as part of work towards a scientific publication, please
17// include a citation to the FastJet paper.
18//
19// FastJet is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License
25// along with FastJet; if not, write to the Free Software
26// Foundation, Inc.:
27// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28//----------------------------------------------------------------------
29//ENDHEADER
30
31
32#ifndef __FASTJET_LIMITEDWARNING_HH__
33#define __FASTJET_LIMITEDWARNING_HH__
34
35#include<iostream>
36#include<string>
37
38/// class to provide facilities for giving warnings up to some maximum
39/// number of times
40class LimitedWarning {
41public:
42
43 /// constructor that provides a default maximum number of warnings
44 LimitedWarning() : _max_warn(_max_warn_default), _n_warn_so_far(0) {}
45
46 /// constructor that provides a used-set max number of warnings
47 LimitedWarning(int max_warn) : _max_warn(max_warn), _n_warn_so_far(0) {}
48
49 /// output a warning to ostr
50 void warn(const std::string & warning, std::ostream & ostr = std::cerr) {
51 if (_n_warn_so_far < _max_warn) {
52 ostr << "WARNING: ";
53 ostr << warning;
54 _n_warn_so_far++;
55 if (_n_warn_so_far == _max_warn) ostr << " (LAST SUCH WARNING)";
56 ostr << std::endl;
57 }
58 }
59
60private:
61 int _max_warn, _n_warn_so_far;
62 static const int _max_warn_default = 5;
63
64};
65
66#endif // __FASTJET_LIMITEDWARNING_HH__
Note: See TracBrowser for help on using the repository browser.