From 4d9f25b75cf09760f008cdb393f54a2e5d0029c7 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 22 Apr 2009 13:38:00 -0700 Subject: [PATCH] stats: Rename the info classes to hopefully make things a bit clearer FooInfoBase became FooInfo FooInfo became FooInfoProxy --- src/base/statistics.cc | 6 +-- src/base/statistics.hh | 95 +++++++++++++++++++++-------------------- src/base/stats/mysql.cc | 36 ++++++++-------- src/base/stats/mysql.hh | 40 ++++++++--------- src/base/stats/text.cc | 22 +++++----- src/base/stats/text.hh | 12 +++--- src/base/stats/visit.hh | 26 +++++------ 7 files changed, 119 insertions(+), 118 deletions(-) diff --git a/src/base/statistics.cc b/src/base/statistics.cc index 1f3562384..8a896f8cd 100644 --- a/src/base/statistics.cc +++ b/src/base/statistics.cc @@ -206,7 +206,7 @@ Info::enable() } void -VectorInfoBase::enable() +VectorInfo::enable() { size_type s = size(); if (subnames.size() < s) @@ -216,7 +216,7 @@ VectorInfoBase::enable() } void -VectorDistInfoBase::enable() +VectorDistInfo::enable() { size_type s = size(); if (subnames.size() < s) @@ -226,7 +226,7 @@ VectorDistInfoBase::enable() } void -Vector2dInfoBase::enable() +Vector2dInfo::enable() { if (subnames.size() < x) subnames.resize(x); diff --git a/src/base/statistics.hh b/src/base/statistics.hh index cd5be21ce..6758a6489 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -161,15 +161,16 @@ class Info */ static bool less(Info *stat1, Info *stat2); }; +struct StorageParams; template -class InfoWrap : public Base +class InfoProxy : public Base { protected: Stat &s; public: - InfoWrap(Stat &stat) : s(stat) {} + InfoProxy(Stat &stat) : s(stat) {} bool check() const { return s.check(); } void prepare() { s.prepare(); } @@ -182,7 +183,7 @@ class InfoWrap : public Base bool zero() const { return s.zero(); } }; -class ScalarInfoBase : public Info +class ScalarInfo : public Info { public: virtual Counter value() const = 0; @@ -191,17 +192,17 @@ class ScalarInfoBase : public Info }; template -class ScalarInfo : public InfoWrap +class ScalarInfoProxy : public InfoProxy { public: - ScalarInfo(Stat &stat) : InfoWrap(stat) {} + ScalarInfoProxy(Stat &stat) : InfoProxy(stat) {} Counter value() const { return this->s.value(); } Result result() const { return this->s.result(); } Result total() const { return this->s.total(); } }; -class VectorInfoBase : public Info +class VectorInfo : public Info { public: /** Names and descriptions of subfields. */ @@ -219,14 +220,14 @@ class VectorInfoBase : public Info }; template -class VectorInfo : public InfoWrap +class VectorInfoProxy : public InfoProxy { protected: mutable VCounter cvec; mutable VResult rvec; public: - VectorInfo(Stat &stat) : InfoWrap(stat) {} + VectorInfoProxy(Stat &stat) : InfoProxy(stat) {} size_type size() const { return this->s.size(); } @@ -259,7 +260,7 @@ struct DistData Counter samples; }; -class DistInfoBase : public Info +class DistInfo : public Info { public: /** Local storage for the entry values, used for printing. */ @@ -267,13 +268,13 @@ class DistInfoBase : public Info }; template -class DistInfo : public InfoWrap +class DistInfoProxy : public InfoProxy { public: - DistInfo(Stat &stat) : InfoWrap(stat) {} + DistInfoProxy(Stat &stat) : InfoProxy(stat) {} }; -class VectorDistInfoBase : public Info +class VectorDistInfo : public Info { public: std::vector data; @@ -292,15 +293,15 @@ class VectorDistInfoBase : public Info }; template -class VectorDistInfo : public InfoWrap +class VectorDistInfoProxy : public InfoProxy { public: - VectorDistInfo(Stat &stat) : InfoWrap(stat) {} + VectorDistInfoProxy(Stat &stat) : InfoProxy(stat) {} size_type size() const { return this->s.size(); } }; -class Vector2dInfoBase : public Info +class Vector2dInfo : public Info { public: /** Names and descriptions of subfields. */ @@ -318,10 +319,10 @@ class Vector2dInfoBase : public Info }; template -class Vector2dInfo : public InfoWrap +class Vector2dInfoProxy : public InfoProxy { public: - Vector2dInfo(Stat &stat) : InfoWrap(stat) {} + Vector2dInfoProxy(Stat &stat) : InfoProxy(stat) {} }; class InfoAccess @@ -359,11 +360,11 @@ class InfoAccess bool check() const { return true; } }; -template class InfoType> +template class InfoProxyType> class DataWrap : public InfoAccess { public: - typedef InfoType Info; + typedef InfoProxyType Info; protected: Derived &self() { return *static_cast(this); } @@ -466,11 +467,11 @@ class DataWrap : public InfoAccess } }; -template class InfoType> -class DataWrapVec : public DataWrap +template class InfoProxyType> +class DataWrapVec : public DataWrap { public: - typedef InfoType Info; + typedef InfoProxyType Info; // The following functions are specific to vectors. If you use them // in a non vector context, you will get a nice compiler error! @@ -542,11 +543,11 @@ class DataWrapVec : public DataWrap } }; -template class InfoType> -class DataWrapVec2d : public DataWrapVec +template class InfoProxyType> +class DataWrapVec2d : public DataWrapVec { public: - typedef InfoType Info; + typedef InfoProxyType Info; /** * @warning This makes the assumption that if you're gonna subnames a 2d @@ -746,7 +747,7 @@ class AvgStor * Storage template. */ template -class ScalarBase : public DataWrap +class ScalarBase : public DataWrap { public: typedef Stor Storage; @@ -860,7 +861,7 @@ class ScalarBase : public DataWrap void prepare() { data()->prepare(this->info()); } }; -class ProxyInfo : public ScalarInfoBase +class ProxyInfo : public ScalarInfo { public: std::string str() const { return to_string(value()); } @@ -900,7 +901,7 @@ class FunctorProxy : public ProxyInfo }; template -class ValueBase : public DataWrap +class ValueBase : public DataWrap { private: ProxyInfo *proxy; @@ -1076,7 +1077,7 @@ class ScalarProxy * Storage class. @sa ScalarBase */ template -class VectorBase : public DataWrapVec +class VectorBase : public DataWrapVec { public: typedef Stor Storage; @@ -1085,7 +1086,7 @@ class VectorBase : public DataWrapVec /** Proxy type */ typedef ScalarProxy Proxy; friend class ScalarProxy; - friend class DataWrapVec; + friend class DataWrapVec; protected: /** The storage of this stat. */ @@ -1295,17 +1296,17 @@ class VectorProxy }; template -class Vector2dBase : public DataWrapVec2d +class Vector2dBase : public DataWrapVec2d { public: - typedef Vector2dInfo Info; + typedef Vector2dInfoProxy Info; typedef Stor Storage; typedef typename Stor::Params Params; typedef VectorProxy Proxy; friend class ScalarProxy; friend class VectorProxy; - friend class DataWrapVec; - friend class DataWrapVec2d; + friend class DataWrapVec; + friend class DataWrapVec2d; protected: size_type x; @@ -1733,10 +1734,10 @@ class AvgFancy * determined by the Storage template. @sa ScalarBase */ template -class DistBase : public DataWrap +class DistBase : public DataWrap { public: - typedef DistInfo Info; + typedef DistInfoProxy Info; typedef Stor Storage; typedef typename Stor::Params Params; @@ -1816,15 +1817,15 @@ template class DistProxy; template -class VectorDistBase : public DataWrapVec +class VectorDistBase : public DataWrapVec { public: - typedef VectorDistInfo Info; + typedef VectorDistInfoProxy Info; typedef Stor Storage; typedef typename Stor::Params Params; typedef DistProxy Proxy; friend class DistProxy; - friend class DataWrapVec; + friend class DataWrapVec; protected: Storage *storage; @@ -2027,11 +2028,11 @@ typedef RefCountingPtr NodePtr; class ScalarStatNode : public Node { private: - const ScalarInfoBase *data; + const ScalarInfo *data; mutable VResult vresult; public: - ScalarStatNode(const ScalarInfoBase *d) : data(d), vresult(1) {} + ScalarStatNode(const ScalarInfo *d) : data(d), vresult(1) {} const VResult & result() const @@ -2094,10 +2095,10 @@ class ScalarProxyNode : public Node class VectorStatNode : public Node { private: - const VectorInfoBase *data; + const VectorInfo *data; public: - VectorStatNode(const VectorInfoBase *d) : data(d) { } + VectorStatNode(const VectorInfo *d) : data(d) { } const VResult &result() const { return data->result(); } Result total() const { return data->total(); }; @@ -2554,21 +2555,21 @@ class VectorAverageDeviation } }; -class FormulaInfoBase : public VectorInfoBase +class FormulaInfo : public VectorInfo { public: virtual std::string str() const = 0; }; template -class FormulaInfo : public InfoWrap +class FormulaInfoProxy : public InfoProxy { protected: mutable VResult vec; mutable VCounter cvec; public: - FormulaInfo(Stat &stat) : InfoWrap(stat) {} + FormulaInfoProxy(Stat &stat) : InfoProxy(stat) {} size_type size() const { return this->s.size(); } @@ -2590,7 +2591,7 @@ class Temp; * stored as a tree of Nodes that represent the equation to calculate. * @sa Stat, ScalarStat, VectorStat, Node, Temp */ -class Formula : public DataWrapVec +class Formula : public DataWrapVec { protected: /** The root of the tree which represents the Formula */ diff --git a/src/base/stats/mysql.cc b/src/base/stats/mysql.cc index 1e0c923f1..dff9a0ee0 100644 --- a/src/base/stats/mysql.cc +++ b/src/base/stats/mysql.cc @@ -544,7 +544,7 @@ MySql::configure(const Info &info, string type) } void -MySql::configure(const ScalarInfoBase &info) +MySql::configure(const ScalarInfo &info) { if (!configure(info, "SCALAR")) return; @@ -553,7 +553,7 @@ MySql::configure(const ScalarInfoBase &info) } void -MySql::configure(const VectorInfoBase &info) +MySql::configure(const VectorInfo &info) { if (!configure(info, "VECTOR")) return; @@ -578,7 +578,7 @@ MySql::configure(const VectorInfoBase &info) } void -MySql::configure(const DistInfoBase &info) +MySql::configure(const DistInfo &info) { if (!configure(info, "DIST")) return; @@ -595,7 +595,7 @@ MySql::configure(const DistInfoBase &info) } void -MySql::configure(const VectorDistInfoBase &info) +MySql::configure(const VectorDistInfo &info) { if (!configure(info, "VECTORDIST")) return; @@ -628,7 +628,7 @@ MySql::configure(const VectorDistInfoBase &info) } void -MySql::configure(const Vector2dInfoBase &info) +MySql::configure(const Vector2dInfo &info) { if (!configure(info, "VECTOR2D")) return; @@ -665,7 +665,7 @@ MySql::configure(const Vector2dInfoBase &info) } void -MySql::configure(const FormulaInfoBase &info) +MySql::configure(const FormulaInfo &info) { MySQL::Connection &mysql = run->conn(); assert(mysql.connected()); @@ -735,7 +735,7 @@ MySql::event(const std::string &event) } void -MySql::output(const ScalarInfoBase &info) +MySql::output(const ScalarInfo &info) { if (!(info.flags & print)) return; @@ -749,7 +749,7 @@ MySql::output(const ScalarInfoBase &info) } void -MySql::output(const VectorInfoBase &info) +MySql::output(const VectorInfo &info) { if (!(info.flags & print)) return; @@ -816,7 +816,7 @@ MySql::output(const DistData &data, const DistParams *params) } void -MySql::output(const DistInfoBase &info) +MySql::output(const DistInfo &info) { if (!(info.flags & print)) return; @@ -827,7 +827,7 @@ MySql::output(const DistInfoBase &info) } void -MySql::output(const VectorDistInfoBase &info) +MySql::output(const VectorDistInfo &info) { if (!(info.flags & print)) return; @@ -843,7 +843,7 @@ MySql::output(const VectorDistInfoBase &info) } void -MySql::output(const Vector2dInfoBase &info) +MySql::output(const Vector2dInfo &info) { if (!(info.flags & print)) return; @@ -862,7 +862,7 @@ MySql::output(const Vector2dInfoBase &info) } void -MySql::output(const FormulaInfoBase &info) +MySql::output(const FormulaInfo &info) { } @@ -870,7 +870,7 @@ MySql::output(const FormulaInfoBase &info) * Implement the visitor */ void -MySql::visit(const ScalarInfoBase &info) +MySql::visit(const ScalarInfo &info) { if (!configured) configure(info); @@ -879,7 +879,7 @@ MySql::visit(const ScalarInfoBase &info) } void -MySql::visit(const VectorInfoBase &info) +MySql::visit(const VectorInfo &info) { if (!configured) configure(info); @@ -888,7 +888,7 @@ MySql::visit(const VectorInfoBase &info) } void -MySql::visit(const DistInfoBase &info) +MySql::visit(const DistInfo &info) { return; if (!configured) @@ -898,7 +898,7 @@ MySql::visit(const DistInfoBase &info) } void -MySql::visit(const VectorDistInfoBase &info) +MySql::visit(const VectorDistInfo &info) { return; if (!configured) @@ -908,7 +908,7 @@ MySql::visit(const VectorDistInfoBase &info) } void -MySql::visit(const Vector2dInfoBase &info) +MySql::visit(const Vector2dInfo &info) { return; if (!configured) @@ -918,7 +918,7 @@ MySql::visit(const Vector2dInfoBase &info) } void -MySql::visit(const FormulaInfoBase &info) +MySql::visit(const FormulaInfo &info) { if (!configured) configure(info); diff --git a/src/base/stats/mysql.hh b/src/base/stats/mysql.hh index 86a4d6d23..45fda2982 100644 --- a/src/base/stats/mysql.hh +++ b/src/base/stats/mysql.hh @@ -40,7 +40,7 @@ namespace MySQL { class Connection; } namespace Stats { -class DistInfoBase; +class DistInfo; class MySqlRun; struct SetupStat @@ -122,7 +122,7 @@ class MySql : public Output SetupStat stat; InsertData newdata; InsertEvent newevent; - std::list formulas; + std::list formulas; bool configured; protected: @@ -156,12 +156,12 @@ class MySql : public Output public: // Implement Visit - virtual void visit(const ScalarInfoBase &info); - virtual void visit(const VectorInfoBase &info); - virtual void visit(const DistInfoBase &info); - virtual void visit(const VectorDistInfoBase &info); - virtual void visit(const Vector2dInfoBase &info); - virtual void visit(const FormulaInfoBase &info); + virtual void visit(const ScalarInfo &info); + virtual void visit(const VectorInfo &info); + virtual void visit(const DistInfo &info); + virtual void visit(const VectorDistInfo &info); + virtual void visit(const Vector2dInfo &info); + virtual void visit(const FormulaInfo &info); // Implement Output virtual bool valid() const; @@ -172,22 +172,22 @@ class MySql : public Output protected: // Output helper - void output(const ScalarInfoBase &info); - void output(const VectorInfoBase &info); - void output(const DistInfoBase &info); - void output(const VectorDistInfoBase &info); - void output(const Vector2dInfoBase &info); - void output(const FormulaInfoBase &info); + void output(const ScalarInfo &info); + void output(const VectorInfo &info); + void output(const DistInfo &info); + void output(const VectorDistInfo &info); + void output(const Vector2dInfo &info); + void output(const FormulaInfo &info); void output(const DistData &data, const DistParams *params); void configure(); bool configure(const Info &info, std::string type); - void configure(const ScalarInfoBase &info); - void configure(const VectorInfoBase &info); - void configure(const DistInfoBase &info); - void configure(const VectorDistInfoBase &info); - void configure(const Vector2dInfoBase &info); - void configure(const FormulaInfoBase &info); + void configure(const ScalarInfo &info); + void configure(const VectorInfo &info); + void configure(const DistInfo &info); + void configure(const VectorDistInfo &info); + void configure(const Vector2dInfo &info); + void configure(const FormulaInfo &info); }; bool initMySQL(std::string host, std::string database, std::string user, diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc index d218d72e0..8502ec747 100644 --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -299,19 +299,19 @@ struct DistPrint const DistData &data; - DistPrint(const Text *text, const DistInfoBase &info); - DistPrint(const Text *text, const VectorDistInfoBase &info, int i); + DistPrint(const Text *text, const DistInfo &info); + DistPrint(const Text *text, const VectorDistInfo &info, int i); void init(const Text *text, const Info &info, const DistParams *params); void operator()(ostream &stream) const; }; -DistPrint::DistPrint(const Text *text, const DistInfoBase &info) +DistPrint::DistPrint(const Text *text, const DistInfo &info) : data(info.data) { init(text, info, safe_cast(info.storageParams)); } -DistPrint::DistPrint(const Text *text, const VectorDistInfoBase &info, int i) +DistPrint::DistPrint(const Text *text, const VectorDistInfo &info, int i) : data(info.data[i]) { init(text, info, safe_cast(info.storageParams)); @@ -458,7 +458,7 @@ DistPrint::operator()(ostream &stream) const } void -Text::visit(const ScalarInfoBase &info) +Text::visit(const ScalarInfo &info) { if (noOutput(info)) return; @@ -477,7 +477,7 @@ Text::visit(const ScalarInfoBase &info) } void -Text::visit(const VectorInfoBase &info) +Text::visit(const VectorInfo &info) { if (noOutput(info)) return; @@ -515,7 +515,7 @@ Text::visit(const VectorInfoBase &info) } void -Text::visit(const Vector2dInfoBase &info) +Text::visit(const Vector2dInfo &info) { if (noOutput(info)) return; @@ -569,7 +569,7 @@ Text::visit(const Vector2dInfoBase &info) } void -Text::visit(const DistInfoBase &info) +Text::visit(const DistInfo &info) { if (noOutput(info)) return; @@ -579,7 +579,7 @@ Text::visit(const DistInfoBase &info) } void -Text::visit(const VectorDistInfoBase &info) +Text::visit(const VectorDistInfo &info) { if (noOutput(info)) return; @@ -591,9 +591,9 @@ Text::visit(const VectorDistInfoBase &info) } void -Text::visit(const FormulaInfoBase &info) +Text::visit(const FormulaInfo &info) { - visit((const VectorInfoBase &)info); + visit((const VectorInfo &)info); } bool diff --git a/src/base/stats/text.hh b/src/base/stats/text.hh index 9f65454af..04b914ae9 100644 --- a/src/base/stats/text.hh +++ b/src/base/stats/text.hh @@ -61,12 +61,12 @@ class Text : public Output void open(const std::string &file); // Implement Visit - virtual void visit(const ScalarInfoBase &info); - virtual void visit(const VectorInfoBase &info); - virtual void visit(const DistInfoBase &info); - virtual void visit(const VectorDistInfoBase &info); - virtual void visit(const Vector2dInfoBase &info); - virtual void visit(const FormulaInfoBase &info); + virtual void visit(const ScalarInfo &info); + virtual void visit(const VectorInfo &info); + virtual void visit(const DistInfo &info); + virtual void visit(const VectorDistInfo &info); + virtual void visit(const Vector2dInfo &info); + virtual void visit(const FormulaInfo &info); // Implement Output virtual bool valid() const; diff --git a/src/base/stats/visit.hh b/src/base/stats/visit.hh index 9d6996689..89dd57912 100644 --- a/src/base/stats/visit.hh +++ b/src/base/stats/visit.hh @@ -39,25 +39,25 @@ namespace Stats { class Info; -class ScalarInfoBase; -class VectorInfoBase; -class DistInfoBase; -class DistInfoBase; -class VectorDistInfoBase; -class Vector2dInfoBase; -class FormulaInfoBase; +class ScalarInfo; +class VectorInfo; +class DistInfo; +class DistInfo; +class VectorDistInfo; +class Vector2dInfo; +class FormulaInfo; struct Visit { Visit(); virtual ~Visit(); - virtual void visit(const ScalarInfoBase &info) = 0; - virtual void visit(const VectorInfoBase &info) = 0; - virtual void visit(const DistInfoBase &info) = 0; - virtual void visit(const VectorDistInfoBase &info) = 0; - virtual void visit(const Vector2dInfoBase &info) = 0; - virtual void visit(const FormulaInfoBase &info) = 0; + virtual void visit(const ScalarInfo &info) = 0; + virtual void visit(const VectorInfo &info) = 0; + virtual void visit(const DistInfo &info) = 0; + virtual void visit(const VectorDistInfo &info) = 0; + virtual void visit(const Vector2dInfo &info) = 0; + virtual void visit(const FormulaInfo &info) = 0; }; /* namespace Stats */ } -- 2.30.2