xref: /haiku/src/apps/debugger/user_interface/gui/model/VariablesViewState.h (revision 91c0454716f24a7454b20f7a54cfe32e288e3710)
1 /*
2  * Copyright 2013-2014, Rene Gollent, rene@gollent.com.
3  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef VARIABLES_VIEW_STATE_H
7 #define VARIABLES_VIEW_STATE_H
8 
9 
10 #include <Message.h>
11 #include <Referenceable.h>
12 #include <util/OpenHashTable.h>
13 
14 
15 class ExpressionValues;
16 class ObjectID;
17 class StackFrameValues;
18 class Type;
19 class TypeComponentPath;
20 
21 
22 class VariablesViewNodeInfo {
23 public:
24 								VariablesViewNodeInfo();
25 								VariablesViewNodeInfo(
26 									const VariablesViewNodeInfo& other);
27 	virtual						~VariablesViewNodeInfo();
28 
29 			VariablesViewNodeInfo& operator=(
30 									const VariablesViewNodeInfo& other);
31 
32 			bool				IsNodeExpanded() const
33 									{ return fNodeExpanded; }
34 			void				SetNodeExpanded(bool expanded);
35 
36 			Type*				GetCastedType() const
37 									{ return fCastedType; }
38 			void				SetCastedType(Type* type);
39 
40 			const BMessage&		GetRendererSettings() const
41 									{ return fRendererSettings; }
42 
43 			void				SetRendererSettings(const BMessage& settings);
44 
45 private:
46 			bool				fNodeExpanded;
47 			Type*				fCastedType;
48 			BMessage			fRendererSettings;
49 };
50 
51 
52 class VariablesViewState : public BReferenceable {
53 public:
54 								VariablesViewState();
55 	virtual						~VariablesViewState();
56 
57 			status_t			Init();
58 
59 			StackFrameValues*	Values() const
60 									{ return fValues; }
61 			void				SetValues(StackFrameValues* values);
62 
63 			ExpressionValues*	GetExpressionValues() const
64 									{ return fExpressionValues; }
65 			void				SetExpressionValues(ExpressionValues* values);
66 
67 			const VariablesViewNodeInfo* GetNodeInfo(ObjectID* variable,
68 									const TypeComponentPath* path) const;
69 	inline	const VariablesViewNodeInfo* GetNodeInfo(ObjectID* variable,
70 									const TypeComponentPath& path) const;
71 
72 			status_t			SetNodeInfo(ObjectID* variable,
73 									TypeComponentPath* path,
74 									const VariablesViewNodeInfo& info);
75 									// requires an on-heap path
76 
77 private:
78 			struct Key;
79 			struct InfoEntry;
80 			struct InfoEntryHashDefinition;
81 
82 			typedef BOpenHashTable<InfoEntryHashDefinition> NodeInfoTable;
83 
84 private:
85 			void				_Cleanup();
86 
87 private:
88 			NodeInfoTable*		fNodeInfos;
89 			StackFrameValues*	fValues;
90 			ExpressionValues*	fExpressionValues;
91 };
92 
93 
94 const VariablesViewNodeInfo*
95 VariablesViewState::GetNodeInfo(ObjectID* variable,
96 	const TypeComponentPath& path) const
97 {
98 	return GetNodeInfo(variable, &path);
99 }
100 
101 
102 #endif	// VARIABLES_VIEW_STATE_H
103