gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Remove reset() functions from SubCounter classes (ticket #82)
0 1 0
default
1 file changed with 5 insertions and 3 deletions:
↑ Collapse diff ↑
Show white space 24 line context
... ...
@@ -50,25 +50,24 @@
50 50
    _SubCounter(P &parent,const char *title,std::ostream &os=std::cerr)
51 51
      : _parent(parent), _title(title), _os(os), count(0) {}
52 52
    ~_SubCounter() { 
53 53
      _os << _title << count <<std::endl;
54 54
      _parent+=count;
55 55
    }
56 56
    _SubCounter &operator++() { count++; return *this;}
57 57
    int operator++(int) { return count++; }
58 58
    _SubCounter &operator--() { count--; return *this;}
59 59
    int operator--(int) { return count--; }
60 60
    _SubCounter &operator+=(int c) { count+=c; return *this;}
61 61
    _SubCounter &operator-=(int c) { count-=c; return *this;}
62
    void reset(int c=0) {count=c;}
63 62
    operator int() {return count;}
64 63
  };
65 64

	
66 65
  template<class P>
67 66
  class _NoSubCounter 
68 67
  {
69 68
    P &_parent;
70 69
  public:
71 70
    typedef _NoSubCounter<_NoSubCounter<P> > SubCounter;
72 71
    typedef _NoSubCounter<_NoSubCounter<P> > NoSubCounter;
73 72
  
74 73
    _NoSubCounter(P &parent) :_parent(parent) {}
... ...
@@ -78,26 +77,24 @@
78 77
      :_parent(parent) {}
79 78
    _NoSubCounter(P &parent,const char *,std::ostream &)
80 79
      :_parent(parent) {}
81 80
    _NoSubCounter(P &parent,const char *)
82 81
      :_parent(parent) {}
83 82
    ~_NoSubCounter() {}
84 83
    _NoSubCounter &operator++() { ++_parent; return *this;}
85 84
    int operator++(int) { _parent++; return 0;}
86 85
    _NoSubCounter &operator--() { --_parent; return *this;}
87 86
    int operator--(int) { _parent--; return 0;}
88 87
    _NoSubCounter &operator+=(int c) { _parent+=c; return *this;}
89 88
    _NoSubCounter &operator-=(int c) { _parent-=c; return *this;}
90
    void reset(int) {}
91
    void reset() {}
92 89
    operator int() {return 0;}
93 90
  };
94 91

	
95 92

	
96 93
  /// \addtogroup timecount
97 94
  /// @{
98 95

	
99 96
  /// A counter class
100 97

	
101 98
  /// This class makes it easier to count certain events (e.g. for debug
102 99
  /// reasons).
103 100
  /// You can increment or decrement the counter using \c operator++,
... ...
@@ -194,24 +191,29 @@
194 191
    Counter &operator++() { count++; return *this;}
195 192
    ///\e
196 193
    int operator++(int) { return count++;}
197 194
    ///\e
198 195
    Counter &operator--() { count--; return *this;}
199 196
    ///\e
200 197
    int operator--(int) { return count--;}
201 198
    ///\e
202 199
    Counter &operator+=(int c) { count+=c; return *this;}
203 200
    ///\e
204 201
    Counter &operator-=(int c) { count-=c; return *this;}
205 202
    /// Resets the counter to the given value.
203

	
204
    /// Resets the counter to the given value.
205
    /// \note This function does not reset the values of
206
    /// \ref SubCounter "SubCounter"s but it resets \ref NoSubCounter
207
    /// "NoSubCounter"s along with the main counter. 
206 208
    void reset(int c=0) {count=c;}
207 209
    /// Returns the value of the counter.
208 210
    operator int() {return count;}
209 211
  };
210 212

	
211 213
  /// 'Do nothing' version of Counter.
212 214

	
213 215
  /// This class can be used in the same way as \ref Counter however it
214 216
  /// does not count at all and does not print report on destruction.
215 217
  ///
216 218
  /// Replacing a \ref Counter with a \ref NoCounter makes it possible
217 219
  /// to turn off all counting and reporting (SubCounters should also
0 comments (0 inline)