NanoTime Namespace Reference
Classes | |
| struct | Frequency |
| Class to represent a frequency. More... | |
| struct | TimeConst |
| Class template to represent a fixed time value for a specific Clock. More... | |
| struct | TicksConst |
| Class template representing a fixed clock tick count. More... | |
| struct | TimeSource |
| Class template for accessing a Clock in specific time units. More... | |
| struct | Time |
| Class to handle a simple time value with associated unit. More... | |
| struct | Ticks |
| Class to handle a tick value associated with a clock. More... | |
| struct | Clock |
| Class template representing a physical Clock with fixed timing characteristics. More... | |
| struct | TimeValue |
| A time time broken into its constituent elements. More... | |
Typedefs | |
| template<Unit unit> | |
| using | UnitTickRatio = std::ratio< unitTicks[unit].num, unitTicks[unit].den > |
| Class template to define tick std::ratio type. More... | |
Enumerations | |
| enum | Unit { Nanoseconds , Microseconds , Milliseconds , Seconds , Minutes , Hours , Days , UnitMax = Days } |
| Identify units for a scalar quantity of time. More... | |
Functions | |
| constexpr uint64_t | round_ce (double v) |
| const char * | unitToString (Unit unit) |
| Get a string identifying the given time units, e.g. "ns". More... | |
| const char * | unitToLongString (Unit unit) |
| Get a long string identifying the given time units, e.g. "seconds". More... | |
| template<uint64_t time, Unit unitsFrom, Unit unitsTo, typename R = std::ratio_divide<UnitTickRatio<unitsTo>, UnitTickRatio<unitsFrom>>> | |
| constexpr uint64_t | convert () |
| Function template to convert a constant time quantity from one unit to another. More... | |
| template<typename TimeType > | |
| TimeType | convert (const TimeType &time, Unit unitsFrom, Unit unitsTo) |
| Function template to convert a time quantity from one unit to another. More... | |
| template<typename T > | |
| Time< T > | time (Unit unit, T value) |
| Helper function to create a Time and deduce the type. More... | |
| template<Unit unitsFrom, Unit unitsTo, typename TimeType > | |
| TimeType | convert (const TimeType &time) |
| Function template to convert a time quantity from one unit to another. More... | |
Variables | |
| constexpr BasicRatio32 | unitTicks [UnitMax+1] |
| List of clock ticks for each supported unit of time. More... | |
Typedef Documentation
◆ UnitTickRatio
template<Unit unit>
| using NanoTime::UnitTickRatio = typedef std::ratio<unitTicks[unit].num, unitTicks[unit].den> |
Class template to define tick std::ratio type.
- Template Parameters
-
unit
- Return values
-
std::ratio Ticks per second
Enumeration Type Documentation
◆ Unit
| enum NanoTime::Unit |
Function Documentation
◆ convert() [1/3]
template<uint64_t time, Unit unitsFrom, Unit unitsTo, typename R = std::ratio_divide<UnitTickRatio<unitsTo>, UnitTickRatio<unitsFrom>>>
|
constexpr |
Function template to convert a constant time quantity from one unit to another.
- Template Parameters
-
time The time to convert unitsFrom Units for timeparameterunitsTo Units for return value
- Return values
-
TimeType Converted time
- Note
- example:
uint32_t micros = convert<50, Milliseconds, Microseconds>();
◆ convert() [2/3]
template<Unit unitsFrom, Unit unitsTo, typename TimeType >
| TimeType NanoTime::convert | ( | const TimeType & | time | ) |
Function template to convert a time quantity from one unit to another.
- Template Parameters
-
unitsFrom Units for timeparameterunitsTo Units for return value TimeType Variable type to use for calculation
- Parameters
-
time The time to convert
- Return values
-
TimeType Converted time, returns TimeType(-1) if calculation overflowed
◆ convert() [3/3]
template<typename TimeType >
| TimeType NanoTime::convert | ( | const TimeType & | time, |
| Unit | unitsFrom, | ||
| Unit | unitsTo | ||
| ) |
Function template to convert a time quantity from one unit to another.
- Template Parameters
-
TimeType Variable type to use for calculation
- Parameters
-
time The time to convert unitsFrom Units for timeparameterunitsTo Units for return value
- Return values
-
TimeType Converted time, returns TimeType(-1) if calculation overflowed
◆ round_ce()
|
constexpr |
◆ time()
Helper function to create a Time and deduce the type.
◆ unitToLongString()
| const char* NanoTime::unitToLongString | ( | Unit | unit | ) |
Get a long string identifying the given time units, e.g. "seconds".
◆ unitToString()
| const char* NanoTime::unitToString | ( | Unit | unit | ) |
Get a string identifying the given time units, e.g. "ns".
Variable Documentation
◆ unitTicks
|
constexpr |
Initial value:
= {
{1000000000, 1},
{1000000, 1},
{1000, 1},
{1, 1},
{1, 60},
{1, 60 * 60},
{1, 24 * 60 * 60},
}
List of clock ticks for each supported unit of time.
1.9.1