ScummVM API documentation
te_timer.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
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 
22 #ifndef TETRAEDGE_TE_TE_TIMER_H
23 #define TETRAEDGE_TE_TE_TIMER_H
24 
25 #include "common/array.h"
26 #include "common/types.h"
27 
28 #include "tetraedge/te/te_signal.h"
29 #include "tetraedge/te/te_real_timer.h"
30 
31 namespace Tetraedge {
32 
33 class TeTimer {
34 public:
35  TeTimer();
36  ~TeTimer();
37 
38  void stop();
39  void start();
40  void pause();
41  void update();
42  uint64 getTimeFromStart();
43  void setAlarmIn(uint64 offset);
44  uint64 timeElapsed();
45  uint64 timeFromLastTimeElapsed();
46  uint64 time_();
47  void setTime(uint64 time);
48 
49  void pausable(bool ispausable);
50 
51  TeSignal0Param &alarmSignal() { return _alarmSignal; }
52 
53  static void pauseAll();
54  static void resumeAll();
55  static void updateAll();
56 
57  static void cleanup();
58 
59  bool running() const { return !_stopped; }
60 
61 private:
62  static TeRealTimer *realTimer();
63  static Common::Array<TeTimer *> *timers();
64  static Common::Array<TeTimer *> *pausedTimers();
65 
66  uint64 _startTime;
67  uint64 _startTimeOffset;
68  uint64 _alarmTime;
69  uint64 _lastTimeElapsed;
70  bool _pausable;
71  bool _alarmSet;
72  bool _updated;
73  bool _stopped;
74 
75  TeSignal0Param _alarmSignal;
76 
77  static bool _pausedAll;
78  static uint64 _realTime;
79  static Common::Array<TeTimer *> *_timers;
80  static Common::Array<TeTimer *> *_pausedTimers;
81  static TeRealTimer *_realTimer;
82 };
83 
84 } // end namespace Tetraedge
85 
86 #endif // TETRAEDGE_TE_TE_TIMER_H
Definition: te_signal.h:40
Definition: detection.h:27
Definition: array.h:52
Definition: te_timer.h:33
Definition: te_real_timer.h:28