Cyclone ISO C++ API Reference Guide
Duration.hpp
Go to the documentation of this file.
1 #ifndef OMG_DDS_CORE_DURATION_HPP_
2 #define OMG_DDS_CORE_DURATION_HPP_
3 
4 /* Copyright 2010, Object Management Group, Inc.
5  * Copyright 2010, PrismTech, Corp.
6  * Copyright 2010, Real-Time Innovations, Inc.
7  * All rights reserved.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #include <dds/core/types.hpp>
23 
24 namespace dds
25 {
26 namespace core
27 {
28 
43 {
44 public:
48  static const Duration zero(); // {0, 0}
49 
53  static const Duration infinite(); // {0x7fffffff, 0x7fffffff}
54 
55 public:
59  Duration();
60 
67  explicit Duration(int32_t sec, uint32_t nanosec = 0);
68 #if __cplusplus >= 199711L
69 
70  explicit Duration(int64_t sec, uint32_t nanosec = 0);
71 #endif
72 
74  ~Duration();
77 public:
82  static const Duration from_microsecs(int64_t microseconds);
83 
88  static const Duration from_millisecs(int64_t milliseconds);
89 
94  static const Duration from_secs(double seconds);
95 
96 public:
101  int64_t sec() const;
106  void sec(int64_t s);
107 
112  uint32_t nanosec() const;
117  void nanosec(uint32_t ns);
118 
119 public:
130  int compare(const Duration& that) const;
131 
138  bool operator >(const Duration& that) const;
139 
144  bool operator >=(const Duration& that) const;
145 
152  bool operator !=(const Duration& that) const;
153 
160  bool operator ==(const Duration& that) const;
161 
168  bool operator <=(const Duration& that) const;
169 
176  bool operator <(const Duration& that) const;
177 
178 public:
185  Duration& operator+=(const Duration& a_ti);
186 
193  Duration& operator-=(const Duration& a_ti);
194 
201  Duration& operator*=(uint64_t factor);
202 
209  const Duration operator +(const Duration& other) const;
210 
217  const Duration operator -(const Duration& other) const;
218 public:
224  int64_t to_millisecs() const;
225 
231  int64_t to_microsecs() const;
232 
238  double to_secs() const;
239 
240 private:
241  int32_t sec_;
242  uint32_t nsec_;
243 };
244 
253 const Duration OMG_DDS_API operator *(uint64_t lhs,
254  const Duration& rhs);
255 
264 const Duration OMG_DDS_API operator *(const Duration& lhs,
265  uint64_t rhs);
266 
273 const Duration OMG_DDS_API operator /(const Duration& lhs,
274  uint64_t rhs);
275 
276 }
277 } /* namespace dds / namespace core */
278 #endif /* OMG_DDS_CORE_DURATION_HPP_ */
operator-
const dds::core::Time operator-(const dds::core::Time &lhs, const dds::core::Duration &rhs)
dds::core::operator<=
bool operator<=(const array< _Tp, _Nm > &__one, const array< _Tp, _Nm > &__two)
Definition: array.hpp:296
types.hpp
dds::core::Duration
Definition: Duration.hpp:42
operator+
const dds::core::Time operator+(const dds::core::Time &lhs, const dds::core::Duration &rhs)
OMG_DDS_API
#define OMG_DDS_API
Definition: macros.hpp:52
dds::core::operator/
const Duration operator/(const Duration &lhs, uint64_t rhs)
dds::core::operator!=
bool operator!=(const array< _Tp, _Nm > &__one, const array< _Tp, _Nm > &__two)
Definition: array.hpp:274
dds::core::operator==
bool operator==(const array< _Tp, _Nm > &__one, const array< _Tp, _Nm > &__two)
Definition: array.hpp:267
dds
Definition: array.hpp:30
dds::core::operator>=
bool operator>=(const array< _Tp, _Nm > &__one, const array< _Tp, _Nm > &__two)
Definition: array.hpp:303
dds::core::operator<
bool operator<(const array< _Tp, _Nm > &__a, const array< _Tp, _Nm > &__b)
Definition: array.hpp:281
dds::core::operator>
bool operator>(const array< _Tp, _Nm > &__one, const array< _Tp, _Nm > &__two)
Definition: array.hpp:289
dds::core::operator*
const Duration operator*(uint64_t lhs, const Duration &rhs)