BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Calibration/facilities/include/facilities/Clock.h
Go to the documentation of this file.
1// $Id: Clock.h,v 1.1.1.1 2005/10/17 06:11:40 maqm Exp $
2//
3// Original Author: Sawyer Gillespie
4// hgillesp@u.washington.edu
5//
6
7#ifndef _H_CLOCK
8#define _H_CLOCK 1
9
10#if _MSC_VER >= 1000
11# pragma once
12#endif // _MSC_VER >= 1000
13
14// includes
15#include <cmath>
16
17// forward declarations
18typedef double ClockWord;
19
20// class Clock
21// This is a general class for representing a clock value in terms
22// of some integral number of counts (ie. CPU cycles).
23//
24class Clock {
25public:
26 Clock() : m_time( 0 ), m_freq( 2.E7 ) {}
27
28 virtual ClockWord count( double t ) {
29 m_time += t;
30 return m_time;
31 }
32
33 virtual ClockWord count( unsigned int c ) {
34 m_time += c * 1. / m_freq;
35 return m_time;
36 }
37
38 virtual void reset() { m_time = 0; }
39
40 double freq() const { return m_freq; }
41
42 virtual unsigned int cycles() { return static_cast<unsigned>( ceil( m_time / m_freq ) ); }
43
44 virtual double elapsed() { return m_time; }
45
46private:
47 ClockWord m_time; // current elapsed time in clock cycles
48 double m_freq; // frequency in Hz
49};
50
51#endif
virtual ClockWord count(unsigned int c)
virtual ClockWord count(double t)
int t()
Definition t.c:1