xrpld
Loading...
Searching...
No Matches
beast::AbstractClock< Clock > Class Template Referenceabstract

Abstract interface to a clock. More...

#include <abstract_clock.h>

Inheritance diagram for beast::AbstractClock< Clock >:

Public Types

using rep = Clock::rep
using period = Clock::period
using duration = Clock::duration
using time_point = Clock::time_point
using ClockType = Clock

Public Member Functions

virtual ~AbstractClock ()=default
 AbstractClock ()=default
 AbstractClock (AbstractClock const &)=default
virtual time_point now () const =0
 Returns the current time.

Static Public Attributes

static bool const is_steady = Clock::is_steady

Detailed Description

template<class Clock>
class beast::AbstractClock< Clock >

Abstract interface to a clock.

This makes now() a member function instead of a static member, so an instance of the class can be dependency injected, facilitating unit tests where time may be controlled.

An AbstractClock inherits all the nested types of the Clock template parameter.

Example:

struct Implementation
{
ClockType& clock_;
explicit Implementation(ClockType& clock)
: clock_(clock)
{
}
};
Template Parameters
ClockA type meeting these requirements: http://en.cppreference.com/w/cpp/concept/Clock

Definition at line 35 of file abstract_clock.h.

Member Typedef Documentation

◆ rep

template<class Clock>
using beast::AbstractClock< Clock >::rep = Clock::rep

Definition at line 38 of file abstract_clock.h.

◆ period

template<class Clock>
using beast::AbstractClock< Clock >::period = Clock::period

Definition at line 39 of file abstract_clock.h.

◆ duration

template<class Clock>
using beast::AbstractClock< Clock >::duration = Clock::duration

Definition at line 40 of file abstract_clock.h.

◆ time_point

template<class Clock>
using beast::AbstractClock< Clock >::time_point = Clock::time_point

Definition at line 41 of file abstract_clock.h.

◆ ClockType

template<class Clock>
using beast::AbstractClock< Clock >::ClockType = Clock

Definition at line 42 of file abstract_clock.h.

Constructor & Destructor Documentation

◆ ~AbstractClock()

template<class Clock>
virtual beast::AbstractClock< Clock >::~AbstractClock ( )
virtualdefault

◆ AbstractClock() [1/2]

template<class Clock>
beast::AbstractClock< Clock >::AbstractClock ( )
default

◆ AbstractClock() [2/2]

template<class Clock>
beast::AbstractClock< Clock >::AbstractClock ( AbstractClock< Clock > const & )
default

Member Function Documentation

◆ now()

template<class Clock>
virtual time_point beast::AbstractClock< Clock >::now ( ) const
nodiscardpure virtual

Member Data Documentation

◆ is_steady

template<class Clock>
bool const beast::AbstractClock< Clock >::is_steady = Clock::is_steady
static

Definition at line 44 of file abstract_clock.h.