00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file TAO_Time_Service_Clerk.h 00006 * 00007 * TAO_Time_Service_Clerk.h,v 1.21 2006/03/14 06:14:35 jtc Exp 00008 * 00009 * This class implements the CosTime::TimeService IDL interface. 00010 * 00011 * 00012 * @author Vishal Kachroo <vishal@cs.wustl.edu> 00013 */ 00014 //============================================================================= 00015 00016 00017 #ifndef TAO_TIME_SERVICE_CLERK_H 00018 #define TAO_TIME_SERVICE_CLERK_H 00019 #include /**/ "ace/pre.h" 00020 00021 #include "ace/Reactor.h" 00022 00023 #include "orbsvcs/TimeServiceS.h" 00024 #include "orbsvcs/Time/Timer_Helper.h" 00025 #include "orbsvcs/Time/time_export.h" 00026 00027 00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00029 00030 /** 00031 * @class TAO_Time_Service_Clerk 00032 * 00033 * @brief TimeService Object Implementation. 00034 * 00035 * The Object implementation implements methods to retrieve 00036 * GLOBAL time as well as secure GLOBAL time. The times are 00037 * retrieved as UTOs. The object also allows creation of a TIO 00038 * for a given time interval. In general, the TimeService clerk 00039 * manages the UTOs and the TIOs. The notion of time returned 00040 * here is the globally synchronized time. 00041 */ 00042 class TAO_Time_Export TAO_Time_Service_Clerk : public POA_CosTime::TimeService 00043 { 00044 public: 00045 00046 /// Helper class to help in the updation of time. 00047 friend class Timer_Helper; 00048 00049 /// Unbounded set of IORs. 00050 typedef ACE_Array_Base<CosTime::TimeService_var> IORS; 00051 00052 // = Initialization and termination methods. 00053 /// Constructor. 00054 TAO_Time_Service_Clerk (int timer_value, 00055 int timer_value_usecs, 00056 const IORS& server); 00057 00058 /// Destructor. 00059 ~TAO_Time_Service_Clerk (void); 00060 00061 /// This operation returns the global time and an estimate of 00062 /// inaccuracy in a UTO. 00063 virtual CosTime::UTO_ptr universal_time (ACE_ENV_SINGLE_ARG_DECL) 00064 ACE_THROW_SPEC ((CORBA::SystemException, 00065 CosTime::TimeUnavailable)); 00066 00067 /** 00068 * This operation returns the global time in a UTO only if the time 00069 * can be guaranteed to have been obtained securely. Currently this 00070 * operation is not implemented and throws a CORBA::NO_IMPLEMENT 00071 * exception, if called. 00072 */ 00073 virtual CosTime::UTO_ptr secure_universal_time (ACE_ENV_SINGLE_ARG_DECL) 00074 ACE_THROW_SPEC ((CORBA::SystemException, 00075 CosTime::TimeUnavailable)); 00076 00077 /// This creates a new UTO based on the given parameters. 00078 virtual CosTime::UTO_ptr new_universal_time (TimeBase::TimeT time, 00079 TimeBase::InaccuracyT inaccuracy, 00080 TimeBase::TdfT tdf 00081 ACE_ENV_ARG_DECL) 00082 ACE_THROW_SPEC ((CORBA::SystemException)); 00083 00084 /// This creates a new UTO given a time in the UtcT form. 00085 virtual CosTime::UTO_ptr uto_from_utc (const TimeBase::UtcT &utc 00086 ACE_ENV_ARG_DECL) 00087 ACE_THROW_SPEC ((CORBA::SystemException)); 00088 00089 /// This creates a new TIO with the given parameters. 00090 virtual CosTime::TIO_ptr new_interval (TimeBase::TimeT lower, 00091 TimeBase::TimeT upper 00092 ACE_ENV_ARG_DECL) 00093 ACE_THROW_SPEC ((CORBA::SystemException)); 00094 00095 /// Return the globally synchronized time. 00096 virtual CORBA::ULongLong get_time (void); 00097 00098 /// Returns the time displacement factor. 00099 CORBA::Short time_displacement_factor (void); 00100 00101 /// Set the TDF. 00102 void time_displacement_factor (CORBA::Short); 00103 00104 /// Get method for inaccuracy. 00105 TimeBase::InaccuracyT inaccuracy (void); 00106 00107 /// Set method for inaccuracy. 00108 void inaccuracy (TimeBase::InaccuracyT inaccuracy); 00109 00110 /// Clerk's notion of time. 00111 CORBA::ULongLong time_; 00112 00113 private: 00114 00115 /// Time displacement factor in minutes. 00116 CORBA::Short time_displacement_factor_; 00117 00118 /// Inaccuracy in the time. 00119 TimeBase::InaccuracyT inaccuracy_; 00120 00121 /// Set of server Time Server IORs. 00122 IORS server_; 00123 00124 /// Time when last global synchronization was done. 00125 CORBA::ULongLong update_timestamp_; 00126 00127 /** 00128 * This is a friend class that inherits from the Event Handler 00129 * class. The handle_timeout method of this class is scheduled for 00130 * periodic invocation by the reactor. This method, in turn, updates 00131 * the clerks notion of time. Using this class obviates the need for 00132 * the clerk to multiple inherit from the servant base as well as 00133 * the event handler. 00134 */ 00135 Timer_Helper helper_; 00136 }; 00137 00138 TAO_END_VERSIONED_NAMESPACE_DECL 00139 00140 #include /**/ "ace/post.h" 00141 #endif /* TIME_SERVICE_CLERK_H */