TAO_Time_Service_Server.cpp

Go to the documentation of this file.
00001 #include "orbsvcs/Time/TAO_UTO.h"
00002 #include "orbsvcs/Time/TAO_TIO.h"
00003 #include "orbsvcs/Time/TAO_Time_Service_Server.h"
00004 #include "ace/OS_NS_sys_time.h"
00005 #include "orbsvcs/Time_Utilities.h"
00006 
00007 #include "tao/debug.h"
00008 
00009 
00010 ACE_RCSID (Time,
00011            TAO_Time_Service_Server,
00012            "TAO_Time_Service_Server.cpp,v 1.34 2006/03/14 06:14:35 jtc Exp")
00013 
00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00015 
00016 // Constructor.
00017 TAO_Time_Service_Server::TAO_Time_Service_Server (void)
00018 {
00019 }
00020 
00021 // Destructor.
00022 TAO_Time_Service_Server::~TAO_Time_Service_Server (void)
00023 {
00024 }
00025 
00026 // This method returns the current system time and an estimate of
00027 // inaccuracy in a UTO.
00028 
00029 CosTime::UTO_ptr
00030 TAO_Time_Service_Server::universal_time (ACE_ENV_SINGLE_ARG_DECL)
00031     ACE_THROW_SPEC ((CORBA::SystemException,
00032                      CosTime::TimeUnavailable))
00033 {
00034   TAO_UTO *uto = 0;
00035 
00036   TimeBase::TimeT timestamp;
00037   ORBSVCS_Time::Absolute_Time_Value_to_TimeT(timestamp, ACE_OS::gettimeofday());
00038 
00039   // Return the local time of the system as a UTO.
00040   ACE_NEW_THROW_EX (uto,
00041                     TAO_UTO (timestamp,
00042                              0,
00043                              0),
00044                     CORBA::NO_MEMORY ());
00045 
00046   ACE_CHECK_RETURN (CosTime::UTO::_nil ());
00047 
00048   if (TAO_debug_level > 0)
00049     ACE_DEBUG ((LM_DEBUG,
00050                 "Returning a UTO\n"));
00051 
00052   return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
00053 }
00054 
00055 // This method returns the current time in a UTO only if the time can
00056 // be guaranteed to have been obtained securely.  This method is not
00057 // implemented currently.
00058 
00059 CosTime::UTO_ptr
00060 TAO_Time_Service_Server::secure_universal_time (ACE_ENV_SINGLE_ARG_DECL)
00061     ACE_THROW_SPEC ((CORBA::SystemException,
00062                      CosTime::TimeUnavailable))
00063 {
00064   ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (),
00065                     CosTime::UTO::_nil ());
00066 }
00067 
00068 // This creates a new UTO based on the given parameters.
00069 
00070 CosTime::UTO_ptr
00071 TAO_Time_Service_Server::new_universal_time (TimeBase::TimeT time,
00072                                              TimeBase::InaccuracyT inaccuracy,
00073                                              TimeBase::TdfT tdf
00074                                              ACE_ENV_ARG_DECL)
00075     ACE_THROW_SPEC ((CORBA::SystemException))
00076 {
00077   TAO_UTO *uto = 0;
00078 
00079   ACE_NEW_THROW_EX (uto,
00080                     TAO_UTO (time,
00081                              inaccuracy,
00082                              tdf),
00083                     CORBA::NO_MEMORY ());
00084   ACE_CHECK_RETURN (CosTime::UTO::_nil ());
00085 
00086   return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
00087 }
00088 
00089 // This creates a new UTO given a time in the UtcT form.
00090 
00091 CosTime::UTO_ptr
00092 TAO_Time_Service_Server::uto_from_utc (const TimeBase::UtcT &utc
00093                                        ACE_ENV_ARG_DECL)
00094     ACE_THROW_SPEC ((CORBA::SystemException))
00095 {
00096   TAO_UTO *uto = 0;
00097 
00098   ACE_NEW_THROW_EX (uto,
00099                     TAO_UTO (utc.time,
00100                              utc.inacclo + utc.inacchi,
00101                              utc.tdf),
00102                     CORBA::NO_MEMORY ());
00103   ACE_CHECK_RETURN (CosTime::UTO::_nil ());
00104 
00105   return uto->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
00106 }
00107 
00108 // This creates a new TIO with the given parameters.
00109 
00110 CosTime::TIO_ptr
00111 TAO_Time_Service_Server::new_interval (TimeBase::TimeT lower,
00112                                        TimeBase::TimeT upper
00113                                        ACE_ENV_ARG_DECL)
00114     ACE_THROW_SPEC ((CORBA::SystemException))
00115 {
00116   TAO_TIO *tio = 0;
00117 
00118   ACE_NEW_THROW_EX (tio,
00119                     TAO_TIO (lower,
00120                              upper),
00121                     CORBA::NO_MEMORY ());
00122   ACE_CHECK_RETURN (CosTime::TIO::_nil ());
00123 
00124   return tio->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
00125 }
00126 
00127 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:58:37 2006 for TAO_CosTime by doxygen 1.3.6