3
#include "TAO_Time_Service_Server.h"
4
#include "ace/OS_NS_sys_time.h"
10
TAO_Time_Service_Server,
11
"TAO_Time_Service_Server.cpp,v 1.28 2003/11/01 20:54:57 bala Exp")
15
TAO_Time_Service_Server::TAO_Time_Service_Server (void)
20
TAO_Time_Service_Server::~TAO_Time_Service_Server (void)
24
// This method returns the current system time and an estimate of
25
// inaccuracy in a UTO.
28
TAO_Time_Service_Server::universal_time (ACE_ENV_SINGLE_ARG_DECL)
29
ACE_THROW_SPEC ((CORBA::SystemException,
30
CosTime::TimeUnavailable))
34
// UNIX systems use 1st Jan. 1970 as the Base Time. The CORBA Time
35
// Service uses the Universal Time Coordinated (UTC) representation
36
// of time from the X/Open DCE Time Service. The UTC time signals
37
// broadcast by the WWV radio station of the National Bureau of
38
// Standards deliver time that is easier to handle in this
39
// representation. UTC time is defined as :
41
// Time Units : 100 nanosecs
42
// Base Time : 15th October 1582 00:00:00
43
// Approximate range : AD 30,000
45
// To construct the UTC time from UNIX time we need to add the
46
// difference of days between 15th October 1582 and 1st Jan
47
// 1970. This difference is 141427 days or 0x2D8539C80 secs.
49
#if defined (ACE_LACKS_LONGLONG_T)
50
CORBA::ULongLong TAO_Time_Base_Offset (0xD8539C80, 2);
51
// (Lower 32 bits of the offset in hex, Upper 32 bits of the offset in hex)
53
CORBA::ULongLong TAO_Time_Base_Offset = ACE_UINT64_LITERAL (0x2D8539C80);
56
const ACE_Time_Value timeofday = ACE_OS::gettimeofday ();
58
// Return the local time of the system as a UTO.
59
ACE_NEW_THROW_EX (uto,
60
TAO_UTO ((TAO_Time_Base_Offset +
61
ACE_static_cast (CORBA::ULongLong,
63
ACE_static_cast (ACE_UINT32,
65
ACE_static_cast (CORBA::ULongLong,
66
timeofday.usec () * 10),
71
ACE_CHECK_RETURN (CosTime::UTO::_nil ());
73
if (TAO_debug_level > 0)
75
"Returning a UTO\n"));
77
return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
80
// This method returns the current time in a UTO only if the time can
81
// be guaranteed to have been obtained securely. This method is not
82
// implemented currently.
85
TAO_Time_Service_Server::secure_universal_time (ACE_ENV_SINGLE_ARG_DECL)
86
ACE_THROW_SPEC ((CORBA::SystemException,
87
CosTime::TimeUnavailable))
89
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (),
90
CosTime::UTO::_nil ());
93
// This creates a new UTO based on the given parameters.
96
TAO_Time_Service_Server::new_universal_time (TimeBase::TimeT time,
97
TimeBase::InaccuracyT inaccuracy,
100
ACE_THROW_SPEC ((CORBA::SystemException))
104
ACE_NEW_THROW_EX (uto,
108
CORBA::NO_MEMORY ());
109
ACE_CHECK_RETURN (CosTime::UTO::_nil ());
111
return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
114
// This creates a new UTO given a time in the UtcT form.
117
TAO_Time_Service_Server::uto_from_utc (const TimeBase::UtcT &utc
119
ACE_THROW_SPEC ((CORBA::SystemException))
123
ACE_NEW_THROW_EX (uto,
125
utc.inacclo + utc.inacchi,
127
CORBA::NO_MEMORY ());
128
ACE_CHECK_RETURN (CosTime::UTO::_nil ());
130
return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
133
// This creates a new TIO with the given parameters.
136
TAO_Time_Service_Server::new_interval (TimeBase::TimeT lower,
137
TimeBase::TimeT upper
139
ACE_THROW_SPEC ((CORBA::SystemException))
143
ACE_NEW_THROW_EX (tio,
146
CORBA::NO_MEMORY ());
147
ACE_CHECK_RETURN (CosTime::TIO::_nil ());
149
return tio->_this (ACE_ENV_SINGLE_ARG_PARAMETER);