PhoenixClockMock  2.0.0
Tool to manipulate mock of clock (split, merge and get info)
PClockNs.h
Go to the documentation of this file.
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 <time.h>
11 #include <chrono>
12 #include <ctime>
13 #include <string>
14 
16 class PClockNs{
17  public:
18  typedef std::chrono::steady_clock SteadyClock;
19  typedef std::chrono::nanoseconds Nanosecond;
20  typedef std::chrono::time_point<SteadyClock> TimeNs;
21 
22  PClockNs();
23  PClockNs(const PClockNs & other);
24  virtual ~PClockNs();
25  PClockNs & operator = (const PClockNs & other);
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 
34 
35  protected:
36  void copyPClockNs(const PClockNs & other);
37 
38  private:
40 
46  std::time_t p_offsetTimeNs;
47 };
48 
49 std::string phoenix_dateNs(std::time_t currentDateNs, const char* format);
50 std::string phoenix_dateNs(std::time_t currentDateNs);
51 std::string phoenix_dateCompactNs(std::time_t currentDateNs);
52 
53 #endif
54 
std::string phoenix_dateNs(std::time_t currentDateNs, const char *format)
Convert a given date in nanosecond into a text date.
Definition: PClockNs.cpp:15
std::string phoenix_dateCompactNs(std::time_t currentDateNs)
Convert a given date in nanosecond into a text date in a more compact way.
Definition: PClockNs.cpp:38
Nanosecond clock.
Definition: PClockNs.h:16
std::string getDateCompactNs() const
Get the date at nanosecond precision (even if it is not precise at the nanosecond scale,...
Definition: PClockNs.cpp:103
void initialisationPClockNs()
Initialisation function of the class PClockNs.
Definition: PClockNs.cpp:117
PClockNs & operator=(const PClockNs &other)
Definition of equal operator of PClockNs.
Definition: PClockNs.cpp:63
std::time_t getOffsetTimeNs() const
Get the offset in nanoseconds of the current clock.
Definition: PClockNs.cpp:78
std::time_t getFullTimeNs() const
Get the full time in nanoseconds.
Definition: PClockNs.cpp:85
virtual ~PClockNs()
Destructor of PClockNs.
Definition: PClockNs.cpp:55
void setOffsetTimeNs(std::time_t offsetTimeNs)
Set the offset in nanoseconds of the current clock.
Definition: PClockNs.cpp:71
std::string getDateNs() const
Get the date at nanosecond precision (even if it is not precise at the nanosecond scale,...
Definition: PClockNs.cpp:96
PClockNs()
Default constructor of PClockNs.
Definition: PClockNs.cpp:43
std::chrono::nanoseconds Nanosecond
Definition: PClockNs.h:19
std::chrono::steady_clock SteadyClock
Definition: PClockNs.h:18
std::chrono::time_point< SteadyClock > TimeNs
Definition: PClockNs.h:20
std::time_t p_baseSystemClockSecond
Base of the system clock in second.
Definition: PClockNs.h:42
void copyPClockNs(const PClockNs &other)
Copy function of PClockNs.
Definition: PClockNs.cpp:110
std::time_t p_offsetTimeNs
Offset of time with date and nanoseconds.
Definition: PClockNs.h:46
TimeNs p_baseSteadyClockNs
Base clock time with a nanosecond precision but since the starting of the CPU.
Definition: PClockNs.h:44