summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-05-24 19:03:12 +0000
committerjtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-05-24 19:03:12 +0000
commitc36e4522a63191f2c286d7738b4cfb9922197f41 (patch)
treeb5abd0887c5bc9c47a841afaade3d3f8cb583573
parent64bef069ebf5bf00db38d16f46bfa3ed635ed31a (diff)
downloadATCD-c36e4522a63191f2c286d7738b4cfb9922197f41.tar.gz
ChangeLogTag: Tue May 24 11:59:37 2005 J.T. Conklin <jtc@acorntoolworks.com>
-rw-r--r--TAO/ChangeLog11
-rw-r--r--TAO/orbsvcs/orbsvcs/Time_Utilities.cpp9
-rw-r--r--TAO/orbsvcs/orbsvcs/Time_Utilities.h70
-rw-r--r--TAO/orbsvcs/orbsvcs/Time_Utilities.i34
4 files changed, 103 insertions, 21 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index b1868688c39..e9b7cd1142c 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,14 @@
+Tue May 24 11:59:37 2005 J.T. Conklin <jtc@acorntoolworks.com>
+
+ * orbsvcs/orbsvcs/Time_Utilities.cpp:
+ * orbsvcs/orbsvcs/Time_Utilities.h:
+ * orbsvcs/orbsvcs/Time_Utilities.i:
+
+ Updated comments to Doxygen format.
+
+ Added new methods for converting absolute timestamps between
+ ACE_Time_Value and TimeBase::TimeT.
+
Tue May 24 10:32:31 2005 J.T. Conklin <jtc@acorntoolworks.com>
* orbsvcs/orbsvcs/Makefile.am:
diff --git a/TAO/orbsvcs/orbsvcs/Time_Utilities.cpp b/TAO/orbsvcs/orbsvcs/Time_Utilities.cpp
index b0ee99afdbb..d47168b1212 100644
--- a/TAO/orbsvcs/orbsvcs/Time_Utilities.cpp
+++ b/TAO/orbsvcs/orbsvcs/Time_Utilities.cpp
@@ -7,3 +7,12 @@
#endif /* __ACE_INLINE__ */
ACE_RCSID(orbsvcs, Time_Utilities, "$Id$")
+
+// Number of nanoseconds between CORBA and POSIX epochs.
+#ifdef ACE_LACKS_LONGLONG_T
+const ACE_UINT64
+ORBSVCS_Time::Time_Base_Offset(0x82B60000, 0x0A990E2D6);
+#else
+const ACE_UINT64
+ORBSVCS_Time::Time_Base_Offset(ACE_UINT64_LITERAL(12218515200000000000));
+#endif
diff --git a/TAO/orbsvcs/orbsvcs/Time_Utilities.h b/TAO/orbsvcs/orbsvcs/Time_Utilities.h
index 86759d4ae66..f342e67b3df 100644
--- a/TAO/orbsvcs/orbsvcs/Time_Utilities.h
+++ b/TAO/orbsvcs/orbsvcs/Time_Utilities.h
@@ -22,50 +22,80 @@
#include "orbsvcs/svc_utils_export.h"
#include "ace/OS_NS_time.h"
+/**
+ * @class ORBSVCS_Time
+ *
+ * @brief Time conversion utilities.
+ *
+ * This class defines several static methods to convert between
+ * several ACE time structures and the CORBA TimeT structure.
+ *
+ * Recall that TimeBase::TimeT stores time in a 64-bit long long
+ * (or structure when that is not available) and uses hundreds of
+ * nanoseconds as time units (i.e. 1 second is 10^7 TimeT units).
+ *
+ * To convert between the CORBA and the UNIX epochs, we need to adjust
+ * absolute times by the difference between October 15th, 1582 (Julian
+ * Date 2299160.5) and January 1st, 1970 (Julian Date 2440578.5):
+ * 141418.0 days.
+ */
class TAO_Svc_Utils_Export ORBSVCS_Time
{
- // = TITLE
- // Time conversion utilities.
- //
- // = DESCRIPTION
- // This class define several static methods to convert between
- // several time structures and the CORBA TimeT structure.
- //
- // Recall that TimeT stores time in a 64-bit long long (or
- // structure when that is not available) and uses hundreds of
- // nanoseconds as time units (i.e. 1 second is 10^7 TimeT units).
public:
- // = A helper constant, IDL does not have constant for structures.
+ /// @brief A helper constant, IDL does not have constant for structures.
static TimeBase::TimeT zero ();
- // = ACE_hrtime_t conversion routines.
-
+ /**
+ * @name ACE_hrtime_t conversion routines
+ */
+ //@{
// We interpret an ACE_hrtime_t as nanoseconds.
+ /// @brief Convert relative high-resolution time to a <TimeBase::TimeT>.
static void hrtime_to_TimeT (TimeBase::TimeT &lhs,
ACE_hrtime_t rhs);
- // Convert high-resolution time to a <TimeT>.
+ /// @brief Convert relative <TimeBase::TimeT> to a high-resolution time.
static void TimeT_to_hrtime (ACE_hrtime_t &lhs,
const TimeBase::TimeT &rhs);
- // Convert <TimeT> to a high-resolution time.
+ /// @brief Convert relative <TimeBase::TimeT> to a high-resolution time.
static ACE_hrtime_t to_hrtime (const TimeBase::TimeT &t);
- // Convert <TimeT> to a high-resolution time.
+ //@}
- // = ACE_Time_Value conversion routines.
+ /**
+ * @name ACE_Time_Value conversion routines
+ */
+ //@{
// Recall that <ACE_Time_Value>s are <seconds, useconds> pairs.
+ /// @brief Convert relative <ACE_Time_Value> to a <TimeBase::TimeT>.
static void Time_Value_to_TimeT (TimeBase::TimeT& lhs,
const ACE_Time_Value& rhs);
- // Convert an <ACE_Time_Value> to a <TimeT>.
+
+ /// @brief Convert relative <TimeBase::TimeT> to a <ACE_Time_Value>.
static void TimeT_to_Time_Value (ACE_Time_Value& lrs,
const TimeBase::TimeT& rhs);
- // Convert an <TimeT> to a <ACE_Time_Value>.
+ /// @brief Convert relative <TimeBase::TimeT> to a <ACE_Time_Value>.
static ACE_Time_Value to_Time_Value (const TimeBase::TimeT &rhs);
- // Convert an <TimeT> to a <ACE_Time_Value>.
+
+ /// @brief Convert absolute <ACE_Time_Value> to a <TimeBase::TimeT>
+ static void Absolute_Time_Value_to_TimeT (TimeBase::TimeT& lhs,
+ const ACE_Time_Value& rhs);
+
+ /// @brief Convert absolute <TimeBase::TimeT> to a <ACE_Time_Value>
+ static void Absolute_TimeT_to_Time_Value (ACE_Time_Value& lrs,
+ const TimeBase::TimeT& rhs);
+
+ /// @brief Convert absolute <TimeBase::TimeT> to a <ACE_Time_Value>.
+ static ACE_Time_Value to_Absolute_Time_Value (const TimeBase::TimeT &rhs);
+ //@}
+
+private:
+ /// @brief Number of nanoseconds between the CORBA and UNIX epochs.
+ static const ACE_UINT64 Time_Base_Offset;
};
#if defined (__ACE_INLINE__)
diff --git a/TAO/orbsvcs/orbsvcs/Time_Utilities.i b/TAO/orbsvcs/orbsvcs/Time_Utilities.i
index 00e274c0ed0..27ea1cdde34 100644
--- a/TAO/orbsvcs/orbsvcs/Time_Utilities.i
+++ b/TAO/orbsvcs/orbsvcs/Time_Utilities.i
@@ -4,7 +4,6 @@
#include "ace/Time_Value.h"
-
ACE_INLINE TimeBase::TimeT
ORBSVCS_Time::zero ()
{
@@ -65,3 +64,36 @@ ORBSVCS_Time::to_Time_Value (const TimeBase::TimeT& t)
ORBSVCS_Time::TimeT_to_Time_Value (r, t);
return r;
}
+
+ACE_INLINE void
+ORBSVCS_Time::Absolute_Time_Value_to_TimeT (TimeBase::TimeT& lhs,
+ const ACE_Time_Value& rhs)
+{
+ ACE_hrtime_t t =
+ static_cast<ACE_hrtime_t> (rhs.sec ()) * ACE_U_ONE_SECOND_IN_NSECS +
+ static_cast<ACE_hrtime_t> (rhs.usec ()) * 1000u;
+
+ t += Time_Base_Offset;
+ ORBSVCS_Time::hrtime_to_TimeT (lhs, t);
+}
+
+ACE_INLINE void
+ORBSVCS_Time::Absolute_TimeT_to_Time_Value (ACE_Time_Value& lhs,
+ const TimeBase::TimeT& rhs)
+{
+ ACE_hrtime_t t;
+
+ ORBSVCS_Time::TimeT_to_hrtime (t, rhs);
+ t -= Time_Base_Offset;
+
+ lhs.set(static_cast<ACE_UINT32> (t / ACE_U_ONE_SECOND_IN_NSECS),
+ static_cast<ACE_UINT32> ((t % ACE_U_ONE_SECOND_IN_NSECS) / 1000));
+}
+
+ACE_INLINE ACE_Time_Value
+ORBSVCS_Time::to_Absolute_Time_Value (const TimeBase::TimeT& t)
+{
+ ACE_Time_Value r;
+ ORBSVCS_Time::Absolute_TimeT_to_Time_Value (r, t);
+ return r;
+}