#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_GAME_TIMING_CLOCK_H #define NUCLEX_GAME_TIMING_CLOCK_H #include "Nuclex/Game/Config.h" #include #include namespace Nuclex { namespace Game { namespace Timing { // ------------------------------------------------------------------------------------------- // /// Provides accurate timings at system-defined resolutions /// /// /// Clocks must be steady, meaning that they never jump backwards due to daylight saving /// time, NTP synchronization or inaccuracies. If a time source is prone to jumping /// backwards, you should ensure its integrity by cross-checking it with another time /// source and bridging any values that seem implausible with the alternate time source. /// /// /// Thread-safety: per instance. Each instance of this class may only /// be accessed by a single thread. If different threads need to access the same instance, /// these accesses need to be synchronized using a mutex. /// /// class Clock { /// Destroys the clock public: virtual ~Clock() {} /// Creates the best clock available on the current system /// A new instance of the best clock type available on the system public: NUCLEX_GAME_API static std::shared_ptr Create(); /// /// Retrieves the maximum value the time can assume before wrapping around to 0 again /// /// The highest possible value GetTime() can return public: NUCLEX_GAME_API virtual std::uint64_t GetWraparoundTime() const = 0; /// Retrieves the clock's current time /// The number of ticks the clock has ticked to far /// /// There's no rule for what a clock's time should be relative to, only that it /// keeps counting at a fixed pace. The clock could begin ticking when the system /// boots, when the application starts or when the class is instantiated. /// public: NUCLEX_GAME_API virtual std::uint64_t GetTime() const = 0; /// Retrieves the clock's tick frequency /// How often the clock will tick in one second public: NUCLEX_GAME_API virtual std::uint64_t GetFrequency() const = 0; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Game::Timing #endif // NUCLEX_GAME_TIMING_CLOCK_H