00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Countdown_Time.h 00006 * 00007 * $Id: Countdown_Time.h 80826 2008-03-04 14:51:23Z wotte $ 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 00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 /** 00029 * @class ACE_Countdown_Time 00030 * 00031 * @brief Keeps track of the amount of elapsed time. 00032 * 00033 * This class has a side-effect on the @c max_wait_time -- every 00034 * time the stop() method is called the @c max_wait_time is 00035 * updated. 00036 */ 00037 class ACE_Export ACE_Countdown_Time 00038 { 00039 public: 00040 /// Cache the @a max_wait_time and call @c start(). 00041 ACE_Countdown_Time (ACE_Time_Value *max_wait_time); 00042 00043 /// Destructor, makes sure the max_wait_time that got passed as pointer 00044 /// to the constructor is updated with the time elapsed. 00045 ~ACE_Countdown_Time (void); 00046 00047 /// Cache the current time and enter a start state. 00048 void start (void); 00049 00050 /// Subtract the elapsed time from max_wait_time_ and enter a stopped 00051 /// state. 00052 void stop (void); 00053 00054 /// Calls stop and then start. max_wait_time_ is modified by the 00055 /// call to stop. 00056 void update (void); 00057 00058 /// Returns true if we've already been stopped, else false. 00059 bool stopped (void) const; 00060 00061 private: 00062 /// Maximum time we were willing to wait. 00063 ACE_Time_Value *max_wait_time_; 00064 00065 /// Beginning of the start time. 00066 ACE_Time_Value start_time_; 00067 00068 /// Keeps track of whether we've already been stopped. 00069 bool stopped_; 00070 00071 // Prevent copying 00072 ACE_Countdown_Time (const ACE_Countdown_Time &); 00073 ACE_Countdown_Time &operator= (const ACE_Countdown_Time &); 00074 }; 00075 00076 ACE_END_VERSIONED_NAMESPACE_DECL 00077 00078 #include /**/ "ace/post.h" 00079 00080 #endif /* ACE_COUNTDOWN_TIME_H */