2 * Copyright 2015, Rene Gollent, rene@gollent.com.
3 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
11 #include "ValueLocation.h"
12 #include "ValueNodeContainer.h"
15 // #pragma mark - ValueNode
18 ValueNode::ValueNode(ValueNodeChild
* nodeChild
)
21 fNodeChild(nodeChild
),
24 fLocationResolutionState(VALUE_NODE_UNRESOLVED
),
25 fChildrenCreated(false)
27 fNodeChild
->AcquireReference();
31 ValueNode::~ValueNode()
33 SetLocationAndValue(NULL
, NULL
, VALUE_NODE_UNRESOLVED
);
35 fNodeChild
->ReleaseReference();
40 ValueNode::Name() const
42 return fNodeChild
->Name();
47 ValueNode::SetContainer(ValueNodeContainer
* container
)
49 if (container
== fContainer
)
52 if (fContainer
!= NULL
)
53 fContainer
->ReleaseReference();
55 fContainer
= container
;
57 if (fContainer
!= NULL
)
58 fContainer
->AcquireReference();
60 // propagate to children
61 int32 childCount
= CountChildren();
62 for (int32 i
= 0; i
< childCount
; i
++)
63 ChildAt(i
)->SetContainer(fContainer
);
68 ValueNode::IsRangedContainer() const
75 ValueNode::IsContainerRangeFixed() const
82 ValueNode::ClearChildren()
89 ValueNode::CreateChildrenInRange(TeamTypeInformation
* info
, int32 lowIndex
,
92 return B_NOT_SUPPORTED
;
97 ValueNode::SupportedChildRange(int32
& lowIndex
, int32
& highIndex
) const
99 return B_NOT_SUPPORTED
;
104 ValueNode::SetLocationAndValue(ValueLocation
* location
, Value
* value
,
105 status_t resolutionState
)
107 if (fLocation
!= location
) {
108 if (fLocation
!= NULL
)
109 fLocation
->ReleaseReference();
111 fLocation
= location
;
113 if (fLocation
!= NULL
)
114 fLocation
->AcquireReference();
117 if (fValue
!= value
) {
119 fValue
->ReleaseReference();
124 fValue
->AcquireReference();
127 fLocationResolutionState
= resolutionState
;
130 if (fContainer
!= NULL
)
131 fContainer
->NotifyValueNodeValueChanged(this);
135 // #pragma mark - ValueNodeChild
138 ValueNodeChild::ValueNodeChild()
143 fLocationResolutionState(VALUE_NODE_UNRESOLVED
)
148 ValueNodeChild::~ValueNodeChild()
150 SetLocation(NULL
, VALUE_NODE_UNRESOLVED
);
157 ValueNodeChild::IsInternal() const
164 ValueNodeChild::CreateInternalNode(ValueNode
*& _node
)
171 ValueNodeChild::SetContainer(ValueNodeContainer
* container
)
173 if (container
== fContainer
)
176 if (fContainer
!= NULL
)
177 fContainer
->ReleaseReference();
179 fContainer
= container
;
181 if (fContainer
!= NULL
)
182 fContainer
->AcquireReference();
186 fNode
->SetContainer(fContainer
);
191 ValueNodeChild::SetNode(ValueNode
* node
)
196 ValueNode
* oldNode
= fNode
;
197 BReference
<ValueNode
> oldNodeReference(oldNode
, true);
200 fNode
->SetContainer(NULL
);
205 fNode
->AcquireReference();
206 fNode
->SetContainer(fContainer
);
209 if (fContainer
!= NULL
)
210 fContainer
->NotifyValueNodeChanged(this, oldNode
, fNode
);
215 ValueNodeChild::Location() const
222 ValueNodeChild::SetLocation(ValueLocation
* location
, status_t resolutionState
)
224 if (fLocation
!= location
) {
225 if (fLocation
!= NULL
)
226 fLocation
->ReleaseReference();
228 fLocation
= location
;
230 if (fLocation
!= NULL
)
231 fLocation
->AcquireReference();
234 fLocationResolutionState
= resolutionState
;
238 // #pragma mark - ChildlessValueNode
241 ChildlessValueNode::ChildlessValueNode(ValueNodeChild
* nodeChild
)
245 fChildrenCreated
= true;
250 ChildlessValueNode::CreateChildren(TeamTypeInformation
* info
)
256 ChildlessValueNode::CountChildren() const
263 ChildlessValueNode::ChildAt(int32 index
) const