1 /*
2 * Copyright 2013-2018, 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 class TypeHandler;
21
22
23 class VariablesViewNodeInfo {
24 public:
25 VariablesViewNodeInfo();
26 VariablesViewNodeInfo(
27 const VariablesViewNodeInfo& other);
28 virtual ~VariablesViewNodeInfo();
29
30 VariablesViewNodeInfo& operator=(
31 const VariablesViewNodeInfo& other);
32
IsNodeExpanded()33 bool IsNodeExpanded() const
34 { return fNodeExpanded; }
35 void SetNodeExpanded(bool expanded);
36
GetCastedType()37 Type* GetCastedType() const
38 { return fCastedType; }
39 void SetCastedType(Type* type);
40
GetTypeHandler()41 TypeHandler* GetTypeHandler() const
42 { return fTypeHandler; }
43 void SetTypeHandler(TypeHandler* handler);
44
45
GetRendererSettings()46 const BMessage& GetRendererSettings() const
47 { return fRendererSettings; }
48
49 void SetRendererSettings(const BMessage& settings);
50
51 private:
52 bool fNodeExpanded;
53 Type* fCastedType;
54 TypeHandler* fTypeHandler;
55 BMessage fRendererSettings;
56 };
57
58
59 class VariablesViewState : public BReferenceable {
60 public:
61 VariablesViewState();
62 virtual ~VariablesViewState();
63
64 status_t Init();
65
Values()66 StackFrameValues* Values() const
67 { return fValues; }
68 void SetValues(StackFrameValues* values);
69
GetExpressionValues()70 ExpressionValues* GetExpressionValues() const
71 { return fExpressionValues; }
72 void SetExpressionValues(ExpressionValues* values);
73
74 const VariablesViewNodeInfo* GetNodeInfo(ObjectID* variable,
75 const TypeComponentPath* path) const;
76 inline const VariablesViewNodeInfo* GetNodeInfo(ObjectID* variable,
77 const TypeComponentPath& path) const;
78
79 status_t SetNodeInfo(ObjectID* variable,
80 TypeComponentPath* path,
81 const VariablesViewNodeInfo& info);
82 // requires an on-heap path
83
84 private:
85 struct Key;
86 struct InfoEntry;
87 struct InfoEntryHashDefinition;
88
89 typedef BOpenHashTable<InfoEntryHashDefinition> NodeInfoTable;
90
91 private:
92 void _Cleanup();
93
94 private:
95 NodeInfoTable* fNodeInfos;
96 StackFrameValues* fValues;
97 ExpressionValues* fExpressionValues;
98 };
99
100
101 const VariablesViewNodeInfo*
GetNodeInfo(ObjectID * variable,const TypeComponentPath & path)102 VariablesViewState::GetNodeInfo(ObjectID* variable,
103 const TypeComponentPath& path) const
104 {
105 return GetNodeInfo(variable, &path);
106 }
107
108
109 #endif // VARIABLES_VIEW_STATE_H
110