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 ); }
135 virtual void remove( T * 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 Exception class for "too many children": Attempt to add a child to a widget class that can't handle c...
bool hasChildren() const
Check if there are any children.
ChildrenList::iterator begin()
Return an iterator that points to the first child.
YChildrenRejector(T *containerParent)
Constructor.
T * lastChild()
Returns the last child or 0 if there is none.
ChildrenList::const_reverse_iterator rbegin() const
Return a reverse iterator that points to the last child.
bool empty() const
Check if the children list is empty, i.e.
ChildrenList::const_iterator begin() const
Return an iterator that points to the first child.
virtual void add(T *child)
Add a new child.
virtual ~YChildrenManager()
Destructor.
T * container() const
Returns the associated container, i.e.
ChildrenList::const_iterator end() const
Return an iterator that points after the last child.
ChildrenList::const_reverse_iterator rend() const
Return a reverse iterator that points before the first child.
Abstract base template class for children management, such as child widgets.
YChildrenManager(T *containerParent)
Constructor.
virtual void add(T *child)
Add a new child.
virtual void add(T *child)
Add a new child.
bool contains(T *child) const
Check if the children list contains the specified child.
Children manager that can handle one single child (rejecting any more).
Children manager that rejects all children.
void replace(T *newChild)
Replace the previous child (if any) with a new one.
ChildrenList::iterator end()
Return an iterator that points after the last child.
T * firstChild()
Returns the first child or 0 if there is none.
virtual void clear()
Remove all children.
int count() const
Returns the number of children.