| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef __PCLOCKNS_H__ | ||
| 8 | #define __PCLOCKNS_H__ | ||
| 9 | |||
| 10 | #include "ellapsedTime.h" | ||
| 11 | #include <time.h> | ||
| 12 | #include <chrono> | ||
| 13 | #include <ctime> | ||
| 14 | #include <string> | ||
| 15 | #include <thread> | ||
| 16 | |||
| 17 | ///@brief Nanosecond clock | ||
| 18 | class PClockNs{ | ||
| 19 | public: | ||
| 20 | typedef std::chrono::steady_clock SteadyClock; | ||
| 21 | typedef std::chrono::nanoseconds Nanosecond; | ||
| 22 | typedef std::chrono::time_point<SteadyClock> TimeNs; | ||
| 23 | |||
| 24 | PClockNs(); | ||
| 25 | virtual ~PClockNs(); | ||
| 26 | |||
| 27 | void setOffsetTimeNs(std::time_t offsetTimeNs); | ||
| 28 | std::time_t getOffsetTimeNs() const; | ||
| 29 | |||
| 30 | std::time_t getFullTimeNs() const; | ||
| 31 | std::string getDateNs() const; | ||
| 32 | std::string getDateCompactNs() const; | ||
| 33 | std::time_t now() const; | ||
| 34 | void sleep(EllapsedTime ellapsedTime) const; | ||
| 35 | private: | ||
| 36 | void initialisationPClockNs(); | ||
| 37 | |||
| 38 | ///Base of the system clock in second | ||
| 39 | std::time_t p_baseSystemClockSecond; | ||
| 40 | ///Base clock time with a nanosecond precision but since the starting of the CPU | ||
| 41 | TimeNs p_baseSteadyClockNs; | ||
| 42 | ///Offset of time with date and nanoseconds | ||
| 43 | std::time_t p_offsetTimeNs; | ||
| 44 | }; | ||
| 45 | |||
| 46 | std::string phoenix_dateNs(std::time_t currentDateNs, const char* format); | ||
| 47 | std::string phoenix_dateNs(std::time_t currentDateNs); | ||
| 48 | std::string phoenix_dateCompactNs(std::time_t currentDateNs); | ||
| 49 | |||
| 50 | #endif | ||
| 51 | |||
| 52 |