Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Clock.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Core module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_CLOCK_HPP
8 #define NAZARA_CLOCK_HPP
9 
10 #include <Nazara/Prerequesites.hpp>
11 
12 #if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_CLOCK
13 #include <Nazara/Core/ThreadSafety.hpp>
14 #else
15 #include <Nazara/Core/ThreadSafetyOff.hpp>
16 #endif
17 
18 namespace Nz
19 {
20  class NAZARA_CORE_API Clock
21  {
22  public:
23  Clock(UInt64 startingValue = 0, bool paused = false);
24  Clock(const Clock& clock) = default;
25  Clock(Clock&& clock) = default;
26  ~Clock() = default;
27 
28  float GetSeconds() const;
29  UInt64 GetMicroseconds() const;
30  UInt64 GetMilliseconds() const;
31 
32  bool IsPaused() const;
33 
34  void Pause();
35  void Restart();
36  void Unpause();
37 
38  Clock& operator=(const Clock& clock) = default;
39  Clock& operator=(Clock&& clock) = default;
40 
41  private:
42  NazaraMutexAttrib(m_mutex, mutable)
43 
44  UInt64 m_elapsedTime;
45  UInt64 m_refTime;
46  bool m_paused;
47  };
48 
49  typedef UInt64 (*ClockFunction)();
50 
51  extern NAZARA_CORE_API ClockFunction GetElapsedMicroseconds;
52  extern NAZARA_CORE_API ClockFunction GetElapsedMilliseconds;
53 }
54 
55 #endif // NAZARA_CLOCK_HPP
Utility class that measure the elapsed time.
Definition: Clock.hpp:20
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12