- // hasSomeData - Return true if some data has been aquired. Avoid printing
- // lots of zero counts.
- //
- virtual bool hasSomeData() const = 0;
-};
-
-// Statistic Class - templated on the data type we are monitoring...
-template <typename DataType=unsigned>
-class Statistic : private StatisticBase {
- DataType Value;
-
- virtual void printValue(ostream &o) const { o << Value; }
- virtual bool hasSomeData() const { return Value != DataType(); }
-public:
- // Normal constructor, default initialize data item...
- Statistic(const char *name) : StatisticBase(name), Value(DataType()) {}
+ // Allow use of this class as the value itself.
+ operator unsigned() const { return Value; }
+ const Statistic &operator=(unsigned Val) { Value = Val; return init(); }
+ const Statistic &operator++() { ++Value; return init(); }
+ unsigned operator++(int) { init(); return Value++; }
+ const Statistic &operator--() { --Value; return init(); }
+ unsigned operator--(int) { init(); return Value--; }
+ const Statistic &operator+=(const unsigned &V) { Value += V; return init(); }
+ const Statistic &operator-=(const unsigned &V) { Value -= V; return init(); }
+ const Statistic &operator*=(const unsigned &V) { Value *= V; return init(); }
+ const Statistic &operator/=(const unsigned &V) { Value /= V; return init(); }