doc: Document time header

selection
NaiJi ✨ 1 year ago
parent 3044b87dec
commit 5af1b94e22

@ -3,19 +3,41 @@
namespace kku
{
/// microsec
///
/// Primitive alias representing microseconds, which
/// is the main time measure in-game.
/// 1 second is 1000000 microseconds.
using microsec = long long;
/// TimeRange
///
/// Object representing a section of time.
/// To ensure order safety use
/// static produceValidated function.
struct TimeRange
{
const microsec begin = 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
: 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

Loading…
Cancel
Save