diff options
author | Aki <please@ignore.pl> | 2022-04-05 23:18:53 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-04-05 23:18:53 +0200 |
commit | 3b004ab63c16f2eb783e29a35131450ba28383a3 (patch) | |
tree | 95333d21cbbf06245404ff1fc1ad6ea2f8a8e10a /StarsEx/Clock.inl | |
parent | b61b59ae1b7cd4041ef0a815b7e96537418298c9 (diff) | |
download | starshatter-3b004ab63c16f2eb783e29a35131450ba28383a3.zip starshatter-3b004ab63c16f2eb783e29a35131450ba28383a3.tar.gz starshatter-3b004ab63c16f2eb783e29a35131450ba28383a3.tar.bz2 |
Elapsed time clock methods are now templates
Diffstat (limited to 'StarsEx/Clock.inl')
-rw-r--r-- | StarsEx/Clock.inl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/StarsEx/Clock.inl b/StarsEx/Clock.inl new file mode 100644 index 0000000..42a2693 --- /dev/null +++ b/StarsEx/Clock.inl @@ -0,0 +1,28 @@ +/* Starshatter: The Open Source Project + Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors + Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors + Copyright (c) 1997-2006, Destroyer Studios LLC. +*/ + +#include "Clock.h" + +#include <chrono> +#include <ratio> + + +template <typename R> +R +Clock::GameTime() const +{ + using target_duration = std::chrono::duration<R, std::milli>; + return std::chrono::duration_cast<target_duration>(m_game_elapsed).count(); +} + + +template <typename R> +R +Clock::RealTime() const +{ + using target_duration = std::chrono::duration<R, std::milli>; + return std::chrono::duration_cast<target_duration>(m_real_elapsed).count(); +} |