- // printValue - Overridden by template class to print out the value type...
- virtual void printValue(std::ostream &o) const = 0;
-
- // 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(std::ostream &o) const { o << Value; }
- virtual bool hasSomeData() const { return Value != DataType(); }
-public:
- // Normal constructor, default initialize data item...
- Statistic(const char *name, const char *desc)
- : StatisticBase(name, desc), Value(DataType()) {}
-
- // Constructor to provide an initial value...
- Statistic(const DataType &Val, const char *name, const char *desc)
- : StatisticBase(name, desc), Value(Val) {}
+ /// construct - This should only be called for non-global statistics.
+ void construct(const char *name, const char *desc) {
+ Name = name; Desc = desc;
+ Value = 0; Initialized = 0;
+ }