Plaquette
 
Loading...
Searching...
No Matches
AbstractTimer.h
1/*
2 * AbstractTimer.h
3 *
4 * (c) 2018 Sofian Audry :: info(@)sofianaudry(.)com
5 * (c) 2018 Thomas O Fredericks :: tof(@)t-o-f(.)info
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef ABSTRACT_TIMER_H_
22#define ABSTRACT_TIMER_H_
23
24#include "PqCore.h"
25#include "Chronometer.h"
26
27namespace pq {
28
30protected:
32 virtual ~AbstractTimer() {}
33
34public:
36 virtual void start();
37
39 virtual void start(float duration);
40
42 virtual void duration(float duration);
43
45 virtual float duration() const { return _duration; }
46
48 virtual float progress() const;
49
51 virtual bool isFinished() const { return _elapsedTime >= _duration; }
52
54 [[deprecated("Use isFinished() instead.")]]
55 virtual bool isComplete() const { return isFinished(); }
56
57protected:
58 // The duration.
59 float _duration;
60
61#if PQ_OPTIMIZE_FOR_CPU
62 // Precomputed 1/duration.
63 float _invDuration;
64#endif
65};
66
67}
68
69#endif
Definition AbstractChronometer.h:29
Definition AbstractTimer.h:29
virtual float progress() const
The progress of the timer process (in %).
Definition AbstractTimer.cpp:53
virtual bool isFinished() const
Returns true iff the chronometer has finished its process.
Definition AbstractTimer.h:51
virtual bool isComplete() const
Definition AbstractTimer.h:55
virtual float duration() const
Returns duration.
Definition AbstractTimer.h:45
virtual void start()
Starts/restarts the chronometer.
Definition AbstractTimer.cpp:34