File: Timer.cpp

package info (click to toggle)
pentobi 29.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,892 kB
  • sloc: cpp: 25,719; javascript: 875; xml: 40; makefile: 13; sh: 6
file content (35 lines) | stat: -rw-r--r-- 858 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//-----------------------------------------------------------------------------
/** @file libboardgame_base/Timer.cpp
    @author Markus Enzenberger
    @copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------

#include "Timer.h"

#include "Assert.h"
#include "TimeSource.h"

namespace libboardgame_base {

//-----------------------------------------------------------------------------

double Timer::operator()() const
{
    LIBBOARDGAME_ASSERT(m_time_source);
    return (*m_time_source)() - m_start;
}

void Timer::reset()
{
    m_start = (*m_time_source)();
}

void Timer::reset(TimeSource& time_source)
{
    m_time_source = &time_source;
    reset();
}

//-----------------------------------------------------------------------------

} // namespace libboardgame_base