18 #ifndef HPP_STATISTICS_SUCCESSBIN_HH 19 # define HPP_STATISTICS_SUCCESSBIN_HH 26 # include "hpp/statistics/config.hh" 30 # define HPP_DEFINE_REASON_FAILURE(ID, STRING) \ 31 const ::hpp::statistics::SuccessBin::Reason ID = \ 32 ::hpp::statistics::SuccessBin::createReason ( STRING ); \ 33 struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n 36 namespace statistics {
47 Reason (std::size_t a_id, std::string a_what) :
48 id (a_id), what (a_what) {}
56 Bin(), success_ (success), reason_(r)
59 reason_ = REASON_SUCCESS;
76 inline const std::string& reasonString ()
const;
83 return reason_.id == other.
reason().
id;
91 return reason_.id < other.
reason ().
id;
98 return Reason (reasonID_last++, what);
107 const static Reason REASON_SUCCESS;
108 static std::size_t reasonID_last;
110 inline std::ostream& printValue (std::ostream& os)
const 113 if (success_) os <<
"'Success'";
114 else os <<
"'Failure': " << reason_.
what;
127 const std::size_t& logRatio = 2)
128 : name_ (name), logRatio_ (logRatio)
133 : name_ (other.name_), logRatio_ (other.logRatio_)
156 bool lowRatio = (logRatio_ * nbSuccess () < numberOfObservations());
157 if (autoPrint && lowRatio)
158 hppDout (info, name_ <<
":\n" << *
this);
171 return numberOfObservations() - nbSuccess();
188 #endif // HPP_STATISTICS_SUCCESSBIN_HH void addFailure(const SuccessBin::Reason &r=SuccessBin::REASON_UNKNOWN)
Definition: success-bin.hh:146
const Reason & reason() const
If this bin represents 'failure', returns the reason.
Definition: success-bin.hh:70
std::string what
Definition: success-bin.hh:46
std::size_t id
Definition: success-bin.hh:45
#define hppDout(channel, data)
static const Reason REASON_UNKNOWN
The default reason for 'failure'.
Definition: success-bin.hh:52
std::size_t nbFailure() const
Count the number of failure, in total.
Definition: success-bin.hh:169
SuccessStatistics(const std::string name="", const std::size_t &logRatio=2)
Constructor.
Definition: success-bin.hh:126
bool isLowRatio(const bool autoPrint=false) const
Definition: success-bin.hh:154
Definition: success-bin.hh:44
This class count the number of success and failure.
Definition: success-bin.hh:38
static Reason createReason(const std::string &what)
Definition: success-bin.hh:96
std::size_t nbFailure(const SuccessBin::Reason &r) const
Count the number of a particular failure.
Definition: success-bin.hh:175
Definition: success-bin.hh:119
void addSuccess()
Add a 'success'.
Definition: success-bin.hh:137
SuccessBin(const bool success, const Reason &r=REASON_UNKNOWN)
Constructor.
Definition: success-bin.hh:55
Reason(std::size_t a_id, std::string a_what)
Definition: success-bin.hh:47
bool isSuccess() const
Definition: success-bin.hh:64
std::string name_
Definition: success-bin.hh:180
Statistics< SuccessBin > Parent
Definition: success-bin.hh:123
std::size_t nbSuccess() const
Count the number of success.
Definition: success-bin.hh:163
std::size_t logRatio_
If nbSuccess() * logRatio < numberOfObservations(), write to log.
Definition: success-bin.hh:183
SuccessStatistics(const SuccessStatistics &other)
Copy Constructor.
Definition: success-bin.hh:132