00001 ////////////////////////////////////////////////////////////////////// 00002 // Copyright (c) 2001-2002 David Pritchard <drpritch@alumni.uwaterloo.ca> 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public License 00006 // as published by the Free Software Foundation; either 00007 // version 2 of the License, or (at your option) any later 00008 // version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 00019 #ifndef freecloth_base_baTime_h 00020 #define freecloth_base_baTime_h 00021 00022 #ifndef freecloth_base_package_h 00023 #include <freecloth/base/package.h> 00024 #endif 00025 00026 #ifndef freecloth_base_types_h 00027 #include <freecloth/base/types.h> 00028 #endif 00029 00030 FREECLOTH_NAMESPACE_START 00031 00032 //////////////////////////////////////////////////////////////////////////////// 00033 /*! 00034 * \class BaTime freecloth/base/baTime.h 00035 * \brief Basic measurement of time. 00036 * 00037 * Defines instants and durations, and methods for retrieving the current time 00038 * and measuring durations. 00039 */ 00040 class BaTime 00041 { 00042 public: 00043 //----- types and enumerations ----- 00044 //! A period of time. 00045 typedef Int32 Duration; 00046 //! A single point in time. 00047 typedef UInt32 Instant; 00048 00049 enum { 00050 MS = 1, 00051 S = 1000, 00052 MIN = S * 60 00053 }; 00054 00055 // ----- static member functions ----- 00056 00057 //! Retrieve the current time. 00058 static Instant getTime(); 00059 00060 //! Calculate the elapsed time between two instants. 00061 static Duration getDuration( Instant start, Instant end ); 00062 00063 //! Return a floating point value representing the given instant as a 00064 //! number, measured in seconds. 00065 static Float instantAsSeconds( Instant ); 00066 //! Return a floating point value representing the given duration as a 00067 //! number, measured in seconds. 00068 static Float durationAsSeconds( Duration ); 00069 static Instant floatAsInstant( Float ); 00070 static Duration floatAsDuration( Float ); 00071 }; 00072 00073 FREECLOTH_NAMESPACE_END 00074 00075 #include <freecloth/base/baTime.inline.h> 00076 00077 #endif