contur2
Loading...
Searching...
No Matches
clock.h
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <memory>
11
12#include "contur/core/types.h"
13
14namespace contur {
15
20 class IClock
21 {
22 public:
23 virtual ~IClock() = default;
24
27 [[nodiscard]] virtual Tick now() const noexcept = 0;
28
31 virtual void tick() = 0;
32
35 virtual void reset() = 0;
36 };
37
42 class SimulationClock final : public IClock
43 {
44 public:
47 ~SimulationClock() override;
48
49 // Non-copyable
52
53 // Movable
55 SimulationClock &operator=(SimulationClock &&) noexcept;
56
59 [[nodiscard]] Tick now() const noexcept override;
60
63 void tick() override;
64
67 void reset() override;
68
69 private:
70 struct Impl;
71 std::unique_ptr<Impl> impl_;
72 };
73
74} // namespace contur
Abstract clock interface for simulation time.
Definition clock.h:21
virtual void tick()=0
Advances the simulation clock by one tick.
virtual Tick now() const noexcept=0
Returns the current simulation tick.
virtual ~IClock()=default
virtual void reset()=0
Resets the clock to tick 0.
SimulationClock(const SimulationClock &)=delete
void reset() override
Resets the clock to tick 0.
void tick() override
Advances the simulation clock by one tick.
Tick now() const noexcept override
Returns the current simulation tick.
SimulationClock(SimulationClock &&) noexcept
SimulationClock()
Constructs a new simulation clock initialized to tick 0.
SimulationClock & operator=(const SimulationClock &)=delete
std::unique_ptr< Impl > impl_
Definition clock.h:71
Definition block.h:15
std::uint64_t Tick
Simulation clock tick counter.
Definition types.h:18
Common type aliases, sentinel constants, and forward declarations used throughout the Contur 2 kernel...