DDS-PSM-C++  1.0
ISO C++ API for OpenSplice DDS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Time.hpp
Go to the documentation of this file.
1 #ifndef OMG_DDS_CORE_TIME_HPP_
2 #define OMG_DDS_CORE_TIME_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  namespace core {
26  class Duration;
27  class Time;
28  }
29 }
30 
32 public:
33  static const Time invalid(); // {-1, 0xffffffff}
34 
35 public:
36  static const Time from_microsecs(int64_t microseconds);
37  static const Time from_millisecs(int64_t milliseconds);
38  static const Time from_secs(double seconds);
39 
40 public:
41  Time();
42  explicit Time(int64_t sec, uint32_t nanosec = 0);
43 
44 public:
45  int64_t sec() const;
46  void sec(int64_t s);
47 
48  uint32_t nanosec() const;
49  void nanosec(uint32_t ns);
50 
51 public:
52  int compare(const Time& that);
53  bool operator >(const Time& that);
54  bool operator >=(const Time& that);
55 
56  bool operator ==(const Time& that);
57 
58  bool operator <=(const Time& that);
59  bool operator <(const Time& that);
60 
61 public:
62  Time& operator+=(const Duration& a_ti);
63  Time& operator-=(const Duration& a_ti);
64 
65 public:
66  int64_t to_millisecs() const;
67  void to_microsecs(int64_t microsec);
68  double to_secs() const;
69 
70 private:
71  int64_t sec_;
72  uint32_t nsec_;
73 };
74 
75 // Time arithmetic operators.
79 
80 
81 #endif /* OMG_DDS_CORE_TIME_HPP_ */
82