BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
3032550
Branches
Tags
master
Blinker
src
linux
Time.h
first version, plays videos to stdout
Stefan Schuermans
commited
3032550
at 2011-10-23 11:37:40
Time.h
Blame
History
Raw
/* Blinker Copyright 2011 Stefan Schuermans <stefan@blinkenarea.org> Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html a blinkenarea.org project */ #ifndef TIME_H #define TIME_H #include <stdint.h> #include <time.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 milliseconds * @param[in] ms milliseconds */ void fromMs(int ms); /** * @brief convert to seconds * @return seconds */ time_t toSec() const; public: /// sleep for duration void sleepFor() const; /// sleep until time void sleepUntil() const; protected: /// fix internal time representation after calculation void fix(); protected: int64_t m_sec; ///< seconds int64_t m_ns; ///< nanoseconds }; // class Time } // namespace Blinker #endif // #ifndef TIME_H