Debian Codegraph @

src/timestamp.h

raw symbols SCIP
1 #ifndef _TIMESTAMP_H_
2 #define _TIMESTAMP_H_
3
4 #include <memory>
5
6 // Impl abstract class; implemented by platform-specific classes
7 class TimestampImpl {
8 public:
9 virtual ~TimestampImpl() {}
10 virtual bool future() const = 0;
11 virtual bool less(const TimestampImpl* other) const = 0;
12 virtual bool greater(const TimestampImpl* other) const = 0;
13 virtual double diff_secs(const TimestampImpl* other) const = 0;
14 };
15
16 class Timestamp {
17 private:
18 std::shared_ptr<const TimestampImpl> p_impl;
19
20 public:
21 Timestamp();
22 Timestamp(double secs);
23
24 // Is this timestamp in the future?
25 bool future() const {
26 return p_impl->future();
27 }
28
29 // Comparison operators
30 bool operator<(const Timestamp& other) const {
31 return p_impl->less(other.p_impl.get());
32 }
33 bool operator>(const Timestamp& other) const {
34 return p_impl->greater(other.p_impl.get());
35 }
36
37 // Diff
38 double diff_secs(const Timestamp& other) const {
39 return p_impl->diff_secs(other.p_impl.get());
40 }
41 };
42
43 #endif // _TIMESTAMP_H_