# HG changeset patch # User Alain Mazy # Date 1776174048 -7200 # Node ID 3e7a9e980269b43bf13a2a4f8401061f4b83c82b # Parent d0bdedd75ff78e4be3f45d2893a58f5636e99e84 doc + cppcheck in WeightedAverageMetrics diff -r d0bdedd75ff7 -r 3e7a9e980269 Plugin/WeightedAverageMetrics.h --- a/Plugin/WeightedAverageMetrics.h Tue Apr 14 14:31:12 2026 +0200 +++ b/Plugin/WeightedAverageMetrics.h Tue Apr 14 15:40:48 2026 +0200 @@ -29,6 +29,10 @@ #include +// This class is used to compute e.g: the average throughput +// of all WADO-RS retrievals over a period of time. For each call, we +// give a value (in this case: the throughput) and a weight (a large request +// has more weight than a small request). template class WeightedAverageMetrics : public boost::noncopyable { @@ -60,7 +64,7 @@ if (values_.size() > 0) { - Value& oldest = values_.front(); + Value oldest = values_.front(); while ((now - oldest.time_).total_seconds() > duration_) { totalWeightedValue_ -= oldest.value_ * oldest.weight_; @@ -70,12 +74,16 @@ { oldest = values_.front(); } + else + { + return; + } } } } public: - WeightedAverageMetrics(int64_t duration) : + explicit WeightedAverageMetrics(int64_t duration) : totalWeightedValue_(0), totalWeight_(0), duration_(duration)