Fight with Doxygen.
Victory hasn't been reached yet, but it's on the horizon.
3 * Part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
6 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 * Permission to use, modify and distribute this software is granted
9 * provided that this copyright notice appears in all copies. For
10 * precise terms see the accompanying LICENSE file.
12 * This software is provided "AS IS" with no warranty of any kind,
13 * express or implied, and with no claim as to its suitability for any
18 #ifndef LEMON_COUNTER_H
19 #define LEMON_COUNTER_H
26 ///\brief Tools for counting steps and events
31 template<class P> class _SubNoCounter;
42 typedef _SubCounter<_SubCounter<P> > SubCounter;
43 typedef _SubNoCounter<_SubCounter<P> > SubNoCounter;
45 _SubCounter(P &parent)
46 : _parent(parent), _title(), _os(std::cerr), count(0) {}
47 _SubCounter(P &parent,std::string title,std::ostream &os=std::cerr)
48 : _parent(parent), _title(title), _os(os), count(0) {}
49 _SubCounter(P &parent,const char *title,std::ostream &os=std::cerr)
50 : _parent(parent), _title(title), _os(os), count(0) {}
52 _os << _title << count <<std::endl;
55 _SubCounter &operator++() { count++; return *this;}
56 int operator++(int) { return count++; }
57 _SubCounter &operator--() { count--; return *this;}
58 int operator--(int) { return count--; }
59 _SubCounter &operator+=(int c) { count+=c; return *this;}
60 _SubCounter &operator-=(int c) { count-=c; return *this;}
61 void reset(int c=0) {count=c;}
62 operator int() {return count;}
70 typedef _SubNoCounter<_SubNoCounter<P> > SubCounter;
71 typedef _SubNoCounter<_SubNoCounter<P> > SubNoCounter;
73 _SubNoCounter(P &parent) :_parent(parent) {}
74 _SubNoCounter(P &parent,std::string,std::ostream &)
76 _SubNoCounter(P &parent,std::string)
78 _SubNoCounter(P &parent,const char *,std::ostream &)
80 _SubNoCounter(P &parent,const char *)
83 _SubNoCounter &operator++() { ++_parent; return *this;}
84 int operator++(int) { _parent++; return 0;}
85 _SubNoCounter &operator--() { --_parent; return *this;}
86 int operator--(int) { _parent--; return 0;}
87 _SubNoCounter &operator+=(int c) { _parent+=c; return *this;}
88 _SubNoCounter &operator-=(int c) { _parent-=c; return *this;}
91 operator int() {return 0;}
95 /// \addtogroup timecount
100 ///This class makes it easier to count certain events. You can increment
101 ///or decrement the counter using operator++ and operator--.
102 ///A report is automatically printed on destruction.
112 ///\todo document please.
114 typedef _SubCounter<Counter> SubCounter;
117 ///\todo document please.
119 typedef _SubNoCounter<Counter> SubNoCounter;
122 Counter() : _title(), _os(std::cerr), count(0) {}
124 Counter(std::string title,std::ostream &os=std::cerr)
125 : _title(title), _os(os), count(0) {}
127 Counter(const char *title,std::ostream &os=std::cerr)
128 : _title(title), _os(os), count(0) {}
129 ///Destructor. Prints the given title and the value of the counter.
131 _os << _title << count <<std::endl;
134 Counter &operator++() { count++; return *this;}
136 int operator++(int) { return count++;}
138 Counter &operator--() { count--; return *this;}
140 int operator--(int) { return count--;}
142 Counter &operator+=(int c) { count+=c; return *this;}
144 Counter &operator-=(int c) { count-=c; return *this;}
146 void reset(int c=0) {count=c;}
148 operator int() {return count;}
151 ///'Do nothing' version of \ref Counter
153 ///'Do nothing' version of \ref Counter.
158 typedef _SubNoCounter<NoCounter> SubCounter;
159 typedef _SubNoCounter<NoCounter> SubNoCounter;
162 NoCounter(std::string,std::ostream &) {}
163 NoCounter(const char *,std::ostream &) {}
164 NoCounter(std::string) {}
165 NoCounter(const char *) {}
166 NoCounter &operator++() { return *this; }
167 int operator++(int) { return 0; }
168 NoCounter &operator--() { return *this; }
169 int operator--(int) { return 0; }
170 NoCounter &operator+=(int) { return *this;}
171 NoCounter &operator-=(int) { return *this;}
174 operator int() {return 0;}