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::const_iterator
begin()
const 77 {
return _children.begin(); }
82 typename ChildrenList::const_iterator
end()
const 83 {
return _children.end(); }
88 typename ChildrenList::const_reverse_iterator
rbegin()
const 89 {
return _children.rbegin(); }
94 typename ChildrenList::const_reverse_iterator
rend()
const 95 {
return _children.rend(); }
102 {
return _children.empty() ? (T *) 0 : _children.front(); }
108 {
return _children.empty() ? (T *) 0 : _children.back(); }
116 virtual void add( T * child )
117 { _children.push_back( child ); }
123 virtual void remove( T * child )
124 { _children.remove( child ); }
131 { _children.clear(); }
140 return ( find( _children.begin(), _children.end(), child )
141 != _children.end() );
153 ChildrenList _children;
177 virtual void add( T * child )
180 this->_children.push_back( child );
190 this->_children.clear();
191 this->_children.push_back( newChild );
220 virtual void add( T * child )
225 #endif // YChildrenManager_h Exception class for "too many children": Attempt to add a child to a widget class that can't handle c...
YChildrenRejector(T *containerParent)
Constructor.
T * lastChild()
Returns the last child or 0 if there is none.
int count() const
Returns the number of children.
T * container() const
Returns the associated container, i.e.
virtual void add(T *child)
Add a new child.
virtual ~YChildrenManager()
Destructor.
ChildrenList::const_iterator end() const
Return an iterator that points after the last 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.
bool hasChildren() const
Check if there are any children.
Children manager that can handle one single child (rejecting any more).
bool empty() const
Check if the children list is empty, i.e.
Children manager that rejects all children.
void replace(T *newChild)
Replace the previous child (if any) with a new one.
T * firstChild()
Returns the first child or 0 if there is none.
virtual void clear()
Remove all children.
ChildrenList::const_iterator begin() const
Return an iterator that points to the first child.
ChildrenList::const_reverse_iterator rend() const
Return a reverse iterator that points before the first child.
ChildrenList::const_reverse_iterator rbegin() const
Return a reverse iterator that points to the last child.