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
29namespace Wintermute {
30
31class Breakpoint;
32class Watch;
33class DebuggableScript;
34class DebuggableScEngine;
35class ScriptMonitor;
36
37class PublisherWArray : private Common::Array<Watch *> {
39 void notifySubscribers() {
40 for (uint i = 0; i < _subscribers.size(); i++) {
41 _subscribers[i]->updateWatches();
42 }
43 }
44public:
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
94 Common::Array<Breakpoint *> _breakpoints;
95 PublisherWArray _watches;
96 ScriptMonitor *_monitor;
97public:
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: array.h:52
T & operator[](size_type idx)
Definition: array.h:274
iterator end()
Definition: array.h:380
uint size_type
Definition: array.h:62
T remove_at(size_type idx)
Definition: array.h:261
Watch * * iterator
Definition: array.h:54
size_type size() const
Definition: array.h:316
void push_back(const T &element)
Definition: array.h:181
iterator begin()
Definition: array.h:375
Definition: base_game.h:79
Definition: debuggable_script_engine.h:93
Definition: debuggable_script.h:32
Definition: debuggable_script_engine.h:37
Definition: script_engine.h:43
Definition: script.h:44
Definition: script_monitor.h:31
Definition: watch.h:34
In find(In first, In last, const T &v)
Definition: algorithm.h:225