From: Nathan Binkert Date: Wed, 5 Nov 2003 23:21:18 +0000 (-0500) Subject: Add a virtual function resetStats() that any SimObject can inherit X-Git-Tag: m5_1.0_beta2~287 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b064b8a6fda1dd3f1bd174d742cc8e452f714efe;p=gem5.git Add a virtual function resetStats() that any SimObject can inherit from that will get called any time stats are reset. sim/sim_object.cc: sim/sim_object.hh: add a virtual function resetStats that any simObject can reset when a statistics reset is initiated --HG-- extra : convert_revision : fdad673142f6ff811f84c246d80e5d41e3c9d4d1 --- diff --git a/sim/sim_object.cc b/sim/sim_object.cc index af6a258ff..5c8e3eb9b 100644 --- a/sim/sim_object.cc +++ b/sim/sim_object.cc @@ -28,12 +28,13 @@ #include -#include "sim/sim_object.hh" +#include "base/callback.hh" #include "base/inifile.hh" -#include "sim/configfile.hh" -#include "sim/host.hh" #include "base/misc.hh" #include "base/trace.hh" +#include "sim/configfile.hh" +#include "sim/host.hh" +#include "sim/sim_object.hh" #include "sim/sim_stats.hh" using namespace std; @@ -72,6 +73,21 @@ SimObject::regFormulas() { } +namespace { + class __SimObjectResetCB : public Callback + { + public: + __SimObjectResetCB() { Statistics::RegResetCallback(this); } + virtual void process() { SimObject::resetAllStats(); } + }; + __SimObjectResetCB __theSimObjectResetCB; +} + +void +SimObject::resetStats() +{ +} + // // no default extra output // @@ -109,6 +125,14 @@ SimObject::regAllStats() } } +// +// static function: call resetStats() on all SimObjects. +// +void +SimObject::resetAllStats() +{ +} + // // static function: call printExtraOutput() on all SimObjects. // diff --git a/sim/sim_object.hh b/sim/sim_object.hh index 1a365651b..6b26a1cb0 100644 --- a/sim/sim_object.hh +++ b/sim/sim_object.hh @@ -68,6 +68,7 @@ class SimObject : public Serializeable // register statistics for this object virtual void regStats(); virtual void regFormulas(); + virtual void resetStats(); // print extra results for this object not covered by registered // statistics (called at end of simulation) @@ -76,6 +77,9 @@ class SimObject : public Serializeable // static: call reg_stats on all SimObjects static void regAllStats(); + // static: call resetStats on all SimObjects + static void resetAllStats(); + // static: call printExtraOutput on all SimObjects static void printAllExtraOutput(std::ostream&); };