TAO_Time_Service_Clerk Class Reference

TimeService Object Implementation. More...

#include <TAO_Time_Service_Clerk.h>

Collaboration diagram for TAO_Time_Service_Clerk:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Array_Base< CosTime::TimeService_var > IORS
 Unbounded set of IORs.

Public Member Functions

 TAO_Time_Service_Clerk (int timer_value, int timer_value_usecs, const IORS &server)
 Constructor.
 ~TAO_Time_Service_Clerk (void)
 Destructor.
virtual CosTime::UTO_ptr universal_time (void)
virtual CosTime::UTO_ptr secure_universal_time (void)
virtual CosTime::UTO_ptr new_universal_time (TimeBase::TimeT time, TimeBase::InaccuracyT inaccuracy, TimeBase::TdfT tdf)
 This creates a new UTO based on the given parameters.
virtual CosTime::UTO_ptr uto_from_utc (const TimeBase::UtcT &utc)
 This creates a new UTO given a time in the UtcT form.
virtual CosTime::TIO_ptr new_interval (TimeBase::TimeT lower, TimeBase::TimeT upper)
 This creates a new TIO with the given parameters.
virtual CORBA::ULongLong get_time (void)
 Return the globally synchronized time.
CORBA::Short time_displacement_factor (void)
 Returns the time displacement factor.
void time_displacement_factor (CORBA::Short)
 Set the TDF.
TimeBase::InaccuracyT inaccuracy (void)
 Get method for inaccuracy.
void inaccuracy (TimeBase::InaccuracyT inaccuracy)
 Set method for inaccuracy.

Public Attributes

CORBA::ULongLong time_
 Clerk's notion of time.

Private Attributes

CORBA::Short time_displacement_factor_
 Time displacement factor in minutes.
TimeBase::InaccuracyT inaccuracy_
 Inaccuracy in the time.
IORS server_
 Set of server Time Server IORs.
CORBA::ULongLong update_timestamp_
 Time when last global synchronization was done.
Timer_Helper helper_

Friends

class Timer_Helper
 Helper class to help in the updation of time.

Detailed Description

TimeService Object Implementation.

The Object implementation implements methods to retrieve GLOBAL time as well as secure GLOBAL time. The times are retrieved as UTOs. The object also allows creation of a TIO for a given time interval. In general, the TimeService clerk manages the UTOs and the TIOs. The notion of time returned here is the globally synchronized time.

Definition at line 42 of file TAO_Time_Service_Clerk.h.


Member Typedef Documentation

typedef ACE_Array_Base<CosTime::TimeService_var> TAO_Time_Service_Clerk::IORS

Unbounded set of IORs.

Definition at line 50 of file TAO_Time_Service_Clerk.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Time_Service_Clerk::TAO_Time_Service_Clerk ( int  timer_value,
int  timer_value_usecs,
const IORS server 
)

Constructor.

Definition at line 14 of file TAO_Time_Service_Clerk.cpp.

References ACE_ERROR, helper_, LM_ERROR, TAO_ORB_Core_instance(), and ACE_Time_Value::zero.

00017   : server_ (servers),
00018     helper_ (this)
00019 {
00020   // Schedule the helper to be invoked by the reactor
00021   // periodically.
00022 
00023   if (TAO_ORB_Core_instance ()->reactor ()->schedule_timer
00024       (&helper_,
00025        0,
00026        ACE_Time_Value::zero,
00027        ACE_Time_Value(timer_value,timer_value_usecs)) == -1)
00028     ACE_ERROR ((LM_ERROR,
00029                 "%p\n",
00030                 "schedule_timer ()"));
00031 }

TAO_Time_Service_Clerk::~TAO_Time_Service_Clerk ( void   ) 

Destructor.

Definition at line 35 of file TAO_Time_Service_Clerk.cpp.

00036 {
00037 }


Member Function Documentation

CORBA::ULongLong TAO_Time_Service_Clerk::get_time ( void   )  [virtual]

Return the globally synchronized time.

Definition at line 123 of file TAO_Time_Service_Clerk.cpp.

References ACE_OS::gettimeofday(), ACE_Time_Value::sec(), time_, update_timestamp_, and ACE_Time_Value::usec().

00124 {
00125   // Globally sync. time is the latest global time plus the time
00126   // elapsed since last updation was done.
00127 
00128   const ACE_Time_Value timeofday = ACE_OS::gettimeofday ();
00129 
00130   return (CORBA::ULongLong) (static_cast<CORBA::ULongLong> (timeofday.sec ()) *
00131                              static_cast<ACE_UINT32> (10000000) +
00132                              static_cast<CORBA::ULongLong> (timeofday.usec () * 10))
00133     - this->update_timestamp_
00134     + this->time_;
00135 }

void TAO_Time_Service_Clerk::inaccuracy ( TimeBase::InaccuracyT  inaccuracy  ) 

Set method for inaccuracy.

Definition at line 161 of file TAO_Time_Service_Clerk.cpp.

References inaccuracy_.

00162 {
00163   this->inaccuracy_ = inaccuracy;
00164 }

TimeBase::InaccuracyT TAO_Time_Service_Clerk::inaccuracy ( void   ) 

Get method for inaccuracy.

Definition at line 154 of file TAO_Time_Service_Clerk.cpp.

References inaccuracy_.

Referenced by Timer_Helper::handle_timeout(), universal_time(), and uto_from_utc().

00155 {
00156   return this->inaccuracy_;
00157 }

CosTime::TIO_ptr TAO_Time_Service_Clerk::new_interval ( TimeBase::TimeT  lower,
TimeBase::TimeT  upper 
) [virtual]

This creates a new TIO with the given parameters.

Definition at line 110 of file TAO_Time_Service_Clerk.cpp.

