UserInterface.h revision fce4895d
1/*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2013-2016, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6#ifndef USER_INTERFACE_H
7#define USER_INTERFACE_H
8
9
10#include <OS.h>
11
12#include <Referenceable.h>
13
14#include "TeamMemoryBlock.h"
15#include "Types.h"
16
17
18class entry_ref;
19
20class CpuState;
21class ExpressionInfo;
22class FunctionInstance;
23class Image;
24class LocatableFile;
25class SourceLanguage;
26class StackFrame;
27class Team;
28class TeamUiSettings;
29class Thread;
30class TypeComponentPath;
31class UserBreakpoint;
32class UserInterfaceListener;
33class Value;
34class ValueNode;
35class ValueNodeContainer;
36class Watchpoint;
37
38
39enum user_notification_type {
40	USER_NOTIFICATION_INFO,
41	USER_NOTIFICATION_WARNING,
42	USER_NOTIFICATION_ERROR
43};
44
45
46class UserInterface : public BReferenceable {
47public:
48	virtual						~UserInterface();
49
50	virtual const char*			ID() const = 0;
51
52	virtual	status_t			Init(Team* team,
53									UserInterfaceListener* listener) = 0;
54	virtual	void				Show() = 0;
55	virtual	void				Terminate() = 0;
56									// shut down the UI *now* -- no more user
57									// feedback
58
59	virtual	bool				IsInteractive() const = 0;
60
61	virtual status_t			LoadSettings(const TeamUiSettings* settings)
62									= 0;
63	virtual status_t			SaveSettings(TeamUiSettings*& settings)
64									const = 0;
65
66	virtual	void				NotifyUser(const char* title,
67									const char* message,
68									user_notification_type type) = 0;
69	virtual	void				NotifyBackgroundWorkStatus(const char* message)
70									= 0;
71									// this is used to inform the user about
72									// background processing work, but doesn't
73									// otherwise require any form of
74									// user interaction, i.e. for a status bar
75									// to indicate that debug information is
76									// being parsed.
77
78	virtual	int32				SynchronouslyAskUser(const char* title,
79									const char* message, const char* choice1,
80									const char* choice2, const char* choice3)
81									= 0;
82									// returns -1, if not implemented or user
83									// cannot be asked
84
85	virtual	status_t			SynchronouslyAskUserForFile(entry_ref* _ref)
86									= 0;
87};
88
89
90class UserInterfaceListener {
91public:
92			enum QuitOption {
93				QUIT_OPTION_ASK_USER,
94				QUIT_OPTION_ASK_KILL_TEAM,
95				QUIT_OPTION_ASK_RESUME_TEAM
96			};
97
98public:
99	virtual						~UserInterfaceListener();
100
101	virtual	void				FunctionSourceCodeRequested(
102									FunctionInstance* function,
103									bool forceDisassembly = false) = 0;
104	virtual void				SourceEntryLocateRequested(
105									const char* sourcePath,
106									const char* locatedPath) = 0;
107	virtual	void				SourceEntryInvalidateRequested(
108									LocatableFile* sourceFile) = 0;
109	virtual	void				ImageDebugInfoRequested(Image* image) = 0;
110	virtual	void				ValueNodeValueRequested(CpuState* cpuState,
111									ValueNodeContainer* container,
112									ValueNode* valueNode) = 0;
113	virtual	void				ValueNodeWriteRequested(ValueNode* node,
114									CpuState* state, Value* newValue) = 0;
115	virtual	void				ThreadActionRequested(thread_id threadID,
116									uint32 action,
117									target_addr_t address = 0) = 0;
118
119	virtual	void				SetBreakpointRequested(target_addr_t address,
120									bool enabled, bool hidden = false) = 0;
121	virtual	void				SetBreakpointEnabledRequested(
122									UserBreakpoint* breakpoint,
123									bool enabled) = 0;
124	virtual	void				SetBreakpointConditionRequested(
125									UserBreakpoint* breakpoint,
126									const char* condition) = 0;
127	virtual	void				ClearBreakpointConditionRequested(
128									UserBreakpoint* breakpoint) = 0;
129	virtual	void				ClearBreakpointRequested(
130									target_addr_t address) = 0;
131	virtual	void				ClearBreakpointRequested(
132									UserBreakpoint* breakpoint) = 0;
133									// TODO: Consolidate those!
134
135	virtual	void				SetStopOnImageLoadRequested(bool enabled,
136									bool useImageNames) = 0;
137	virtual	void				AddStopImageNameRequested(
138									const char* name) = 0;
139	virtual	void				RemoveStopImageNameRequested(
140									const char* name) = 0;
141
142	virtual	void				SetDefaultSignalDispositionRequested(
143									int32 disposition) = 0;
144	virtual	void				SetCustomSignalDispositionRequested(
145									int32 signal, int32 disposition) = 0;
146	virtual	void				RemoveCustomSignalDispositionRequested(
147									int32 signal) = 0;
148
149	virtual	void				SetWatchpointRequested(target_addr_t address,
150									uint32 type, int32 length,
151									bool enabled) = 0;
152	virtual	void				SetWatchpointEnabledRequested(
153									Watchpoint* watchpoint,
154									bool enabled) = 0;
155	virtual	void				ClearWatchpointRequested(
156									target_addr_t address) = 0;
157	virtual	void				ClearWatchpointRequested(
158									Watchpoint* watchpoint) = 0;
159
160	virtual void				InspectRequested(
161									target_addr_t address,
162									TeamMemoryBlock::Listener* listener) = 0;
163	virtual	void				MemoryWriteRequested(
164									target_addr_t address,
165									const void* data,
166									target_size_t length) = 0;
167
168	virtual	void				ExpressionEvaluationRequested(
169									SourceLanguage* language,
170									ExpressionInfo* info,
171									StackFrame* frame = NULL,
172									::Thread* thread = NULL) = 0;
173
174	virtual void				DebugReportRequested(entry_ref* path) = 0;
175
176	virtual	void				WriteCoreFileRequested(entry_ref* path) = 0;
177
178	virtual	void				TeamRestartRequested() = 0;
179
180	virtual	bool				UserInterfaceQuitRequested(
181									QuitOption quitOption
182										= QUIT_OPTION_ASK_USER) = 0;
183};
184
185
186#endif	// USER_INTERFACE_H
187