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
30public:
32
33protected:
35 virtual ~AbstractTimer() {}
36
37public:
39 virtual void start();
40
42 virtual void start(float duration);
43
45 virtual void duration(float duration);
46
48 virtual float duration() const { return _duration; }
49
52
54 virtual float progress() const;
55
57 virtual bool isFinished() const { return _elapsedTime >= _duration; }
58
60 [[deprecated("Use isFinished() instead.")]]
61 virtual bool isComplete() const { return isFinished(); }
62
63protected:
64 // The duration.
65 float _duration;
66
67#if PQ_OPTIMIZE_FOR_CPU
68 // Precomputed 1/duration.
69 float _invDuration;
70#endif
71};
72
73}
74
75#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 Parameter Duration()
Returns duration as a parameter.
Definition AbstractTimer.h:51
virtual bool isFinished() const
Returns true iff the chronometer has finished its process.
Definition AbstractTimer.h:57
virtual bool isComplete() const
Definition AbstractTimer.h:61
virtual float duration() const
Returns duration.
Definition AbstractTimer.h:48
virtual void start()
Starts/restarts the chronometer.
Definition AbstractTimer.cpp:34
Definition PqCore.h:343