    

 ## On this page

  

 

 # i\_clock

 Last update: 16.07.2025 

<a id="l00001" name="l00001"></a> 1 

<a id="l00005" name="l00005"></a> 5 

<a id="l00006" name="l00006"></a> 6\#pragma once

<a id="l00007" name="l00007"></a> 7 

<a id="l00008" name="l00008"></a> 8\#include "core/time/i\_clock/timestamp.h"

<a id="l00009" name="l00009"></a> 9\#include &lt;chrono&gt;

<a id="l00010" name="l00010"></a> 10\#include &lt;memory&gt;

<a id="l00011" name="l00011"></a> 11 

<a id="l00016" name="l00016"></a> 16namespace [simulation\_framework](namespacesimulation__framework.xhtml)

<a id="l00017" name="l00017"></a> 17{

<a id="l00018" name="l00018"></a> 18namespace [core](namespacecore.xhtml)

<a id="l00019" name="l00019"></a> 19{

<a id="l00024" name="l00024"></a> 24namespace [time](namespacetime.xhtml)

<a id="l00025" name="l00025"></a> 25{

<a id="l00026" name="l00026"></a> 26 

<a id="l00027" name="l00027"></a> 27template &lt;class Duration&gt;

<a id="l00028" name="l00028"></a> 28using timepoint = std::chrono::time_point&lt;std::chrono::system_clock, Duration&gt;;

<a id="l00029" name="l00029"></a> 29using milliseconds = std::chrono::milliseconds;

<a id="l00030" name="l00030"></a> 30 

<a id="l00038" name="l00038"></a>[ 38](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml)class [IClock](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml)

<a id="l00039" name="l00039"></a> 39{

<a id="l00040" name="l00040"></a> 40 public:

<a id="l00043" name="l00043"></a>[ 43](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a81888860915574a48b4f436e87fbc35e) virtual [~IClock](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a81888860915574a48b4f436e87fbc35e)() = default;

<a id="l00044" name="l00044"></a> 44 

<a id="l00049" name="l00049"></a>[ 49](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a1c559515085520b85213dd1e85527149) virtual void [SetNow](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a1c559515085520b85213dd1e85527149)(const milliseconds&amp; [ms](classsimulation__framework_1_1core_1_1Topic.xhtml)) = 0;

<a id="l00050" name="l00050"></a> 50 

<a id="l00055" name="l00055"></a>[ 55](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a9a5d393c4f9087ad954b0d754cf73fb6) virtual void [SetNow](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a9a5d393c4f9087ad954b0d754cf73fb6)(const Timestamp&amp; timestamp) = 0;

<a id="l00056" name="l00056"></a> 56 

<a id="l00061" name="l00061"></a>[ 61](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a23ad965396946a6fad21103baf8ed5ff) virtual milliseconds [GetNow](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a23ad965396946a6fad21103baf8ed5ff)() const = 0;

<a id="l00062" name="l00062"></a> 62 

<a id="l00067" name="l00067"></a>[ 67](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a08b2e6144d8dc49bce2f684e6fdf8199) virtual Timestamp [GetNowAsTimestamp](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a08b2e6144d8dc49bce2f684e6fdf8199)() const = 0;

<a id="l00068" name="l00068"></a> 68 

<a id="l00073" name="l00073"></a>[ 73](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a93cef605ec46a30ae9542ba40e5bda21) virtual void [IncrementBy](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a93cef605ec46a30ae9542ba40e5bda21)(const milliseconds&amp; [ms](classsimulation__framework_1_1core_1_1Topic.xhtml)) = 0;

<a id="l00074" name="l00074"></a> 74};



<a id="l00075" name="l00075"></a> 75 

<a id="l00076" name="l00076"></a> 76} // namespace time

<a id="l00077" name="l00077"></a> 77} // namespace core

<a id="l00078" name="l00078"></a> 78} // namespace simulation\_framework

[simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)

This is the concrete Topic class that can be used for creation of a communication channel with given ...

**Definition** [topic.h:38](topic_8h_source.xhtml#l00037)



[simulation\_framework::core::time::IClock](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml)

Interface for managing and manipulating simulation time.

**Definition** [i\_clock.h:39](i__clock_8h_source.xhtml#l00038)



[simulation\_framework::core::time::IClock::GetNowAsTimestamp](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a08b2e6144d8dc49bce2f684e6fdf8199)

virtual Timestamp GetNowAsTimestamp() const =0

Gets the current simulation time as a timestamp.



[simulation\_framework::core::time::IClock::SetNow](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a1c559515085520b85213dd1e85527149)

virtual void SetNow(const milliseconds &amp;ms)=0

Sets the current simulation time.



[simulation\_framework::core::time::IClock::GetNow](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a23ad965396946a6fad21103baf8ed5ff)

virtual milliseconds GetNow() const =0

Gets the current simulation time in milliseconds.



[simulation\_framework::core::time::IClock::~IClock](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a81888860915574a48b4f436e87fbc35e)

virtual ~IClock()=default

Virtual destructor.



[simulation\_framework::core::time::IClock::IncrementBy](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a93cef605ec46a30ae9542ba40e5bda21)

virtual void IncrementBy(const milliseconds &amp;ms)=0

Increments the simulation time by a specified duration.



[simulation\_framework::core::time::IClock::SetNow](classsimulation__framework_1_1core_1_1time_1_1IClock.xhtml#a9a5d393c4f9087ad954b0d754cf73fb6)

virtual void SetNow(const Timestamp &amp;timestamp)=0

Sets the current simulation time using a timestamp.



[core](namespacecore.xhtml)

The namespace for all core functionalities under namespace simulation_framework.



[simulation\_framework](namespacesimulation__framework.xhtml)

The top namespace for simulation framework.



[time](namespacetime.xhtml)

The namespace for simulation time related implementation under namespace simulation_framework::core.