00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Countdown_Time.h 00006 * 00007 * $Id: Countdown_Time.h 85365 2009-05-18 08:27:42Z johnnyw $ 00008 * 00009 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef ACE_COUNTDOWN_TIME_H 00014 #define ACE_COUNTDOWN_TIME_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include /**/ "ace/ACE_export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "ace/Time_Value.h" 00025 #include "ace/Copy_Disabled.h" 00026 00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00028 00029 /** 00030 * @class ACE_Countdown_Time 00031 * 00032 * @brief Keeps track of the amount of elapsed time. 00033 * 00034 * This class has a side-effect on the @c max_wait_time -- every 00035 * time the stop() method is called the @c max_wait_time is 00036 * updated. 00037 */ 00038 class ACE_Export ACE_Countdown_Time : private ACE_Copy_Disabled 00039 { 00040 public: 00041 /// Cache the @a max_wait_time and call @c start(). 00042 ACE_Countdown_Time (ACE_Time_Value *max_wait_time); 00043 00044 /// Destructor, makes sure the max_wait_time that got passed as pointer 00045 /// to the constructor is updated with the time elapsed. 00046 ~ACE_Countdown_Time (void); 00047 00048 /// Cache the current time and enter a start state. 00049 void start (void); 00050 00051 /// Subtract the elapsed time from max_wait_time_ and enter a stopped 00052 /// state. 00053 void stop (void); 00054 00055 /// Calls stop and then start. max_wait_time_ is modified by the 00056 /// call to stop. 00057 void update (void); 00058 00059 /// Returns true if we've already been stopped, else false. 00060 bool stopped (void) const; 00061 00062 private: 00063 /// Maximum time we were willing to wait. 00064 ACE_Time_Value *max_wait_time_; 00065 00066 /// Beginning of the start time. 00067 ACE_Time_Value start_time_; 00068 00069 /// Keeps track of whether we've already been stopped. 00070 bool stopped_; 00071 }; 00072 00073 ACE_END_VERSIONED_NAMESPACE_DECL 00074 00075 #include /**/ "ace/post.h" 00076 00077 #if defined (__ACE_INLINE__) 00078 #include "ace/Countdown_Time.inl" 00079 #endif /* __ACE_INLINE__ */ 00080 00081 #endif /* ACE_COUNTDOWN_TIME_H */