From 9f45fbaaa6e5f0fc63c63162b756c44b33e367f5 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 5 Mar 2009 19:09:53 -0800 Subject: stats: clean up how templates are used on the data side. This basically works by taking advantage of the curiously recurring template pattern in an intelligent way so as to reduce the number of lines of code and hopefully make things a little bit clearer. --- src/base/statistics.cc | 78 +++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'src/base/statistics.cc') diff --git a/src/base/statistics.cc b/src/base/statistics.cc index 032cbf689..c77816f23 100644 --- a/src/base/statistics.cc +++ b/src/base/statistics.cc @@ -158,7 +158,7 @@ Info::less(Info *stat1, Info *stat2) bool Info::baseCheck() const { - if (!(flags & init)) { + if (!(flags & Stats::init)) { #ifdef DEBUG cprintf("this is stat number %d\n", id); #endif @@ -175,21 +175,52 @@ Info::baseCheck() const } +Formula::Formula() +{ + setInit(); +} + +Formula::Formula(Temp r) +{ + root = r; + assert(size()); +} + +const Formula & +Formula::operator=(Temp r) +{ + assert(!root && "Can't change formulas"); + root = r; + assert(size()); + return *this; +} + +const Formula & +Formula::operator+=(Temp r) +{ + if (root) + root = NodePtr(new BinaryNode >(root, r)); + else + root = r; + assert(size()); + return *this; +} + void -FormulaBase::result(VResult &vec) const +Formula::result(VResult &vec) const { if (root) vec = root->result(); } Result -FormulaBase::total() const +Formula::total() const { return root ? root->total() : 0.0; } size_type -FormulaBase::size() const +Formula::size() const { if (!root) return 0; @@ -198,12 +229,12 @@ FormulaBase::size() const } void -FormulaBase::reset() +Formula::reset() { } bool -FormulaBase::zero() const +Formula::zero() const { VResult vec; result(vec); @@ -214,47 +245,16 @@ FormulaBase::zero() const } void -FormulaBase::update(Info *) +Formula::update() { } string -FormulaBase::str() const +Formula::str() const { return root ? root->str() : ""; } -Formula::Formula() -{ - setInit(); -} - -Formula::Formula(Temp r) -{ - root = r; - assert(size()); -} - -const Formula & -Formula::operator=(Temp r) -{ - assert(!root && "Can't change formulas"); - root = r; - assert(size()); - return *this; -} - -const Formula & -Formula::operator+=(Temp r) -{ - if (root) - root = NodePtr(new BinaryNode >(root, r)); - else - root = r; - assert(size()); - return *this; -} - void check() { -- cgit v1.2.3