References ACE_NEW_THROW_EX.

00112 {
00113   TAO_TIO *tio = 0;
00114 
00115   ACE_NEW_THROW_EX (tio,
00116                     TAO_TIO (lower,
00117                              upper),
00118                     CORBA::NO_MEMORY ());
00119   return tio->_this ();
00120 }

CosTime::UTO_ptr TAO_Time_Service_Clerk::new_universal_time ( TimeBase::TimeT  time,
TimeBase::InaccuracyT  inaccuracy,
TimeBase::TdfT  tdf 
) [virtual]

This creates a new UTO based on the given parameters.

Definition at line 70 of file TAO_Time_Service_Clerk.cpp.

References ACE_NEW_THROW_EX.

00073 {
00074   TAO_UTO *uto = 0;
00075 
00076   ACE_NEW_THROW_EX (uto,
00077                     TAO_UTO (time,
00078                              inaccuracy,
00079                              tdf),
00080                     CORBA::NO_MEMORY ());
00081 
00082   return uto->_this ();
00083 }

CosTime::UTO_ptr TAO_Time_Service_Clerk::secure_universal_time ( void   )  [virtual]

This operation returns the global time in a UTO only if the time can be guaranteed to have been obtained securely. Currently this operation is not implemented and throws a CORBA::NO_IMPLEMENT exception, if called.

Definition at line 62 of file TAO_Time_Service_Clerk.cpp.

00063 {
00064   throw CORBA::NO_IMPLEMENT ();
00065 }

void TAO_Time_Service_Clerk::time_displacement_factor ( CORBA::Short   ) 

Set the TDF.

Definition at line 147 of file TAO_Time_Service_Clerk.cpp.

References time_displacement_factor_.

00148 {
00149   this->time_displacement_factor_ = tdf;
00150 }

CORBA::Short TAO_Time_Service_Clerk::time_displacement_factor ( void   ) 

Returns the time displacement factor.

Definition at line 140 of file TAO_Time_Service_Clerk.cpp.

References time_displacement_factor_.

Referenced by Timer_Helper::handle_timeout(), and universal_time().

00141 {
00142   return time_displacement_factor_;
00143 }

CosTime::UTO_ptr TAO_Time_Service_Clerk::universal_time ( void   )  [virtual]

This operation returns the global time and an estimate of inaccuracy in a UTO.

Definition at line 43 of file TAO_Time_Service_Clerk.cpp.

References ACE_NEW_THROW_EX, inaccuracy(), and time_displacement_factor().

00044 {
00045   TAO_UTO *uto = 0;
00046 
00047   ACE_NEW_THROW_EX (uto,
00048                     TAO_UTO (this->get_time (),
00049                              this->inaccuracy (),
00050                              this->time_displacement_factor ()),
00051                     CORBA::NO_MEMORY ());
00052   // Return the global time as a UTO.
00053 
00054   return uto->_this ();
00055 }

CosTime::UTO_ptr TAO_Time_Service_Clerk::uto_from_utc ( const TimeBase::UtcT &  utc  )  [virtual]

This creates a new UTO given a time in the UtcT form.

Definition at line 88 of file TAO_Time_Service_Clerk.cpp.

References ACE_NEW_THROW_EX, and inaccuracy().

00089 {
00090   TAO_UTO *uto = 0;
00091 
00092   // Use the low and high values of inaccuracy
00093   // to calculate the total inaccuracy.
00094 
00095   TimeBase::InaccuracyT inaccuracy = utc.inacchi;
00096   inaccuracy <<= 32;
00097   inaccuracy |= utc.inacclo;
00098 
00099   ACE_NEW_THROW_EX (uto,
00100                     TAO_UTO (utc.time,
00101                              inaccuracy,
00102                              utc.tdf),
00103                     CORBA::NO_MEMORY ());
00104   return uto->_this ();
00105 }


Friends And Related Function Documentation

friend class Timer_Helper [friend]

Helper class to help in the updation of time.

Definition at line 47 of file TAO_Time_Service_Clerk.h.


Member Data Documentation

Timer_Helper TAO_Time_Service_Clerk::helper_ [private]

This is a friend class that inherits from the Event Handler class. The handle_timeout method of this class is scheduled for periodic invocation by the reactor. This method, in turn, updates the clerks notion of time. Using this class obviates the need for the clerk to multiple inherit from the servant base as well as the event handler.

Definition at line 125 of file TAO_Time_Service_Clerk.h.

Referenced by TAO_Time_Service_Clerk().

TimeBase::InaccuracyT TAO_Time_Service_Clerk::inaccuracy_ [private]

Inaccuracy in the time.

Definition at line 109 of file TAO_Time_Service_Clerk.h.

Referenced by inaccuracy().

IORS TAO_Time_Service_Clerk::server_ [private]

Set of server Time Server IORs.

Definition at line 112 of file TAO_Time_Service_Clerk.h.

CORBA::ULongLong TAO_Time_Service_Clerk::time_

Clerk's notion of time.

Definition at line 101 of file TAO_Time_Service_Clerk.h.

Referenced by get_time(), and Timer_Helper::handle_timeout().

CORBA::Short TAO_Time_Service_Clerk::time_displacement_factor_ [private]

Time displacement factor in minutes.

Definition at line 106 of file TAO_Time_Service_Clerk.h.

Referenced by time_displacement_factor().

CORBA::ULongLong TAO_Time_Service_Clerk::update_timestamp_ [private]

Time when last global synchronization was done.

Definition at line 115 of file TAO_Time_Service_Clerk.h.

Referenced by get_time(), and Timer_Helper::handle_timeout().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:49:18 2010 for TAO_CosTime by  doxygen 1.4.7