00001 #ifndef __TIMER_H_INCLUDED__ 00002 #define __TIMER_H_INCLUDED__ 00003 00004 // $Id$ 00005 00006 //********************************************************************** 00007 // * 00008 // Description: Timer class. Provides interval and duration * 00009 // timing, both of which can be reset. * 00010 // * 00011 // Author: Chris White (whitecf@bcs.org.uk) * 00012 // * 00013 // Copyright (C) 2003 Monitor Computing Services Ltd. * 00014 // * 00015 // This program is free software; you can redistribute it and/or * 00016 // modify it under the terms of the GNU General Public License * 00017 // as published by the Free Software Foundation; either version 2 * 00018 // of the License, or any later version. * 00019 // * 00020 // This program is distributed in the hope that it will be useful, * 00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of * 00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00023 // GNU General Public License for more details. * 00024 // * 00025 // You should have received a copy of the GNU General Public * 00026 // License (http://www.gnu.org/copyleft/gpl.html) along with this * 00027 // program; if not, write to: * 00028 // The Free Software Foundation Inc., * 00029 // 59 Temple Place - Suite 330, * 00030 // Boston, MA 02111-1307, * 00031 // USA. * 00032 // * 00033 //********************************************************************** 00034 // * 00035 // Notes: * 00036 // * 00037 //********************************************************************** 00038 00039 00040 #include <time.h> 00041 00042 00043 namespace Monitor { 00044 namespace Utility { 00045 00049 class Timer 00050 { 00051 public: 00055 Timer(); 00056 00060 virtual ~Timer(); 00061 00062 00068 unsigned 00069 interval(); 00070 00076 unsigned 00077 restartInterval(); 00078 00084 unsigned 00085 duration(); 00086 00087 00093 unsigned 00094 restart(); 00095 00096 00097 private: 00101 clock_t startTime; 00102 00106 clock_t intervalTime; 00107 }; 00108 00109 }; // namespace Utility 00110 }; // namespace Monitor 00111 00112 #endif // __TIMER_H_INCLUDED__