ScummVM API documentation
effect_manager.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 NUVIE_CORE_EFFECT_MANAGER_H
23 #define NUVIE_CORE_EFFECT_MANAGER_H
24 
25 #include "ultima/shared/std/containers.h"
26 
27 namespace Ultima {
28 namespace Nuvie {
29 
30 class Effect;
31 
32 /* This just keeps a list of Effect pointers, and deletes them when requested.
33  */
35  friend class Effect;
36  typedef Std::vector<Effect *>::iterator EffectIterator;
37  typedef Std::vector<Effect *>::const_iterator ConstEffectIterator;
38  /* For each EffectWatch, a message will be sent to "watcher" when
39  "effect" is deleted. */
40  typedef struct {
41  CallBack *watcher;
42  Effect *effect;
43  } EffectWatch;
44  typedef Std::vector<EffectWatch>::iterator WatchIterator;
45 
46  Std::vector<Effect *> effects; // the simple list
48 
49  void add_effect(Effect *eff); // only effects can add themselves
50  void signal_watch(Effect *effect);
51  EffectWatch *find_effect_watch(Effect *effect);
52 
53 public:
54  EffectManager();
55  ~EffectManager();
56 
57  void delete_effect(Effect *eff); // anyone may delete an effect
58  void update_effects(); // check and delete
59 
60  bool has_effects() const;
61  void watch_effect(CallBack *callback_target, Effect *watch);
62  void unwatch_effect(CallBack *callback_target, Effect *watch = nullptr);
63 };
64 
65 } // End of namespace Nuvie
66 } // End of namespace Ultima
67 
68 #endif
Definition: effect_manager.h:34
T * iterator
Definition: array.h:54
Definition: detection.h:27
Definition: effect.h:67
const T * const_iterator
Definition: array.h:55
Definition: call_back.h:50
Definition: containers.h:38