rippled
Public Types | Public Member Functions | Static Public Attributes | List of all members
beast::abstract_clock< Clock > Class Template Referenceabstract

Abstract interface to a clock. More...

Inheritance diagram for beast::abstract_clock< Clock >:
Inheritance graph
[legend]

Public Types

using rep = typename Clock::rep
 
using period = typename Clock::period
 
using duration = typename Clock::duration
 
using time_point = typename Clock::time_point
 
using clock_type = Clock
 

Public Member Functions

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

Static Public Attributes

static const bool is_steady = Clock::is_steady
 

Detailed Description

template<class Clock>
class beast::abstract_clock< 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 abstract_clock inherits all the nested types of the Clock template parameter.

Example:

struct Implementation
{
using clock_type = abstract_clock <std::chrono::steady_clock>;
clock_type& clock_;
explicit Implementation (clock_type& clock)
: clock_(clock)
{
}
};
Template Parameters
ClockA type meeting these requirements: http://en.cppreference.com/w/cpp/concept/Clock

Definition at line 57 of file abstract_clock.h.

Member Typedef Documentation

◆ rep

template<class Clock >
using beast::abstract_clock< Clock >::rep = typename Clock::rep

Definition at line 60 of file abstract_clock.h.

◆ period

template<class Clock >
using beast::abstract_clock< Clock >::period = typename Clock::period

Definition at line 61 of file abstract_clock.h.

◆ duration

template<class Clock >
using beast::abstract_clock< Clock >::duration = typename Clock::duration

Definition at line 62 of file abstract_clock.h.

◆ time_point

template<class Clock >
using beast::abstract_clock< Clock >::time_point = typename Clock::time_point

Definition at line 63 of file abstract_clock.h.

◆ clock_type

template<class Clock >
using beast::abstract_clock< Clock >::clock_type = Clock

Definition at line 64 of file abstract_clock.h.

Constructor & Destructor Documentation

◆ ~abstract_clock()

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

◆ abstract_clock() [1/2]

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

◆ abstract_clock() [2/2]

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

Member Function Documentation

◆ now()

template<class Clock >
virtual time_point beast::abstract_clock< Clock >::now ( ) const
pure virtual

Member Data Documentation

◆ is_steady

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

Definition at line 66 of file abstract_clock.h.

beast::abstract_clock::clock_type
Clock clock_type
Definition: abstract_clock.h:64
std::clock
T clock(T... args)