rippled
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
beast::manual_clock< Clock > Class Template Reference

Manual clock implementation. More...

Inheritance diagram for beast::manual_clock< Clock >:
Inheritance graph
[legend]
Collaboration diagram for beast::manual_clock< Clock >:
Collaboration 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

 manual_clock (time_point const &now=time_point(duration(0)))
 
time_point now () const override
 Returns the current time. More...
 
void set (time_point const &when)
 Set the current time of the manual clock. More...
 
template<class Integer >
void set (Integer seconds_from_epoch)
 Convenience for setting the time in seconds from epoch. More...
 
template<class Rep , class Period >
void advance (std::chrono::duration< Rep, Period > const &elapsed)
 Advance the clock by a duration. More...
 
manual_clockoperator++ ()
 Convenience for advancing the clock by one second. More...
 

Static Public Attributes

static const bool is_steady = Clock::is_steady
 

Private Attributes

time_point now_
 

Detailed Description

template<class Clock>
class beast::manual_clock< Clock >

Manual clock implementation.

This concrete class implements the abstract_clock interface and allows the time to be advanced manually, mainly for the purpose of providing a clock in unit tests.

Template Parameters
ClockA type meeting these requirements: http://en.cppreference.com/w/cpp/concept/Clock

Definition at line 38 of file manual_clock.h.

Member Typedef Documentation

◆ rep

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

Definition at line 60 of file abstract_clock.h.

◆ period

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

Definition at line 61 of file abstract_clock.h.

◆ duration

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

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
inherited

Definition at line 63 of file abstract_clock.h.

◆ clock_type

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

Definition at line 64 of file abstract_clock.h.

Constructor & Destructor Documentation

◆ manual_clock()

template<class Clock >
beast::manual_clock< Clock >::manual_clock ( time_point const &  now = time_point(duration(0)))
explicit

Definition at line 49 of file manual_clock.h.

Member Function Documentation

◆ now()

template<class Clock >
time_point beast::manual_clock< Clock >::now ( ) const
overridevirtual

Returns the current time.

Implements beast::abstract_clock< Clock >.

Definition at line 55 of file manual_clock.h.

◆ set() [1/2]

template<class Clock >
void beast::manual_clock< Clock >::set ( time_point const &  when)

Set the current time of the manual clock.

Definition at line 62 of file manual_clock.h.

◆ set() [2/2]

template<class Clock >
template<class Integer >
void beast::manual_clock< Clock >::set ( Integer  seconds_from_epoch)

Convenience for setting the time in seconds from epoch.

Definition at line 71 of file manual_clock.h.

◆ advance()

template<class Clock >
template<class Rep , class Period >
void beast::manual_clock< Clock >::advance ( std::chrono::duration< Rep, Period > const &  elapsed)

Advance the clock by a duration.

Definition at line 79 of file manual_clock.h.

◆ operator++()

template<class Clock >
manual_clock& beast::manual_clock< Clock >::operator++ ( )

Convenience for advancing the clock by one second.

Definition at line 87 of file manual_clock.h.

Member Data Documentation

◆ now_

template<class Clock >
time_point beast::manual_clock< Clock >::now_
private

Definition at line 46 of file manual_clock.h.

◆ is_steady

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

Definition at line 66 of file abstract_clock.h.