rippled
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ripple::DecayingSample< Window, Clock > Class Template Reference

Sampling function using exponential decay to provide a continuous value. More...

Public Types

using value_type = typename Clock::duration::rep
 
using time_point = typename Clock::time_point
 

Public Member Functions

 DecayingSample ()=delete
 
 DecayingSample (time_point now)
 
value_type add (value_type value, time_point now)
 Add a new sample. More...
 
value_type value (time_point now)
 Retrieve the current value in normalized units. More...
 

Private Member Functions

void decay (time_point now)
 

Private Attributes

value_type m_value
 
time_point m_when
 

Detailed Description

template<int Window, typename Clock>
class ripple::DecayingSample< Window, Clock >

Sampling function using exponential decay to provide a continuous value.

Template Parameters
Thenumber of seconds in the decay window.

Definition at line 32 of file DecayingSample.h.

Member Typedef Documentation

◆ value_type

template<int Window, typename Clock >
using ripple::DecayingSample< Window, Clock >::value_type = typename Clock::duration::rep

Definition at line 35 of file DecayingSample.h.

◆ time_point

template<int Window, typename Clock >
using ripple::DecayingSample< Window, Clock >::time_point = typename Clock::time_point

Definition at line 36 of file DecayingSample.h.

Constructor & Destructor Documentation

◆ DecayingSample() [1/2]

template<int Window, typename Clock >
ripple::DecayingSample< Window, Clock >::DecayingSample ( )
delete

◆ DecayingSample() [2/2]

template<int Window, typename Clock >
ripple::DecayingSample< Window, Clock >::DecayingSample ( time_point  now)
explicit
Parameters
nowStart time of DecayingSample.

Definition at line 43 of file DecayingSample.h.

Member Function Documentation

◆ add()

template<int Window, typename Clock >
value_type ripple::DecayingSample< Window, Clock >::add ( value_type  value,
time_point  now 
)

Add a new sample.

The value is first aged according to the specified time.

Definition at line 51 of file DecayingSample.h.

◆ value()

template<int Window, typename Clock >
value_type ripple::DecayingSample< Window, Clock >::value ( time_point  now)

Retrieve the current value in normalized units.

The samples are first aged according to the specified time.

Definition at line 62 of file DecayingSample.h.

◆ decay()

template<int Window, typename Clock >
void ripple::DecayingSample< Window, Clock >::decay ( time_point  now)
private

Definition at line 71 of file DecayingSample.h.

Member Data Documentation

◆ m_value

template<int Window, typename Clock >
value_type ripple::DecayingSample< Window, Clock >::m_value
private

Definition at line 100 of file DecayingSample.h.

◆ m_when

template<int Window, typename Clock >
time_point ripple::DecayingSample< Window, Clock >::m_when
private

Definition at line 103 of file DecayingSample.h.