Line data Source code
1 : #include "TimePoint_T.h" 2 : 3 : #include "Time_Helper.h" 4 : 5 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 6 : 7 : namespace OpenDDS { 8 : namespace DCPS { 9 : 10 : template<typename AceClock> 11 : ACE_INLINE 12 211 : TimePoint_T<AceClock>::TimePoint_T() 13 211 : : value_(zero_value.value()) 14 : { 15 211 : } 16 : 17 : template<typename AceClock> 18 : ACE_INLINE 19 864 : TimePoint_T<AceClock>::TimePoint_T(const ACE_Time_Value& ace_time_value) 20 864 : : value_(ace_time_value) 21 : { 22 864 : } 23 : 24 : template<typename AceClock> 25 : ACE_INLINE 26 998 : TimePoint_T<AceClock>::TimePoint_T(const ACE_Time_Value_T<AceClock>& ace_time_value) 27 998 : : value_(ace_time_value) 28 : { 29 998 : } 30 : 31 : template<typename AceClock> 32 : ACE_INLINE 33 0 : TimePoint_T<AceClock>::TimePoint_T(const DDS::Time_t& dds_time) 34 0 : : value_(time_to_time_value(dds_time)) 35 : { 36 0 : } 37 : 38 : template<typename AceClock> 39 : ACE_INLINE 40 : TimePoint_T<AceClock> 41 998 : TimePoint_T<AceClock>::now() 42 : { 43 998 : return TimePoint_T<AceClock>(clock()); 44 : } 45 : 46 : template<typename AceClock> 47 : ACE_INLINE 48 : const ACE_Time_Value_T<AceClock>& 49 3855 : TimePoint_T<AceClock>::value() const 50 : { 51 3855 : return value_; 52 : } 53 : 54 : template<typename AceClock> 55 : ACE_INLINE 56 : void 57 : TimePoint_T<AceClock>::value(const ACE_Time_Value_T<AceClock>& ace_time_value) 58 : { 59 : value_ = ace_time_value; 60 : } 61 : 62 : template<typename AceClock> 63 : ACE_INLINE 64 : bool 65 131 : TimePoint_T<AceClock>::is_zero() const 66 : { 67 131 : return *this == zero_value; 68 : } 69 : 70 : template<typename AceClock> 71 : ACE_INLINE 72 : bool 73 0 : TimePoint_T<AceClock>::is_max() const 74 : { 75 0 : return *this == max_value; 76 : } 77 : 78 : template<typename AceClock> 79 : ACE_INLINE 80 : void 81 0 : TimePoint_T<AceClock>::set_to_now() 82 : { 83 0 : value_ = clock(); 84 0 : } 85 : 86 : template<typename AceClock> 87 : ACE_INLINE 88 : DDS::Time_t 89 12 : TimePoint_T<AceClock>::to_dds_time() const 90 : { 91 12 : return time_value_to_time(value_); 92 : } 93 : 94 : template<typename AceClock> 95 : ACE_INLINE 96 : MonotonicTime_t 97 0 : TimePoint_T<AceClock>::to_monotonic_time() const 98 : { 99 0 : return time_value_to_monotonic_time(value_); 100 : } 101 : 102 : template<typename AceClock> 103 : ACE_INLINE 104 : TimePoint_T<AceClock>& 105 0 : TimePoint_T<AceClock>::operator+=(const TimeDuration& td) 106 : { 107 0 : value_ += td.value(); 108 0 : return *this; 109 : } 110 : 111 : template<typename AceClock> 112 : ACE_INLINE 113 : TimePoint_T<AceClock>& 114 : TimePoint_T<AceClock>::operator-=(const TimeDuration& td) 115 : { 116 : value_ -= td.value(); 117 : return *this; 118 : } 119 : 120 : template<typename AceClock> 121 : ACE_INLINE 122 : TimePoint_T<AceClock> 123 : operator+(const TimeDuration& x, const TimePoint_T<AceClock>& y) 124 : { 125 : return TimePoint_T<AceClock>(x.value() + y.value()); 126 : } 127 : 128 : template<typename AceClock> 129 : ACE_INLINE 130 : TimePoint_T<AceClock> 131 856 : operator+(const TimePoint_T<AceClock>& x, const TimeDuration& y) 132 : { 133 856 : return TimePoint_T<AceClock>(x.value() + y.value()); 134 : } 135 : 136 : template<typename AceClock> 137 : ACE_INLINE 138 : TimeDuration 139 0 : operator-(const TimePoint_T<AceClock>& x, const TimePoint_T<AceClock>& y) 140 : { 141 0 : return TimeDuration(x.value() - y.value()); 142 : } 143 : 144 : template<typename AceClock> 145 : ACE_INLINE 146 : TimePoint_T<AceClock> 147 0 : operator-(const TimePoint_T<AceClock>& x, const TimeDuration& y) 148 : { 149 0 : return TimePoint_T<AceClock>(x.value() - y.value()); 150 : } 151 : 152 : template<typename AceClock> 153 : ACE_INLINE 154 : bool 155 600 : operator<(const TimePoint_T<AceClock>& x, const TimePoint_T<AceClock>& y) 156 : { 157 600 : return x.value() < y.value(); 158 : } 159 : 160 : template<typename AceClock> 161 : ACE_INLINE 162 : bool 163 0 : operator>(const TimePoint_T<AceClock>& x, const TimePoint_T<AceClock>& y) 164 : { 165 0 : return x.value() > y.value(); 166 : } 167 : 168 : template<typename AceClock> 169 : ACE_INLINE 170 : bool 171 565 : operator<=(const TimePoint_T<AceClock>& x, const TimePoint_T<AceClock>& y) 172 : { 173 565 : return x.value() <= y.value(); 174 : } 175 : 176 : template<typename AceClock> 177 : ACE_INLINE 178 : bool 179 28 : operator>=(const TimePoint_T<AceClock>& x, const TimePoint_T<AceClock>& y) 180 : { 181 28 : return x.value() >= y.value(); 182 : } 183 : 184 : template<typename AceClock> 185 : ACE_INLINE 186 : bool 187 133 : operator==(const TimePoint_T<AceClock>& x, const TimePoint_T<AceClock>& y) 188 : { 189 133 : return x.value() == y.value(); 190 : } 191 : 192 : template<typename AceClock> 193 : ACE_INLINE 194 : bool 195 1 : operator!=(const TimePoint_T<AceClock>& x, const TimePoint_T<AceClock>& y) 196 : { 197 1 : return x.value() != y.value(); 198 : } 199 : 200 : } 201 : } 202 : 203 : OPENDDS_END_VERSIONED_NAMESPACE_DECL