~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to TAO/orbsvcs/orbsvcs/Time/TAO_Time_Service_Server.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "TAO_UTO.h"
2
 
#include "TAO_TIO.h"
3
 
#include "TAO_Time_Service_Server.h"
4
 
#include "ace/OS_NS_sys_time.h"
5
 
 
6
 
#include "tao/debug.h"
7
 
 
8
 
 
9
 
ACE_RCSID (Time,
10
 
           TAO_Time_Service_Server,
11
 
           "TAO_Time_Service_Server.cpp,v 1.28 2003/11/01 20:54:57 bala Exp")
12
 
 
13
 
 
14
 
// Constructor.
15
 
TAO_Time_Service_Server::TAO_Time_Service_Server (void)
16
 
{
17
 
}
18
 
 
19
 
// Destructor.
20
 
TAO_Time_Service_Server::~TAO_Time_Service_Server (void)
21
 
{
22
 
}
23
 
 
24
 
// This method returns the current system time and an estimate of
25
 
// inaccuracy in a UTO.
26
 
 
27
 
CosTime::UTO_ptr
28
 
TAO_Time_Service_Server::universal_time (ACE_ENV_SINGLE_ARG_DECL)
29
 
    ACE_THROW_SPEC ((CORBA::SystemException,
30
 
                     CosTime::TimeUnavailable))
31
 
{
32
 
  TAO_UTO *uto = 0;
33
 
 
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 :
40
 
  //
41
 
  //  Time Units : 100 nanosecs
42
 
  //  Base Time  : 15th October 1582 00:00:00
43
 
  //  Approximate range : AD 30,000
44
 
  //
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.
48
 
 
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)
52
 
#else
53
 
  CORBA::ULongLong TAO_Time_Base_Offset = ACE_UINT64_LITERAL (0x2D8539C80);
54
 
#endif
55
 
 
56
 
  const ACE_Time_Value timeofday = ACE_OS::gettimeofday ();
57
 
 
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,
62
 
                                               timeofday.sec ())) *
63
 
                             ACE_static_cast (ACE_UINT32,
64
 
                                              10000000) +
65
 
                             ACE_static_cast  (CORBA::ULongLong,
66
 
                                               timeofday.usec () * 10),
67
 
                             0,
68
 
                             0),
69
 
                    CORBA::NO_MEMORY ());
70
 
 
71
 
  ACE_CHECK_RETURN (CosTime::UTO::_nil ());
72
 
 
73
 
  if (TAO_debug_level > 0)
74
 
    ACE_DEBUG ((LM_DEBUG,
75
 
                "Returning a UTO\n"));
76
 
 
77
 
  return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
78
 
}
79
 
 
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.
83
 
 
84
 
CosTime::UTO_ptr
85
 
TAO_Time_Service_Server::secure_universal_time (ACE_ENV_SINGLE_ARG_DECL)
86
 
    ACE_THROW_SPEC ((CORBA::SystemException,
87
 
                     CosTime::TimeUnavailable))
88
 
{
89
 
  ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (),
90
 
                    CosTime::UTO::_nil ());
91
 
}
92
 
 
93
 
// This creates a new UTO based on the given parameters.
94
 
 
95
 
CosTime::UTO_ptr
96
 
TAO_Time_Service_Server::new_universal_time (TimeBase::TimeT time,
97
 
                                             TimeBase::InaccuracyT inaccuracy,
98
 
                                             TimeBase::TdfT tdf
99
 
                                             ACE_ENV_ARG_DECL)
100
 
    ACE_THROW_SPEC ((CORBA::SystemException))
101
 
{
102
 
  TAO_UTO *uto = 0;
103
 
 
104
 
  ACE_NEW_THROW_EX (uto,
105
 
                    TAO_UTO (time,
106
 
                             inaccuracy,
107
 
                             tdf),
108
 
                    CORBA::NO_MEMORY ());
109
 
  ACE_CHECK_RETURN (CosTime::UTO::_nil ());
110
 
 
111
 
  return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
112
 
}
113
 
 
114
 
// This creates a new UTO given a time in the UtcT form.
115
 
 
116
 
CosTime::UTO_ptr
117
 
TAO_Time_Service_Server::uto_from_utc (const TimeBase::UtcT &utc
118
 
                                       ACE_ENV_ARG_DECL)
119
 
    ACE_THROW_SPEC ((CORBA::SystemException))
120
 
{
121
 
  TAO_UTO *uto = 0;
122
 
 
123
 
  ACE_NEW_THROW_EX (uto,
124
 
                    TAO_UTO (utc.time,
125
 
                             utc.inacclo + utc.inacchi,
126
 
                             utc.tdf),
127
 
                    CORBA::NO_MEMORY ());
128
 
  ACE_CHECK_RETURN (CosTime::UTO::_nil ());
129
 
 
130
 
  return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
131
 
}
132
 
 
133
 
// This creates a new TIO with the given parameters.
134
 
 
135
 
CosTime::TIO_ptr
136
 
TAO_Time_Service_Server::new_interval (TimeBase::TimeT lower,
137
 
                                       TimeBase::TimeT upper
138
 
                                       ACE_ENV_ARG_DECL)
139
 
    ACE_THROW_SPEC ((CORBA::SystemException))
140
 
{
141
 
  TAO_TIO *tio = 0;
142
 
 
143
 
  ACE_NEW_THROW_EX (tio,
144
 
                    TAO_TIO (lower,
145
 
                             upper),
146
 
                    CORBA::NO_MEMORY ());
147
 
  ACE_CHECK_RETURN (CosTime::TIO::_nil ());
148
 
 
149
 
  return tio->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
150
 
}
151
 
 
152
 
 
153
 
 
154
 
 
155
 
 
156
 
 
157
 
 
158
 
 
159