ScummVM API documentation
timed_event_mgr.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 ULTIMA4_EVENTS_TIMED_EVENT_MGR_H
23 #define ULTIMA4_EVENTS_TIMED_EVENT_MGR_H
24 
25 #include "common/list.h"
26 
27 namespace Ultima {
28 namespace Ultima4 {
29 
33 class TimedEvent {
34 public:
35  /* Typedefs */
37  typedef void (*Callback)(void *);
38 
39  /* Constructors */
40  TimedEvent(Callback callback, int interval, void *data = nullptr);
41 
42  /* Member functions */
43  Callback getCallback() const;
44  void *getData();
45 
50  void tick();
51 
52  /* Properties */
53 protected:
54  Callback _callback;
55  void *_data;
56  int _interval;
57  int _current;
58 };
59 
64 public:
65  /* Typedefs */
66  typedef TimedEvent::List List;
67 
68  /* Constructors */
75  TimedEventMgr(int baseInterval);
76 
84 
89  void poll();
90 
94  bool isLocked() const;
95 
99  void add(TimedEvent::Callback theCallback, int interval, void *data = nullptr);
100 
104  List::iterator remove(List::iterator i);
105  void remove(TimedEvent *event);
106  void remove(TimedEvent::Callback theCallback, void *data = nullptr);
107 
111  void tick();
112 
116  void reset(uint interval);
117 #if defined(IOS_ULTIMA4)
118  bool hasActiveTimer() const;
119 #endif
120 
121 private:
122  void lock();
123  void unlock();
125  /* Properties */
126 protected:
127  uint32 _lastTickTime;
128  uint32 _baseInterval;
129  bool _locked;
130  List _events;
131  List _deferredRemovals;
132 #if defined(IOS_ULTIMA4)
133  TimedManagerHelper *m_helper;
134 #endif
135 };
136 
137 } // End of namespace Ultima4
138 } // End of namespace Ultima
139 
140 #endif
~TimedEventMgr()
Definition: timed_event_mgr.h:83
Definition: list.h:44
Definition: timed_event_mgr.h:33
Definition: timed_event_mgr.h:63
Definition: detection.h:27
Definition: list_intern.h:51