25 #ifndef YChildrenManager_h
26 #define YChildrenManager_h
30 #include "YUIException.h"
47 : _container( containerParent )
56 typedef std::list<T *> ChildrenList;
66 bool empty()
const {
return _children.empty(); }
71 int count()
const {
return _children.size(); }
76 typename ChildrenList::iterator
begin()
77 {
return _children.begin(); }
82 typename ChildrenList::iterator
end()
83 {
return _children.end(); }
88 typename ChildrenList::const_iterator
begin()
const
89 {
return _children.begin(); }
94 typename ChildrenList::const_iterator
end()
const
95 {
return _children.end(); }
100 typename ChildrenList::const_reverse_iterator
rbegin()
const
101 {
return _children.rbegin(); }
106 typename ChildrenList::const_reverse_iterator
rend()
const
107 {
return _children.rend(); }
114 {
return _children.empty() ? (T *) 0 : _children.front(); }
120 {
return _children.empty() ? (T *) 0 : _children.back(); }
128 virtual void add( T * child )
129 { _children.push_back( child ); }
136 { _children.remove( child ); }
143 { _children.clear(); }
152 return ( find( _children.begin(), _children.end(), child )
153 != _children.end() );
165 ChildrenList _children;
189 virtual void add( T * child )
192 this->_children.push_back( child );
202 this->_children.clear();
203 this->_children.push_back( newChild );
232 virtual void add( T * child )
237 #endif // YChildrenManager_h
YChildrenRejector(T *containerParent)
Constructor.
YChildrenManager(T *containerParent)
Constructor.
ChildrenList::const_iterator end() const
Return an iterator that points after the last child.
Children manager that rejects all children.
Exception class for "too many children": Attempt to add a child to a widget class that can't handle c...
int count() const
Returns the number of children.
ChildrenList::const_iterator begin() const
Return an iterator that points to the first child.
virtual void add(T *child)
Add a new child.
bool hasChildren() const
Check if there are any children.
virtual void add(T *child)
Add a new child.
ChildrenList::const_reverse_iterator rbegin() const
Return a reverse iterator that points to the last child.
virtual void remove(T *child)
Remove a child.
virtual ~YChildrenManager()
Destructor.
ChildrenList::const_reverse_iterator rend() const
Return a reverse iterator that points before the first child.
ChildrenList::iterator begin()
Return an iterator that points to the first child.
virtual void add(T *child)
Add a new child.
ChildrenList::iterator end()
Return an iterator that points after the last child.
T * firstChild()
Returns the first child or 0 if there is none.
void replace(T *newChild)
Replace the previous child (if any) with a new one.
Children manager that can handle one single child (rejecting any more).
T * lastChild()
Returns the last child or 0 if there is none.
T * container() const
Returns the associated container, i.e.
bool contains(T *child) const
Check if the children list contains the specified child.
bool empty() const
Check if the children list is empty, i.e.
Abstract base template class for children management, such as child widgets.
virtual void clear()
Remove all children.