• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

src/hpp/dds/core/Time.hpp

Go to the documentation of this file.
00001 #ifndef OMG_DDS_CORE_TIME_HPP_
00002 #define OMG_DDS_CORE_TIME_HPP_
00003 
00004 /* Copyright 2010, Object Management Group, Inc.
00005  * Copyright 2010, PrismTech, Corp.
00006  * Copyright 2010, Real-Time Innovations, Inc.
00007  * All rights reserved.
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License");
00010  * you may not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  *     http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS,
00017  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #include <dds/core/corefwd.hpp>
00023 
00024 
00025 namespace dds { namespace core {
00026 
00027 class Time {
00028 public:
00029     static const Time invalid();       // {-1, 0xffffffff}
00030 
00031 public:
00032     static const Time from_microseconds(int64_t microseconds);
00033     static const Time from_milliseconds(int64_t milliseconds);
00034     static const Time from_seconds(double seconds);
00035 
00036 public:
00037         Time();
00038     explicit Time(int64_t sec, uint32_t nanosec = 0);
00039 
00040 public:
00041     int64_t sec() const;
00042     void    sec(int64_t s);
00043 
00044     uint32_t nanosec() const;
00045     void     nanosec(uint32_t ns);
00046 
00047 public:
00048     int compare(const Time& that);
00049         bool operator >(const Time& that);
00050         bool operator >=(const Time& that);
00051 
00052         bool operator ==(const Time& that);
00053 
00054         bool operator <=(const Time& that);
00055         bool operator <(const Time& that);
00056 
00057 public:
00058     Time& operator+=(const Duration& a_ti);
00059     Time& operator-=(const Duration& a_ti);
00060     
00061 public:
00062     void set_in_milliseconds(int64_t millisec);
00063     int64_t get_in_milliseconds() const;
00064     
00065     void set_in_microseconds(int64_t microsec);
00066     int64_t get_in_microseconds() const;
00067     
00068     void set_in_seconds(double seconds);
00069     double get_in_seconds() const;
00070     
00071 private:
00072     int64_t sec_;
00073     uint32_t nsec_;
00074 };
00075 
00076 // Time arithmetic operators.
00077 const Time operator +(const Time& lhs,      const Duration &rhs);
00078 const Time operator +(const Duration& lhs,  const Time& rhs);
00079 const Time operator -(const Time& lhs,      const Duration &rhs);
00080 
00081 } } /* namespace dds / namespace core  */
00082 #endif /* OMG_DDS_CORE_TIME_HPP_ */
00083 

Generated on Tue Nov 9 2010 02:16:21 for dds-psm-cxx-doc by  doxygen 1.7.1