xref: /haiku/headers/private/debugger/value/value_nodes/ArrayValueNode.h (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * Copyright 2013-2015, 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 ARRAY_VALUE_NODE_H
7 #define ARRAY_VALUE_NODE_H
8 
9 
10 #include <ObjectList.h>
11 
12 #include "ValueNode.h"
13 
14 
15 class AbstractArrayValueNodeChild;
16 class ArrayType;
17 
18 
19 class AbstractArrayValueNode : public ValueNode {
20 public:
21 								AbstractArrayValueNode(
22 									ValueNodeChild* nodeChild, ArrayType* type,
23 									int32 dimension);
24 	virtual						~AbstractArrayValueNode();
25 
26 			ArrayType*			GetArrayType() const
27 									{ return fType; }
28 			int32				Dimension() const
29 									{ return fDimension; }
30 
31 	virtual	Type*				GetType() const;
32 
33 	virtual	status_t			ResolvedLocationAndValue(
34 									ValueLoader* valueLoader,
35 									ValueLocation*& _location,
36 									Value*& _value);
37 
38 			// locking required
39 
40 	virtual	status_t			CreateChildren(TeamTypeInformation* info);
41 	virtual	int32				CountChildren() const;
42 	virtual	ValueNodeChild*		ChildAt(int32 index) const;
43 
44 	virtual	bool				IsRangedContainer() const;
45 	virtual	void				ClearChildren();
46 	virtual	status_t			CreateChildrenInRange(
47 									TeamTypeInformation* info,
48 									int32 lowIndex, int32 highIndex);
49 	virtual	status_t			SupportedChildRange(int32& lowIndex,
50 									int32& highIndex) const;
51 protected:
52 			typedef BObjectList<AbstractArrayValueNodeChild> ChildList;
53 
54 protected:
55 			ArrayType*			fType;
56 			ChildList			fChildren;
57 			int32				fDimension;
58 			int32				fLowerBound;
59 			int32				fUpperBound;
60 			bool				fBoundsInitialized;
61 };
62 
63 
64 // TODO: Are ArrayValueNode and InternalArrayValueNode still needed?
65 
66 class ArrayValueNode : public AbstractArrayValueNode {
67 public:
68 								ArrayValueNode(ValueNodeChild* nodeChild,
69 									ArrayType* type);
70 	virtual						~ArrayValueNode();
71 };
72 
73 
74 class InternalArrayValueNode : public AbstractArrayValueNode {
75 public:
76 								InternalArrayValueNode(
77 									ValueNodeChild* nodeChild,
78 									ArrayType* type, int32 dimension);
79 	virtual						~InternalArrayValueNode();
80 };
81 
82 
83 class AbstractArrayValueNodeChild : public ValueNodeChild {
84 public:
85 								AbstractArrayValueNodeChild(
86 									AbstractArrayValueNode* parent,
87 									const BString& name, int64 elementIndex);
88 	virtual						~AbstractArrayValueNodeChild();
89 
90 			AbstractArrayValueNode* ArrayParent() const	{ return fParent; }
91 			int32				ElementIndex() const { return fElementIndex; }
92 
93 	virtual	const BString&		Name() const;
94 	virtual	ValueNode*			Parent() const;
95 
96 protected:
97 			AbstractArrayValueNode* fParent;
98 			BString				fName;
99 			int64				fElementIndex;
100 };
101 
102 
103 class ArrayValueNodeChild : public AbstractArrayValueNodeChild {
104 public:
105 								ArrayValueNodeChild(
106 									AbstractArrayValueNode* parent,
107 									const BString& name, int64 elementIndex,
108 									Type* type);
109 	virtual						~ArrayValueNodeChild();
110 
111 	virtual	Type*				GetType() const;
112 
113 	virtual	status_t			ResolveLocation(ValueLoader* valueLoader,
114 									ValueLocation*& _location);
115 
116 private:
117 			Type*				fType;
118 };
119 
120 
121 class InternalArrayValueNodeChild : public AbstractArrayValueNodeChild {
122 public:
123 								InternalArrayValueNodeChild(
124 									AbstractArrayValueNode* parent,
125 									const BString& name, int64 elementIndex,
126 									ArrayType* type);
127 	virtual						~InternalArrayValueNodeChild();
128 
129 	virtual	Type*				GetType() const;
130 
131 	virtual	bool				IsInternal() const;
132 	virtual	status_t			CreateInternalNode(ValueNode*& _node);
133 
134 	virtual	status_t			ResolveLocation(ValueLoader* valueLoader,
135 									ValueLocation*& _location);
136 
137 private:
138 			ArrayType*			fType;
139 };
140 
141 
142 #endif	// ARRAY_VALUE_NODE_H
143