00001 /** 00002 * \file mtimer.h <mi32/mtimer.h> 00003 * \brief Header file for MTIMER class 00004 * 00005 * \if NODOC 00006 * $Id: mtimer.h_v 1.6 2004/02/16 21:01:45 mju Exp $ 00007 * 00008 * $Log: mtimer.h_v $ 00009 * Revision 1.6 2004/02/16 21:01:45 mju 00010 * Warn on deprecated usage. 00011 * 00012 * Revision 1.5 2003/10/27 16:26:12 dwilliss 00013 * Fixed Mike's deprecatation. Have to allow the prototype to exist if 00014 * compiling misystem 00015 * 00016 * Revision 1.4 2003/10/09 13:44:30 mju 00017 * Remove rest of deprecated stuff. 00018 * 00019 * Revision 1.3 2003/10/08 22:03:21 mju 00020 * Remove unused deprecated stuff. 00021 * 00022 * Revision 1.2 2003/10/08 17:32:00 mju 00023 * Fix to compile. 00024 * 00025 * Revision 1.1 2003/10/08 16:40:01 mju 00026 * Initial revision 00027 * \endif 00028 **/ 00029 00030 #ifndef INC_MI32_MTIMER_H 00031 #define INC_MI32_MTIMER_H 00032 00033 #ifndef INC_MI32_STDDEFNS_H 00034 #include <mi32/stddefns.h> 00035 #endif 00036 00037 #ifndef INC_MI32_TEXTID_H 00038 #include <mi32/textid.h> 00039 #endif 00040 00041 class MISTRING; 00042 00043 #ifdef MISYSTEMDLL 00044 #define LIBEXPORT MI_DLLEXPORT 00045 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT 00046 #else 00047 #define LIBEXPORT MI_DLLIMPORT 00048 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT 00049 #endif 00050 00051 00052 //===================================================================================================================== 00053 //! Interval timer, used to time operations. 00054 //! Timer is accurate to 100ns on Windows and 1ms on other platforms. 00055 struct CLASSLIBEXPORT MTIMER { 00056 public: 00057 00058 //! Default constructor 00059 MTIMER (); 00060 00061 //! Destructor. 00062 ~MTIMER (); 00063 00064 //! Clear timer. 00065 //! Also stops timer. 00066 void Clear (); 00067 00068 // Get timer value as formatted string. 00069 void GetString ( 00070 MISTRING& string 00071 ) const; 00072 00073 //! Get the value of the timer in seconds. 00074 double GetValue ( 00075 ) const; 00076 00077 //! Determine if timer is currently 'on'. 00078 bool IsOn ( 00079 ) const; 00080 00081 //! Report "Time to ???: xxx xxx xxx". 00082 //! 00083 //! The ??? part is retrieved from the text resource file using the TEXTID provided. 00084 //! The rest of the message is built from text resource strings and the actual time. 00085 //! 00086 //! If TEXTID__None is specified then only the time is reported. 00087 void Report ( 00088 MISTRING& string, 00089 TEXTID textid = TEXTID__None 00090 ) const; 00091 00092 #if !defined(DEPRECATE_GROUPKEY) || defined(MISYSTEMDLL) 00093 //! Report "Time to ???: xxx xxx xxx". 00094 //! \deprecated Replaced by variant using TEXTID. 00095 //! The ??? part is retrieved from the text resource file using the TEXTID provided. 00096 //! The rest of the message is built from text resource strings and the actual time. 00097 //! 00098 //! If the group/key are NULL, it will just report the time 00099 DEPRECATED void Report ( 00100 MISTRING& string, 00101 const char* group, 00102 const char* key 00103 ) const; 00104 #endif 00105 00106 //! Report in "00:00" format 00107 void ReportShort ( 00108 MISTRING& string, 00109 int places = 0 //!< number of decimal places in seconds (eg, 0:00.00) 00110 ) const; 00111 00112 //! Start timer. 00113 void Start (); 00114 00115 //! Set the value of the timer 00116 void Set ( 00117 double seconds 00118 ); 00119 00120 //! Stop timer. 00121 //! Does not clear the timer. 00122 void Stop (); 00123 00124 private: 00125 #ifndef GENERATING_DOXYGEN_OUTPUT 00126 double m_total; 00127 double m_StartTime; 00128 UINT8 m_TimerOn; 00129 UINT8 padding[7]; 00130 00131 CHECKSIZE(24) 00132 #endif // GENERATING_DOXYGEN_OUTPUT 00133 }; 00134 00135 //===================================================================================================================== 00136 // REMOVED - Begin 00137 00138 #ifndef GENERATING_DOXYGEN_OUTPUT 00139 //! Removed items, still exported from DLL until sure all dependent EXEs rebuilt. 00140 #ifdef MISYSTEMDLL 00141 00142 extern "C" { 00143 00144 //! Clear a timer. 00145 LIBEXPORT void MtimerClear ( 00146 MTIMER *timer 00147 ); 00148 00149 //! Report timer value to formatted Unicode string. 00150 //! 00151 //! The message is generated using a two-step lookup process. The specified group/key is used 00152 //! to get the "description" of what is being timed. This is formatted (by default) in the form: 00153 //! Time to ???: XXX hours, XX minutes, XX seconds. 00154 //! where '???' is replaced by the message generated from the group/key. If both group and key 00155 //! are NULL then only the time string with no prefix is generated. 00156 LIBEXPORT void MtimerReportStr ( 00157 const MTIMER *timer, //!< Timer to report 00158 UNICODE* str, //!< String to hold message 00159 const char* group, //!< Message group 00160 const char* key //!< Message key 00161 ); 00162 00163 //! Start a timer. 00164 LIBEXPORT void MtimerStart ( 00165 MTIMER *timer 00166 ); 00167 00168 //! Stop a timer. 00169 LIBEXPORT void MtimerStop ( 00170 MTIMER *timer 00171 ); 00172 00173 //! Get the value of a timer. 00174 //! 00175 //! @return The number of seconds that the timer has run. 00176 LIBEXPORT double MtimerValue ( 00177 MTIMER *timer 00178 ); 00179 00180 //! Get current tick count. 00181 //! 00182 //! @return Clock "tick" of unknown starting time for use in interval timing. 00183 LIBEXPORT UINT32 MtimerTickCount (); 00184 00185 } // extern "C" 00186 00187 #endif 00188 #endif // GENERATING_DOXYGEN_OUTPUT 00189 00190 // REMOVED - End 00191 //===================================================================================================================== 00192 00193 #undef LIBEXPORT 00194 #undef CLASSLIBEXPORT 00195 00196 #endif // INC_MI32_MTIMER_H
1.3.8-20040913