doc: Document time header

This commit is contained in:
NaiJi ✨ 2022-12-14 14:37:49 +04:00
parent 3044b87dec
commit 5af1b94e22
1 changed files with 23 additions and 1 deletions

View File

@ -3,19 +3,41 @@
namespace kku namespace kku
{ {
/// microsec
///
/// Primitive alias representing microseconds, which
/// is the main time measure in-game.
/// 1 second is 1000000 microseconds.
using microsec = long long; using microsec = long long;
/// TimeRange
///
/// Object representing a section of time.
/// To ensure order safety use
/// static produceValidated function.
struct TimeRange struct TimeRange
{ {
const microsec begin = 0; const microsec begin = 0;
const microsec end = 0; const microsec end = 0;
constexpr inline explicit TimeRange() noexcept : begin(0), end(0) {} constexpr inline explicit TimeRange() noexcept : begin(0), end(0)
{
}
constexpr inline explicit TimeRange(microsec x, microsec y) noexcept constexpr inline explicit TimeRange(microsec x, microsec y) noexcept
: begin(x), end(y) : begin(x), end(y)
{ {
} }
/// produceValidated
///
/// Creates an object of TimeRange, but
/// also makes sure to place begin and end
/// in the right order to avoid confusion.
static inline TimeRange produceValidated(microsec x, microsec y) noexcept
{
return (x < y) ? TimeRange(x, y) : TimeRange(y, x);
}
}; };
} // namespace kku } // namespace kku