ScummVM API documentation
debuggable_script_engine.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 DEBUGGABLE_SCRIPT_ENGINE_H_
23 #define DEBUGGABLE_SCRIPT_ENGINE_H_
24 #include "engines/wintermute/base/scriptables/script_engine.h"
25 #include "engines/wintermute/coll_templ.h"
26 #include "common/algorithm.h"
27 #include "engines/wintermute/base/scriptables/debuggable/debuggable_script.h"
28 
29 namespace Wintermute {
30 
31 class Breakpoint;
32 class Watch;
33 class DebuggableScript;
34 class DebuggableScEngine;
35 class ScriptMonitor;
36 
37 class PublisherWArray : private Common::Array<Watch *> {
39  void notifySubscribers() {
40  for (uint i = 0; i < _subscribers.size(); i++) {
41  _subscribers[i]->updateWatches();
42  }
43  }
44 public:
45  void subscribe(DebuggableScript *script) {
46  if (Common::find(_subscribers.begin(), _subscribers.end(), script) == _subscribers.end()) {
47  // If not already contained
48  _subscribers.push_back(script);
49  }
50  }
51 
52  void unsubscribe(DebuggableScript *script) {
53  int location = -1;
54  for (uint i = 0; i < _subscribers.size() && location == -1; i++) {
55  if (_subscribers[i] == script) {
56  location = i;
57  }
58  }
59  if (location >= 0) {
60  _subscribers.remove_at(location);
61  } else {
62  // TODO: If this happens... it's funny. Some script out there forgot to subscribe.
63  }
64  }
65 
66  void push_back(Watch *newElement) {
68  notifySubscribers();
69  }
70 
71  size_type size() {
73  }
74 
75  iterator begin() {
77  }
78 
79  iterator end() {
81  }
82 
83  Watch *&operator[](size_type idx) {
85  }
86  Watch *remove_at(size_type idx) {
88  notifySubscribers();
89  return res;
90  }
91 };
92 
93 class DebuggableScEngine : public ScEngine {
94  Common::Array<Breakpoint *> _breakpoints;
95  PublisherWArray _watches;
96  ScriptMonitor *_monitor;
97 public:
99  void attachMonitor(ScriptMonitor *);
100 
101  friend class DebuggerController;
102  friend class DebuggableScript;
103  friend class ScScript;
104  friend class WatchableScriptArray;
105 };
106 
107 } // End of namespace Wintermute
108 
109 #endif /* DEBUGGABLE_SCRIPT_ENGINE_H_ */
Definition: script.h:44
Definition: base_game.h:76
Definition: array.h:52
Definition: debuggable_script_engine.h:37
iterator end()
Definition: array.h:379
iterator begin()
Definition: array.h:374
In find(In first, In last, const T &v)
Definition: algorithm.h:225
T & operator[](size_type idx)
Definition: array.h:273
Watch * * iterator
Definition: array.h:54
Definition: debugger_controller.h:59
void push_back(const T &element)
Definition: array.h:180
Definition: watch.h:34
size_type size() const
Definition: array.h:315
Definition: script_monitor.h:31
Definition: debuggable_script_engine.h:93
T remove_at(size_type idx)
Definition: array.h:260
uint size_type
Definition: array.h:59
Definition: debuggable_script.h:32
Definition: script_engine.h:42
Definition: achievements_tables.h:27