sequencer
beat_time_point.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace sequencer
6 {
7 
9  {
10  public:
11  constexpr beat_time_point() = default;
12 
14  : time_since_epoch_( time_since_epoch )
15  {
16  }
17 
18  constexpr beat_duration time_since_epoch() const noexcept
19  {
20  return time_since_epoch_;
21  }
22 
23  constexpr beat_time_point& operator+=( beat_duration other ) noexcept
24  {
25  time_since_epoch_ += other;
26  return *this;
27  }
28 
29  private:
30  beat_duration time_since_epoch_ = 0.0_beats;
31  };
32 
33  constexpr beat_time_point operator+( beat_time_point lhs, beat_duration rhs ) noexcept
34  {
35  return lhs += rhs;
36  }
37 
38  constexpr bool operator<( beat_time_point lhs, beat_time_point rhs ) noexcept
39  {
40  return lhs.time_since_epoch() < rhs.time_since_epoch();
41  }
42 
43  constexpr bool operator<=( beat_time_point lhs, beat_time_point rhs ) noexcept
44  {
45  return lhs.time_since_epoch() <= rhs.time_since_epoch();
46  }
47 
48  inline std::ostream& operator<<( std::ostream& os, beat_time_point time_point )
49  {
50  return os << time_point.time_since_epoch() << " since epoch";
51  }
52 
53 } // namespace sequencer
constexpr beat_duration time_since_epoch() const noexcept
Definition: beat_time_point.hpp:18
Definition: beat_duration.hpp:13
constexpr beat_duration operator+(beat_duration lhs, beat_duration rhs) noexcept
Definition: beat_duration.hpp:60
constexpr beat_time_point & operator+=(beat_duration other) noexcept
Definition: beat_time_point.hpp:23
constexpr bool operator<=(beat_time_point lhs, beat_time_point rhs) noexcept
Definition: beat_time_point.hpp:43
Definition: beat_time_point.hpp:8
constexpr bool operator<(beat_time_point lhs, beat_time_point rhs) noexcept
Definition: beat_time_point.hpp:38
constexpr beat_time_point()=default
std::ostream & operator<<(std::ostream &os, beat_duration beats)
Definition: beat_duration.hpp:86
constexpr beat_time_point(beat_duration time_since_epoch)
Definition: beat_time_point.hpp:13