Skip to content

Commit

Permalink
Fix reporting bug where ContextCounters have their per-context counts…
Browse files Browse the repository at this point in the history
… printed twice (#497)

* Fix reporting bug where ContextCounters have their per-context counts
printed twice

* Update Doxygen comments for add() methods

* Second (simpler) attempt at fixing duplicate ContextCounters in reports

* Make all single-argument StatisticInstance constructors explicit
Change StatAdder operator() to take const TreeNode* instead of TreeNode*
  • Loading branch information
bdutro authored May 3, 2024
1 parent a0d7ca4 commit 2f3dc4c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sparta/sparta/report/Report.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ namespace sparta
r_.add(ctr, name);
return *this;
}
StatAdder& operator()(TreeNode* n,
StatAdder& operator()(const TreeNode* n,
const std::string& name="") {
r_.add(n, name);
return *this;
Expand Down Expand Up @@ -435,7 +435,7 @@ namespace sparta
* \param n The TreeNode to add
* \param name The name of the item in the report
*/
StatAdder add(TreeNode* n, const std::string& name="");
StatAdder add(const TreeNode* n, const std::string& name="");

/*!
* \brief Add a single Expression parsed at the current context for this
Expand Down
8 changes: 4 additions & 4 deletions sparta/sparta/statistics/StatisticInstance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace sparta
* \note Stream insertion operator can be used to add more text to the
* reason.
*/
ReversedStatisticRange(const std::string & reason) :
explicit ReversedStatisticRange(const std::string & reason) :
SpartaException(reason)
{ }

Expand All @@ -67,7 +67,7 @@ namespace sparta
* \note Stream insertion operator can be used to add more text to the
* reason.
*/
FutureStatisticRange(const std::string & reason) :
explicit FutureStatisticRange(const std::string & reason) :
SpartaException(reason)
{ }

Expand Down Expand Up @@ -128,15 +128,15 @@ namespace sparta
* \note You *must* set the context (setContext) after this
* call. The Expression might or might not know the context for the Scheduler
*/
StatisticInstance(statistics::expression::Expression&& expr) :
explicit StatisticInstance(statistics::expression::Expression&& expr) :
stat_expr_(expr)
{ }

/*!
* \brief Construct with a StatisticDef or Counter as a TreeNode*
* \param node Must be an interface to a StatisticDef or a Counter
*/
StatisticInstance(const TreeNode* node) :
explicit StatisticInstance(const TreeNode* node) :
StatisticInstance(nullptr, nullptr, nullptr, node, nullptr)
{ }

Expand Down
2 changes: 1 addition & 1 deletion sparta/src/Report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ Report::StatAdder Report::add(CounterBase* ctr, const std::string& name) {
return Report::StatAdder(*this);
}

Report::StatAdder Report::add(TreeNode* n, const std::string& name) {
Report::StatAdder Report::add(const TreeNode* n, const std::string& name) {
sparta_assert(n);
if(name != "" && stat_names_.find(name) != stat_names_.end()){
throw SpartaException("There is already a statistic instance in this Report (")
Expand Down

0 comments on commit 2f3dc4c

Please sign in to comment.