libecs-cpp 2.1.0
Entity Component System library in C++
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ecs::ManualClock Class Reference

A clock that only moves when told to, for tests. More...

#include <Clock.hpp>

Inheritance diagram for ecs::ManualClock:
Inheritance graph
[legend]
Collaboration diagram for ecs::ManualClock:
Collaboration graph
[legend]

Public Member Functions

 ManualClock (std::chrono::microseconds start=std::chrono::microseconds(0))
 Creates a clock that reads the given time, zero by default.
 
std::chrono::microseconds Now () const override
 Time since the clock's starting point, in microseconds.
 
void Advance (std::chrono::microseconds delta)
 Moves time forward.
 
void Set (std::chrono::microseconds value)
 Sets the time.
 
- Public Member Functions inherited from ecs::Clock
virtual ~Clock ()=default
 Destroys the clock.
 

Detailed Description

A clock that only moves when told to, for tests.

Safe to read and move from any thread. A container that has its own thread sleeps on the real clock between passes, so use a ManualClock with containers that are driven by calls to Container::Update().

Constructor & Destructor Documentation

◆ ManualClock()

ecs::ManualClock::ManualClock ( std::chrono::microseconds  start = std::chrono::microseconds(0))
inlineexplicit

Creates a clock that reads the given time, zero by default.

Member Function Documentation

◆ Advance()

void ecs::ManualClock::Advance ( std::chrono::microseconds  delta)
inline

Moves time forward.

A negative amount throws std::runtime_error and changes nothing.

◆ Now()

std::chrono::microseconds ecs::ManualClock::Now ( ) const
inlineoverridevirtual

Time since the clock's starting point, in microseconds.

Never decreases.

Implements ecs::Clock.

◆ Set()

void ecs::ManualClock::Set ( std::chrono::microseconds  value)
inline

Sets the time.

The caller keeps it from going backwards.


The documentation for this class was generated from the following file: