00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Countdown_Time.h 00006 * 00007 * $Id: Countdown_Time.h 76729 2007-01-30 11:36:40Z 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 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 <max_wait_time> is 00035 * updated. 00036 */ 00037 class ACE_Export ACE_Countdown_Time 00038 { 00039 public: 00040 // = Initialization and termination methods. 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 // Prevent copying 00073 ACE_Countdown_Time (const ACE_Countdown_Time &); 00074 ACE_Countdown_Time &operator= (const ACE_Countdown_Time &); 00075 }; 00076 00077 ACE_END_VERSIONED_NAMESPACE_DECL 00078 00079 #include /**/ "ace/post.h" 00080 00081 #endif /* ACE_COUNTDOWN_TIME_H */