BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
delta_time.hpp
1#ifndef BLUETOE_LINK_LAYER_DELTA_TIME_HPP
2#define BLUETOE_LINK_LAYER_DELTA_TIME_HPP
3
4#include <cstdint>
5#include <iosfwd>
6
7namespace bluetoe {
8namespace link_layer {
9
14 {
15 public:
16 constexpr delta_time() : usec_( 0 )
17 {
18 }
19
23 constexpr explicit delta_time( std::uint32_t usec ) : usec_( usec )
24 {
25 }
26
30 static delta_time usec( std::uint32_t usec );
31
35 static delta_time msec( std::uint32_t msec );
36
40 static delta_time seconds( int s );
41
45 static delta_time now();
46
50 void print( std::ostream& ) const;
51
56
62
66 delta_time& operator*=( unsigned rhs );
67
72 unsigned operator/(const delta_time& rhs );
73
77 bool operator<( const delta_time& rhs ) const;
78
82 bool operator<=( const delta_time& rhs ) const;
83
87 bool operator>( const delta_time& rhs ) const;
88
92 bool operator>=( const delta_time& rhs ) const;
93
97 bool operator==( const delta_time& rhs ) const;
98
102 bool operator!=( const delta_time& rhs ) const;
103
109 std::uint32_t usec() const;
110
116 bool zero() const;
117
125 delta_time ppm( unsigned part ) const;
126 private:
127 std::uint32_t usec_;
128 };
129
134 std::ostream& operator<<( std::ostream&, const delta_time& );
135
141
147
152 delta_time operator*( delta_time lhs, unsigned rhs );
153
157 delta_time operator*( unsigned lhs, delta_time rhs );
158
159}
160}
161#endif