OpenDDS  Snapshot(2023/04/28-20:55)
TimeDuration.inl
Go to the documentation of this file.
1 #include "TimeDuration.h"
2 
3 #include "Time_Helper.h"
4 
6 
7 namespace OpenDDS {
8 namespace DCPS {
9 
11 TimeDuration
13 {
15  rv.set_msec(ms);
16  return TimeDuration(rv);
17 }
18 
21 TimeDuration::from_double(double duration)
22 {
24  rv.set(duration);
25  return TimeDuration(rv);
26 }
27 
31 {
32 }
33 
36 : value_(other.value_)
37 {
38 }
39 
42 : value_(ace_time_value)
43 {
44 }
45 
47 TimeDuration::TimeDuration(time_t sec, suseconds_t usec)
48 : value_(sec, usec)
49 {
50 }
51 
54 : value_(duration_to_time_value(dds_duration))
55 {
56 }
57 
59 const ACE_Time_Value&
61 {
62  return value_;
63 }
64 
66 void
67 TimeDuration::value(const ACE_Time_Value& ace_time_value)
68 {
69  value_ = ace_time_value;
70 }
71 
73 bool
75 {
76  return *this == zero_value;
77 }
78 
80 bool
82 {
83  return *this == max_value;
84 }
85 
89 {
90  return time_value_to_duration(value());
91 }
92 
96 {
97  value_ += other.value();
98  return *this;
99 }
100 
104 {
105  value_ -= other.value();
106  return *this;
107 }
108 
112 {
113  value_ *= other;
114  return *this;
115 }
116 
119 {
120  value_ *= (1.0 / other);
121  return *this;
122 }
123 
127 {
128  value_ = other.value();
129  return *this;
130 }
131 
134 TimeDuration::operator=(const time_t& other)
135 {
136  value_ = other;
137  return *this;
138 }
139 
143 {
144  return TimeDuration(x.value() + y.value());
145 }
146 
150 {
151  return TimeDuration(x.value() - y.value());
152 }
153 
157 {
158  return TimeDuration::zero_value - x;
159 }
160 
163 operator*(double x, const TimeDuration& y)
164 {
165  return TimeDuration(x * y.value());
166 }
167 
170 operator*(const TimeDuration& x, double y)
171 {
172  return TimeDuration(x.value() * y);
173 }
174 
177 {
178  return TimeDuration(x.value() * (1.0 / y));
179 }
180 
182 double operator/(const TimeDuration& x, const TimeDuration& y)
183 {
184  return (double(x.value().sec()) * 1000000 + x.value().usec()) /
185  (double(y.value().sec()) * 1000000 + y.value().usec());
186 }
187 
189 bool
191 {
192  return x.value() < y.value();
193 }
194 
196 bool
198 {
199  return x.value() > y.value();
200 }
201 
203 bool
205 {
206  return x.value() <= y.value();
207 }
208 
210 bool
212 {
213  return x.value() >= y.value();
214 }
215 
217 bool
219 {
220  return x.value() == y.value();
221 }
222 
224 bool
226 {
227  return x.value() != y.value();
228 }
229 
230 }
231 }
232 
TimeDuration & operator+=(const TimeDuration &other)
OpenDDS_Dcps_Export TimeDuration operator/(const TimeDuration &x, double y)
ACE_INLINE OpenDDS_Dcps_Export DDS::Duration_t operator-(const DDS::Time_t &t1, const DDS::Time_t &t2)
ACE_INLINE OpenDDS_Dcps_Export bool operator>(const DDS::Duration_t &t1, const DDS::Duration_t &t2)
Definition: Time_Helper.inl:65
const ACE_Time_Value & value() const
bool operator==(const DisjointSequence::OrderedRanges< T > &a, const DisjointSequence::OrderedRanges< T > &b)
TimeDuration & operator*=(double other)
ACE_INLINE OpenDDS_Dcps_Export bool operator<=(const DDS::Duration_t &t1, const DDS::Duration_t &t2)
Definition: Time_Helper.inl:55
static TimeDuration from_msec(const ACE_UINT64 &ms)
TimeDuration & operator-=(const TimeDuration &other)
DDS::Duration_t to_dds_duration() const
ACE_INLINE OpenDDS_Dcps_Export DDS::Duration_t time_value_to_duration(const ACE_Time_Value &tv)
bool operator>=(const LogLevel &ll, LogLevel::Value value)
Definition: debug.h:61
time_t sec(void) const
SequenceNumber operator+(const SequenceNumber &lhs, int rhs)
TimeDuration & operator=(const TimeDuration &other)
ACE_INLINE OpenDDS_Dcps_Export ACE_Time_Value duration_to_time_value(const DDS::Duration_t &t)
static const TimeDuration zero_value
Definition: TimeDuration.h:31
bool operator!=(const GUID_t &lhs, const GUID_t &rhs)
Definition: GuidUtils.h:125
unsigned long long ACE_UINT64
suseconds_t usec(void) const
void set_msec(const ACE_UINT64 &ms)
void set(time_t sec, suseconds_t usec)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
OpenDDS_Dcps_Export TimeDuration operator*(double x, const TimeDuration &y)
static TimeDuration from_double(double duration)
#define ACE_INLINE
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
bool operator<(const GUID_t &lhs, const GUID_t &rhs)
Definition: GuidUtils.h:80
TimeDuration & operator/=(double other)
static const TimeDuration max_value
Definition: TimeDuration.h:32