Timer.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2012  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020    ---------------------------------------------------------------------------
00021 */
00022 
00023 #ifndef __ccxx_Timer_hxx
00024 #define __ccxx_Timer_hxx
00025 
00026 #include <commonc++/Common.h++>
00027 
00028 namespace ccxx {
00029 
00038 class COMMONCPP_API Timer
00039 {
00040   public:
00041 
00043   Timer() throw();
00044 
00046   virtual ~Timer() throw();
00047 
00051   void start() throw();
00052 
00056   void stop() throw();
00057 
00061   inline void pause() throw()
00062   { stop(); }
00063 
00067   inline void resume() throw()
00068   { start(); }
00069 
00071   void reset() throw();
00072 
00076   inline uint64_t elapsedKernelTime() const throw()
00077   { return(_kernelElapsed); }
00078 
00082   inline uint64_t elapsedUserTime() const throw()
00083   { return(_userElapsed); }
00084 
00088   inline uint64_t elapsedRealTime() const throw()
00089   { return(_realElapsed); }
00090 
00092   inline bool isRunning() const throw()
00093   { return(_running); }
00094 
00095   private:
00096 
00097   time_ms_t _userTime;
00098   time_ms_t _kernelTime;
00099   time_ms_t _realTime;
00100 
00101   uint64_t _userElapsed;
00102   uint64_t _kernelElapsed;
00103   uint64_t _realElapsed;
00104 
00105   bool _running;
00106 
00107   CCXX_COPY_DECLS(Timer);
00108 };
00109 
00110 }; // namespace ccxx
00111 
00112 #endif // __ccxx_Timer_hxx
00113 
00114 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3