12#include "sparta/statistics/CounterBase.hpp"
51 const std::string& name,
52 const std::string& group,
54 const std::string& desc,
69 const std::string& name,
70 const std::string& group,
72 const std::string& desc,
87 const std::string& name,
88 const std::string& desc,
104 const std::string& name,
105 const std::string& desc,
131 if(parent !=
nullptr){
163 <<
getLocation() <<
" because its behavior is not COUNT_LATEST. "
164 <<
"Other behaviors should only support incrementing or adding";
193 static_assert(std::numeric_limits<counter_type>::is_signed ==
false,
194 "Counter type expected to be unsigned. If counter type "
195 "is changed or made templated, ths following test should "
196 "probably be enabled and increment should be changed to accept an unsigned value only.");
254 return get() == rhp.
get();
271 virtual std::string
stringize(
bool pretty=
false)
const override {
273 std::stringstream ss;
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
Wrapper class to add meta information to a counter definition.
The base class for all Counters.
static std::string getBehaviorName(CounterBehaviorDetailed behave)
Returns a string containing the name of the given behavior.
uint64_t counter_type
Counter value type.
@ COUNT_LATEST
Counter holds the latest value (from most recent activity) and can increase or decrease at any time.
CounterBehavior getBehavior() const
Gets the behavior for this counter specified at construction.
Represents a counter of type counter_type (uint64_t). 2 and greater than 0 with a ceiling specified....
Counter(TreeNode *parent, const std::string &name, const std::string &desc, CounterBase::CounterBehaviorDetailed behave)
Alternate constructor.
virtual bool supportsCompression() const override
Counter(Counter &&rhp)
Move constructor.
Counter & operator=(const Counter &rhp)
Sets a new value.
virtual void onAddingChild_(TreeNode *child) override
React to child registration.
counter_type increment(counter_type add)
Increments the value with overflow detection.
Counter(const Counter &rhp)=delete
Copy construction not allowed.
Counter & operator=(counter_type val)
Sets a new value.
virtual std::string stringize(bool pretty=false) const override
Create a string representation of this node.
Counter(TreeNode *parent, const std::string &name, const std::string &group, TreeNode::group_idx_type group_idx, const std::string &desc, CounterBase::CounterBehaviorDetailed behave)
Alternate constructor.
counter_type get() const override
Gets the value of this counter.
counter_type operator++()
Pre-increments the value with overflow detection.
counter_type set(counter_type val)
Sets a new value.
Counter(TreeNode *parent, const std::string &name, const std::string &group, TreeNode::group_idx_type group_idx, const std::string &desc, CounterBase::CounterBehaviorDetailed behave, visibility_t visibility)
Counter constructor.
bool operator==(const Counter &rhp) const
Compare value to value of another counter.
Counter(TreeNode *parent, const std::string &name, const std::string &desc, CounterBase::CounterBehaviorDetailed behave, visibility_t visibility)
Alternate constructor.
counter_type operator+=(counter_type add)
Increment this value withi overflow detection.
counter_type operator++(int)
Post-increments the value with overflow detection.
static constexpr visibility_t DEFAULT_VISIBILITY
Default node visibility.
visibility_t getVisibility() const
Gets the visibility hint of this node. This is invariant after construction.
uint32_t visibility_t
Continuous visibility level. Several key points along continum are indicated within Visibility.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Node in a composite tree representing a sparta Tree item.
static const group_idx_type GROUP_IDX_NONE
GroupIndex indicating that a node has no group index because it belongs to no group.
std::string getLocation() const override final
static constexpr char GROUP_NAME_NONE[]
Group name indicating that a node belongs to no group.
void addChild(TreeNode *child, bool inherit_phase=true)
Adds a TreeNode to this node as a child.
uint32_t group_idx_type
Index within a group.
virtual TreeNode * getParent()
Gets immediate parent of this node if one exists.
void stringizeTags(std::stringstream &ss) const
Render tags to a string in the form: " tags:[tag0, tag1]" If there are any tags. The leading space ma...
Macros for handling exponential backoff.