changeset 63e849f0f341 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=63e849f0f341
description:
        stats: add user settable separator string for arrayed stats

        Default is '::', so no visible change unless it is overridden

diffstat:

 src/base/statistics.cc |   1 +
 src/base/statistics.hh |  17 +++++++++++++++++
 src/base/stats/info.hh |   3 +++
 src/base/stats/text.cc |   9 +++++++--
 4 files changed, 28 insertions(+), 2 deletions(-)

diffs (119 lines):

diff -r f52ece27e20d -r 63e849f0f341 src/base/statistics.cc
--- a/src/base/statistics.cc    Wed Apr 20 11:14:51 2011 -0700
+++ b/src/base/statistics.cc    Wed Apr 20 11:14:52 2011 -0700
@@ -48,6 +48,7 @@
 
 namespace Stats {
 
+std::string Info::separatorString = "::";
 typedef map<const void *, Info *> MapType;
 
 // We wrap these in a function to make sure they're built in time.
diff -r f52ece27e20d -r 63e849f0f341 src/base/statistics.hh
--- a/src/base/statistics.hh    Wed Apr 20 11:14:51 2011 -0700
+++ b/src/base/statistics.hh    Wed Apr 20 11:14:52 2011 -0700
@@ -256,6 +256,23 @@
     const std::string &name() const { return this->info()->name; }
 
     /**
+     * Set the character(s) used between the name and vector number
+     * on vectors, dist, etc.
+     * @param _sep The new separator string
+     * @return A reference to this stat.
+     */
+    Derived &
+    setSeparator(const std::string &_sep)
+    {
+      this->info()->setSeparator(_sep);
+      return this->self();
+    }
+    const std::string &setSeparator() const
+    {
+      return this->info()->separatorString;
+    }
+
+    /**
      * Set the description and marks this stat to print at the end of
      * simulation.
      * @param desc The new description.
diff -r f52ece27e20d -r 63e849f0f341 src/base/stats/info.hh
--- a/src/base/stats/info.hh    Wed Apr 20 11:14:51 2011 -0700
+++ b/src/base/stats/info.hh    Wed Apr 20 11:14:52 2011 -0700
@@ -69,6 +69,8 @@
   public:
     /** The name of the stat. */
     std::string name;
+    /** The separator string used for vectors, dist, etc. */
+    static std::string separatorString;
     /** The description of the stat. */
     std::string desc;
     /** The formatting flags. */
@@ -93,6 +95,7 @@
 
     /** Set the name of this statistic */
     void setName(const std::string &name);
+    void setSeparator(std::string _sep) { separatorString = _sep;}
 
     /**
      * Check that this stat has been set up properly and is ready for
diff -r f52ece27e20d -r 63e849f0f341 src/base/stats/text.cc
--- a/src/base/stats/text.cc    Wed Apr 20 11:14:51 2011 -0700
+++ b/src/base/stats/text.cc    Wed Apr 20 11:14:52 2011 -0700
@@ -234,6 +234,7 @@
 struct VectorPrint
 {
     string name;
+    string separatorString;
     string desc;
     vector<string> subnames;
     vector<string> subdescs;
@@ -258,7 +259,7 @@
         }
     }
 
-    string base = name + "::";
+    string base = name + separatorString;
 
     ScalarPrint print;
     print.name = name;
@@ -301,6 +302,7 @@
 struct DistPrint
 {
     string name;
+    string separatorString;
     string desc;
     Flags flags;
     bool descriptions;
@@ -336,6 +338,7 @@
 DistPrint::init(const Text *text, const Info &info)
 {
     name = info.name;
+    separatorString = info.separatorString;
     desc = info.desc;
     flags = info.flags;
     precision = info.precision;
@@ -345,7 +348,7 @@
 void
 DistPrint::operator()(ostream &stream) const
 {
-    string base = name + "::";
+    string base = name + separatorString;
 
     ScalarPrint print;
     print.precision = precision;
@@ -465,6 +468,7 @@
     VectorPrint print;
 
     print.name = info.name;
+    print.separatorString = info.separatorString;
     print.desc = info.desc;
     print.flags = info.flags;
     print.descriptions = descriptions;
@@ -504,6 +508,7 @@
 
     print.subnames = info.y_subnames;
     print.flags = info.flags;
+    print.separatorString = info.separatorString;
     print.descriptions = descriptions;
     print.precision = info.precision;
 
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to