ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHTimeStamp.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHTimeStamp.h
1 // The PHOOL's Software
2 // Copyright (C) PHENIX collaboration, 1999
3 //
4 // Purpose: PHENIX - wide time stamp class
5 //
6 // Declaration of class PHTimeStamp
7 //
8 // Author: Matthias Messer
9 //-----------------------------------------------------------------------------
10 #ifndef PHOOL_PHTIMESTAMP_H
11 #define PHOOL_PHTIMESTAMP_H
12 
13 #include "PHObject.h"
14 
15 #include <ctime>
16 #include <iosfwd>
17 
18 typedef unsigned long long phtime_t;
19 
20 class PHTimeStamp : public PHObject
21 {
22  public:
23  static const unsigned long long PHFarFuture; // set to ULLONG_MAX
24 
25  PHTimeStamp();
26 
27  PHTimeStamp(const int, const int, const int, const int, const int, const int, const int = 0);
28  PHTimeStamp(const time_t);
29  void setBinTics(const phtime_t t);
30 
31  ~PHTimeStamp() override {}
32 
33  public:
34  void set(const int, const int, const int, const int, const int, const int, const int = 0);
35 
36  void set(const char *);
37 
38  void setToSystemTime();
40  phtime_t getBinaryTime() const { return binaryTime; }
41  time_t getTics() const;
42  void setTics(const time_t);
43 
44  int isInRange(const PHTimeStamp &, const PHTimeStamp &);
45  void print();
46 
47  int operator==(const PHTimeStamp &) const;
48  int operator!=(const PHTimeStamp &) const;
49  int operator>(const PHTimeStamp &) const;
50  int operator>=(const PHTimeStamp &) const;
51  int operator<(const PHTimeStamp &) const;
52  int operator<=(const PHTimeStamp &) const;
53 
54  PHTimeStamp operator+=(time_t);
55  PHTimeStamp operator-=(time_t);
56 
57  char *formatTimeString() const;
58  void print() const;
59 
60  private:
61  phtime_t ticsToBinaryTime(time_t) const;
62  time_t binaryTimeToTics(phtime_t) const;
63 
64  protected:
66  ClassDefOverride(PHTimeStamp, 1)
67 };
68 
69 PHTimeStamp operator+(const PHTimeStamp &, time_t);
70 PHTimeStamp operator-(const PHTimeStamp &, time_t);
71 time_t operator-(const PHTimeStamp &, const PHTimeStamp &);
72 
73 std::ostream &operator<<(std::ostream &, const PHTimeStamp &);
74 std::istream &operator>>(std::istream &, PHTimeStamp &);
75 
76 #endif /* PHOOL_PHTIMESTAMP_H */