![]()  | 
  
    Gamedev Framework (gf)
    0.3.0
    
   A C++11 framework for 2D games 
   | 
 
Represents a time value. More...
#include <gf/Time.h>
Public Member Functions | |
| Time () | |
| Default constructor.  More... | |
| Time (std::chrono::steady_clock::duration duration) | |
| Constructor with a duration.  More... | |
| float | asSeconds () const | 
| Return the time value as a number of seconds.  More... | |
| int32_t | asMilliseconds () const | 
| Return the time value as a number of milliseconds.  More... | |
| int64_t | asMicroseconds () const | 
| Return the time value as a number of microseconds.  More... | |
| std::chrono::steady_clock::duration | asDuration () const | 
| Return the time value as a duration.  More... | |
Related Functions | |
(Note that these are not member functions.)  | |
| Time | seconds (float amount) | 
| Construct a time value from a number of seconds.  More... | |
| Time | milliseconds (int32_t amount) | 
| Construct a time value from a number of milliseconds.  More... | |
| Time | microseconds (int64_t amount) | 
| Construct a time value from a number of microseconds.  More... | |
| bool | operator== (const Time &rhs, const Time &lhs) | 
| Equality operator.  More... | |
| bool | operator!= (const Time &rhs, const Time &lhs) | 
| Inequality operator.  More... | |
| bool | operator< (const Time &rhs, const Time &lhs) | 
| Lesser than operator.  More... | |
| bool | operator> (const Time &rhs, const Time &lhs) | 
| Greater than operator.  More... | |
| bool | operator<= (const Time &rhs, const Time &lhs) | 
| Lesser or equal operator.  More... | |
| bool | operator>= (const Time &rhs, const Time &lhs) | 
| Greater or equal than operator.  More... | |
Represents a time value.
gf::Time encapsulates a time value in a flexible way. It allows to define a time value either as a number of seconds, milliseconds or microseconds. It also works the other way round: you can read a time value as either a number of seconds, milliseconds or microseconds.
By using such a flexible interface, the API doesn't impose any fixed type or resolution for time values, and let the user choose its own favorite representation.
Since they represent a time span and not an absolute time value, times can also be negative.
gf::Time is a thin wrapper around C++11 std::chrono::steady_clock.
Usage example:
| gf::Time::Time | ( | ) | 
Default constructor.
Sets the time value to zero.
      
  | 
  explicit | 
Constructor with a duration.
| duration | A duration expressed with a std::chrono type  | 
      
  | 
  inline | 
Return the time value as a duration.
std::chrono type) | int64_t gf::Time::asMicroseconds | ( | ) | const | 
Return the time value as a number of microseconds.
| int32_t gf::Time::asMilliseconds | ( | ) | const | 
Return the time value as a number of milliseconds.
| float gf::Time::asSeconds | ( | ) | const | 
Return the time value as a number of seconds.
      
  | 
  related | 
Construct a time value from a number of microseconds.
| amount | Number of microseconds | 
      
  | 
  related | 
Construct a time value from a number of milliseconds.
| amount | Number of milliseconds | 
Inequality operator.
| rhs | First time | 
| lhs | Second time | 
Lesser than operator.
| rhs | First time | 
| lhs | Second time | 
Lesser or equal operator.
| rhs | First time | 
| lhs | Second time | 
Equality operator.
| rhs | First time | 
| lhs | Second time | 
Greater than operator.
| rhs | First time | 
| lhs | Second time | 
Greater or equal than operator.
| rhs | First time | 
| lhs | Second time | 
      
  | 
  related | 
Construct a time value from a number of seconds.
| amount | Number of seconds | 
 1.8.8