Counts events, forgetting old ones. Useful for "3 errors/minute" limits. More...

#include <FadingCounter.h>

Collaboration diagram for FadingCounter:

Public Member Functions

 FadingCounter ()
 
void configure (double horizonSeconds)
 0=remember nothing; -1=forget nothing; new value triggers clear() More...
 
void clear ()
 forgets all events More...
 
int count (int howMany)
 count fresh, return #events remembered More...
 
int remembered () const
 possibly stale #events More...
 

Public Attributes

double horizon
 read-only memory horizon in seconds; older events are forgotten More...
 

Private Attributes

const int precision
 #counting slots, controls measur. accuracy More...
 
double delta
 sub-interval duration = horizon/precision More...
 
double lastTime
 time of the last update More...
 
std::vector< intcounters
 events per delta (possibly stale) More...
 
int total
 number of remembered events (possibly stale) More...
 

Detailed Description

Definition at line 15 of file FadingCounter.h.

Constructor & Destructor Documentation

◆ FadingCounter()

FadingCounter::FadingCounter ( )

Definition at line 17 of file FadingCounter.cc.

References counters, and precision.

Member Function Documentation

◆ clear()

void FadingCounter::clear ( )

Definition at line 25 of file FadingCounter.cc.

References counters, current_dtime, lastTime, precision, and total.

Referenced by configure(), and count().

◆ configure()

void FadingCounter::configure ( double  horizonSeconds)

Definition at line 33 of file FadingCounter.cc.

References clear(), delta, horizon, and precision.

Referenced by Ssl::ClientBio::ClientBio().

◆ count()

int FadingCounter::count ( int  howMany)

Definition at line 42 of file FadingCounter.cc.

References clear(), counters, current_dtime, delta, horizon, lastTime, Must, precision, and total.

Referenced by ESIContext::parse().

◆ remembered()

int FadingCounter::remembered ( ) const
inline

Definition at line 26 of file FadingCounter.h.

References total.

Member Data Documentation

◆ counters

std::vector<int> FadingCounter::counters
private

Definition at line 36 of file FadingCounter.h.

Referenced by FadingCounter(), clear(), and count().

◆ delta

double FadingCounter::delta
private

Definition at line 33 of file FadingCounter.h.

Referenced by configure(), and count().

◆ horizon

double FadingCounter::horizon

Definition at line 29 of file FadingCounter.h.

Referenced by configure(), and count().

◆ lastTime

double FadingCounter::lastTime
private

Definition at line 35 of file FadingCounter.h.

Referenced by clear(), and count().

◆ precision

const int FadingCounter::precision
private

Definition at line 32 of file FadingCounter.h.

Referenced by FadingCounter(), clear(), configure(), and count().

◆ total

int FadingCounter::total
private

Definition at line 37 of file FadingCounter.h.

Referenced by clear(), count(), and remembered().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors