xrpld
Loading...
Searching...
No Matches
beast::ManualClock< Clock > Class Template Reference

Manual clock implementation. More...

#include <manual_clock.h>

Inheritance diagram for beast::ManualClock< Clock >:
Collaboration diagram for beast::ManualClock< Clock >:

Public Types

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

Public Member Functions

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

Static Public Attributes

static bool const is_steady = Clock::is_steady

Private Attributes

time_point now_

Detailed Description

template<class Clock>
class beast::ManualClock< 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 20 of file manual_clock.h.

Member Typedef Documentation

◆ rep

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

Definition at line 37 of file abstract_clock.h.

◆ period

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

Definition at line 38 of file abstract_clock.h.

◆ duration

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

Definition at line 39 of file abstract_clock.h.

◆ time_point

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

Definition at line 40 of file abstract_clock.h.

◆ clock_type

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

Definition at line 41 of file abstract_clock.h.

Constructor & Destructor Documentation

◆ ManualClock()

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

Definition at line 31 of file manual_clock.h.

Member Function Documentation

◆ now()

template<class Clock>
time_point beast::ManualClock< Clock >::now ( ) const
nodiscardoverridevirtual

Returns the current time.

Implements beast::AbstractClock< Clock >.

Definition at line 36 of file manual_clock.h.

◆ set() [1/2]

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

Set the current time of the manual clock.

Definition at line 43 of file manual_clock.h.

◆ set() [2/2]

template<class Clock>
template<class Integer>
void beast::ManualClock< Clock >::set ( Integer secondsFromEpoch)

Convenience for setting the time in seconds from epoch.

Definition at line 54 of file manual_clock.h.

◆ advance()

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

Advance the clock by a duration.

Definition at line 62 of file manual_clock.h.

◆ operator++()

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

Convenience for advancing the clock by one second.

Definition at line 72 of file manual_clock.h.

Member Data Documentation

◆ now_

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

Definition at line 28 of file manual_clock.h.

◆ is_steady

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

Definition at line 43 of file abstract_clock.h.