xrpld
Loading...
Searching...
No Matches
xrpl::DecayingSample< Window, Clock > Class Template Reference

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

#include <DecayingSample.h>

Public Types

using value_type = Clock::duration::rep
using time_point = 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.
value_type value (time_point now)
 Retrieve the current value in normalized units.

Private Member Functions

void decay (time_point now)

Private Attributes

value_type value_
time_point when_

Detailed Description

template<int Window, typename Clock>
class xrpl::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 12 of file DecayingSample.h.

Member Typedef Documentation

◆ value_type

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

Definition at line 15 of file DecayingSample.h.

◆ time_point

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

Definition at line 16 of file DecayingSample.h.

Constructor & Destructor Documentation

◆ DecayingSample() [1/2]

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

◆ DecayingSample() [2/2]

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

Definition at line 23 of file DecayingSample.h.

Member Function Documentation

◆ add()

template<int Window, typename Clock>
value_type xrpl::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 31 of file DecayingSample.h.

◆ value()

template<int Window, typename Clock>
value_type xrpl::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 42 of file DecayingSample.h.

◆ decay()

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

Definition at line 51 of file DecayingSample.h.

Member Data Documentation

◆ value_

template<int Window, typename Clock>
value_type xrpl::DecayingSample< Window, Clock >::value_
private

Definition at line 81 of file DecayingSample.h.

◆ when_

template<int Window, typename Clock>
time_point xrpl::DecayingSample< Window, Clock >::when_
private

Definition at line 84 of file DecayingSample.h.