/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/facilities/facilities-00-00-04/facilities/Clock.h

Go to the documentation of this file.
00001 // $Id: Clock.h,v 1.1.1.1 2005/10/17 06:11:40 maqm Exp $
00002 //
00003 //  Original Author: Sawyer Gillespie
00004 //                   hgillesp@u.washington.edu
00005 //
00006 
00007 #ifndef _H_CLOCK
00008 #define _H_CLOCK 1
00009 
00010 #if _MSC_VER >= 1000
00011 #pragma once
00012 #endif // _MSC_VER >= 1000
00013 
00014 // includes
00015 #include <cmath>
00016 
00017 // forward declarations
00018 typedef double ClockWord;
00019 
00020 // class Clock
00021 //  This is a general class for representing a clock value in terms
00022 //  of some integral number of counts (ie. CPU cycles).
00023 //
00024 class Clock 
00025 {
00026   public:
00027       Clock ()
00028         : m_time(0), m_freq(2.E7) 
00029       {}
00030 
00031       virtual ClockWord count (double t)
00032       {
00033         m_time += t;
00034         return m_time; 
00035       }
00036 
00037       virtual ClockWord count (unsigned int c)
00038       {
00039         m_time += c * 1./m_freq; 
00040         return m_time; 
00041       }
00042 
00043       virtual void reset ()
00044       {
00045         m_time = 0; 
00046       }
00047 
00048       double freq () const
00049       {
00050         return m_freq; 
00051       }
00052 
00053       virtual unsigned int cycles ()
00054       {
00055         return static_cast<unsigned>(ceil(m_time / m_freq)); 
00056       }
00057 
00058       virtual double elapsed ()
00059       {
00060         return m_time; 
00061       }
00062 
00063   private:
00064       ClockWord m_time; //  current elapsed time        in clock cycles
00065       double m_freq;    //  frequency in Hz
00066 };
00067 
00068 #endif

Generated on Tue Nov 29 22:57:55 2016 for BOSS_7.0.2 by  doxygen 1.4.7