The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::BasicHistogram< BucketT, ASSERT_ON_UNDERFLOW > Class Template Reference

#include <BasicHistogram.hpp>

Public Member Functions

 BasicHistogram (sparta::StatisticSet &sset, const std::string &name, const std::string &desc, const std::vector< BucketT > &buckets)
 Construct a BasicHistogram.
 
 ~BasicHistogram ()
 Destroy, non-virtual.
 
void addValue (const BucketT &val)
 Charge a bucket where the given val falls.
 
 BasicHistogram (const BasicHistogram &)=delete
 Disallow copies/assignment/move.
 
 BasicHistogram (BasicHistogram &&)=delete
 
const BasicHistogramoperator= (const BasicHistogram &)=delete
 
BasicHistogramoperator= (BasicHistogram &&)=delete
 

Detailed Description

template<typename BucketT, bool ASSERT_ON_UNDERFLOW = false>
class sparta::BasicHistogram< BucketT, ASSERT_ON_UNDERFLOW >
Template Parameters
BucketTType contained in the buckets
ASSERT_ON_UNDERFLOW(default false) true will assert if an underflow is detected

This class will create sparta::Counters for each "bucket" of BucketT given in the contructor

The objects contained in the buckets must follow these rules:

The object type must be copyable (for initialization)

The object must respond to the comparison operator== and operator< operator>

A "bucket" is charged a count if an object being added is less than the given bucket. Examples:

sparta::BasicHistogram<int> example_bh(sset_, "example_bh", "Example BasicHistogram", {0,10,20});
example_bh.addValue(-1); // Will add a charge to the 0 -> 10 bucket
example_bh.addValue( 1); // Will add a charge to the 0 -> 10 bucket
example_bh.addValue(10); // Will add a charge to the 0 -> 10 bucket
example_bh.addValue(11); // Will add a charge to the 10 -> 20 bucket
example_bh.addValue(20); // Will add a charge to the 10 -> 20 bucket
example_bh.addValue(21); // Will add a charge to the 10 -> 20 bucket
void addValue(const BucketT &val)
Charge a bucket where the given val falls.

Definition at line 42 of file BasicHistogram.hpp.

Constructor & Destructor Documentation

◆ BasicHistogram()

template<typename BucketT , bool ASSERT_ON_UNDERFLOW = false>
sparta::BasicHistogram< BucketT, ASSERT_ON_UNDERFLOW >::BasicHistogram ( sparta::StatisticSet sset,
const std::string &  name,
const std::string &  desc,
const std::vector< BucketT > &  buckets 
)
inline

Construct a BasicHistogram.

Parameters
ssetThe sparta::StatisticSet this histogram belongs to
nameThe name of thie BasicHistogram
descA useful description
bucketsone bucket will be created per value (plus one for overflow) - values must be sorted

Definition at line 52 of file BasicHistogram.hpp.

◆ ~BasicHistogram()

template<typename BucketT , bool ASSERT_ON_UNDERFLOW = false>
sparta::BasicHistogram< BucketT, ASSERT_ON_UNDERFLOW >::~BasicHistogram ( )
inline

Destroy, non-virtual.

Definition at line 92 of file BasicHistogram.hpp.

Member Function Documentation

◆ addValue()

template<typename BucketT , bool ASSERT_ON_UNDERFLOW = false>
void sparta::BasicHistogram< BucketT, ASSERT_ON_UNDERFLOW >::addValue ( const BucketT &  val)
inline

Charge a bucket where the given val falls.

Parameters
valThe value to charge

A "bucket" is charged a count if an object being added is less than the given bucket. Overflows will go into the last bucket. Undeflows will either assert or charge to the smallest bucket (depending on class template parameter ASSERT_ON_UNDERFLOW)

Definition at line 103 of file BasicHistogram.hpp.


The documentation for this class was generated from the following file: