2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef VALUE_NODE_CONTAINER_H
6 #define VALUE_NODE_CONTAINER_H
11 #include <ObjectList.h>
12 #include <Referenceable.h>
19 class ValueNodeContainer
: public BReferenceable
{
25 virtual ~ValueNodeContainer();
29 inline bool Lock() { return fLock
.Lock(); }
30 inline void Unlock() { fLock
.Unlock(); }
32 int32
CountChildren() const;
33 ValueNodeChild
* ChildAt(int32 index
) const;
34 bool AddChild(ValueNodeChild
* child
);
35 void RemoveChild(ValueNodeChild
* child
);
36 void RemoveAllChildren();
38 bool AddListener(Listener
* listener
);
39 void RemoveListener(Listener
* listener
);
41 // container must be locked
43 void NotifyValueNodeChanged(
44 ValueNodeChild
* nodeChild
,
45 ValueNode
* oldNode
, ValueNode
* newNode
);
46 void NotifyValueNodeChildrenCreated(ValueNode
* node
);
47 void NotifyValueNodeChildrenDeleted(ValueNode
* node
);
48 void NotifyValueNodeValueChanged(ValueNode
* node
);
51 typedef BObjectList
<ValueNodeChild
> NodeChildList
;
52 typedef BObjectList
<Listener
> ListenerList
;
56 NodeChildList fChildren
;
57 ListenerList fListeners
;
61 class ValueNodeContainer::Listener
{
65 // container is locked
67 virtual void ValueNodeChanged(ValueNodeChild
* nodeChild
,
68 ValueNode
* oldNode
, ValueNode
* newNode
);
69 virtual void ValueNodeChildrenCreated(ValueNode
* node
);
70 virtual void ValueNodeChildrenDeleted(ValueNode
* node
);
71 virtual void ValueNodeValueChanged(ValueNode
* node
);
75 #endif // VALUE_NODE_CONTAINER_H