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            "$Id: TAO_Time_Service_Server.cpp 77001 2007-02-12 07:54:49Z johnnyw $")
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 (void)
00031 {
00032   TAO_UTO *uto = 0;
00033 
00034   TimeBase::TimeT timestamp;
00035   ORBSVCS_Time::Absolute_Time_Value_to_TimeT(timestamp, ACE_OS::gettimeofday());
00036 
00037   // Return the local time of the system as a UTO.
00038   ACE_NEW_THROW_EX (uto,
00039                     TAO_UTO (timestamp,
00040                              0,
00041                              0),
00042                     CORBA::NO_MEMORY ());
00043 
00044 
00045   if (TAO_debug_level > 0)
00046     ACE_DEBUG ((LM_DEBUG,
00047                 "Returning a UTO\n"));
00048 
00049   return uto->_this ();
00050 }
00051 
00052 // This method returns the current time in a UTO only if the time can
00053 // be guaranteed to have been obtained securely.  This method is not
00054 // implemented currently.
00055 
00056 CosTime::UTO_ptr
00057 TAO_Time_Service_Server::secure_universal_time (void)
00058 {
00059   throw CORBA::NO_IMPLEMENT ();
00060 }
00061 
00062 // This creates a new UTO based on the given parameters.
00063 
00064 CosTime::UTO_ptr
00065 TAO_Time_Service_Server::new_universal_time (TimeBase::TimeT time,
00066                                              TimeBase::InaccuracyT inaccuracy,
00067                                              TimeBase::TdfT tdf)
00068 {
00069   TAO_UTO *uto = 0;
00070 
00071   ACE_NEW_THROW_EX (uto,
00072                     TAO_UTO (time,
00073                              inaccuracy,
00074                              tdf),
00075                     CORBA::NO_MEMORY ());
00076 
00077   return uto->_this ();
00078 }
00079 
00080 // This creates a new UTO given a time in the UtcT form.
00081 
00082 CosTime::UTO_ptr
00083 TAO_Time_Service_Server::uto_from_utc (const TimeBase::UtcT &utc)
00084 {
00085   TAO_UTO *uto = 0;
00086 
00087   ACE_NEW_THROW_EX (uto,
00088                     TAO_UTO (utc.time,
00089                              utc.inacclo + utc.inacchi,
00090                              utc.tdf),
00091                     CORBA::NO_MEMORY ());
00092 
00093   return uto->_this ();
00094 }
00095 
00096 // This creates a new TIO with the given parameters.
00097 
00098 CosTime::TIO_ptr
00099 TAO_Time_Service_Server::new_interval (TimeBase::TimeT lower,
00100                                        TimeBase::TimeT upper)
00101 {
00102   TAO_TIO *tio = 0;
00103 
00104   ACE_NEW_THROW_EX (tio,
00105                     TAO_TIO (lower,
00106                              upper),
00107                     CORBA::NO_MEMORY ());
00108 
00109   return tio->_this ();
00110 }
00111 
00112 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:49:17 2010 for TAO_CosTime by  doxygen 1.4.7