BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
c2990d7
Branches
Tags
master
Blinker
src
windows
Time.h
include order for Windows
Stefan Schuermans
commited
c2990d7
at 2017-10-28 20:24:17
Time.h
Blame
History
Raw
/* Blinker Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org> Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html a blinkenarea.org project */ #ifndef BLINKER_TIME_H #define BLINKER_TIME_H #include <winsock2.h> // not allowed after windows.h, so include here #include <windows.h> #include <stdint.h> namespace Blinker { /// time, either point in time or duration class Time { public: static const Time zero; ///< zero time public: /** * @brief get current time * @return current time */ static Time now(); public: /// constructor Time(); /** * @brief constructor from seconds * @param[in] t time in seconds */ Time(time_t t); public: /// comparison //@{ int compare(const Time &that) const; bool operator==(const Time &that) const; bool operator!=(const Time &that) const; bool operator<(const Time &that) const; bool operator>(const Time &that) const; bool operator<=(const Time &that) const; bool operator>=(const Time &that) const; //@} /// arithmetic //@{ const Time & operator+=(const Time &that); const Time & operator-=(const Time &that); Time operator+(const Time &that) const; Time operator-(const Time &that) const; //@} /** * @brief convert from floating point seconds * @param[in] s time in seconds */ void fromFloatSec(float s); /** * @brief convert from milliseconds * @param[in] ms milliseconds */ void fromMs(int ms); /** * @brief convert to seconds * @return seconds */ time_t toSec() const; /** * @brief convert to floating point seconds * @return time in seconds */ float toFloatSec() const; /** * @brief convert to struct timeval * @param[out] tv struct timeval */ void toTimeval(struct timeval &tv) const; /** * @brief convert from file time strcuture * @param[in] ft file time structure */ void fromFileTime(FILETIME const &ft); public: /// sleep for duration void sleepFor() const; /// sleep until time void sleepUntil() const; protected: /// fix internal time representation after calculation void fix(); protected: public: int64_t m_sec; ///< seconds int64_t m_ns; ///< nanoseconds }; // class Time } // namespace Blinker #endif // #ifndef BLINKER_TIME_H