template<class ComponentDerived, class CompositeDerived, class ParenthoodInfo = NoInfo>
class ocra::Composite< ComponentDerived, CompositeDerived, ParenthoodInfo >
Base class for the Composite class of the Composite pattern.
See the wikipedia article about the Composite design pattern for more information.
- See also
- class ocra::Component
-
class ocra::Leaf
- Template Parameters
-
ComponentDerived | is the abstract type used to manipulate both nodes and leaves without knowledge of whether they are composite or not. |
CompositeDerived | is the type of the composite objects, i.e. objects that are composed of several subobjects. |
ParenthoodInfo | is an additional type to associate additional information with a parenthood relationship. It must be default constructible with a default constructor (it can be the one defined by the compiler). |
- Precondition
- CompositeDerived is a publicly derived class of ComponentDerived.
-
ParenthoodInfo is default constructible with a no-throw default constructor.
-
ComponentDerived publicly derives Component<ComponentDerived, CompositeDerived, ParenthoodInfo>.
-
CompositeDerived publicly derives Composite<ComponentDerived, CompositeDerived, ParenthoodInfo>.
The preconditions on the template parameters will be enforced at compile-time by the Parenthood class. If a BOOST_STATIC_ASSERT is fired when compiling your composite classes, please have a look at the name of the parameter of the failing assertion: it will give you a hint about how to correct your code.
Definition at line 38 of file Composite.h.
template<class ComponentDerived, class CompositeDerived, class ParenthoodInfo = NoInfo>
virtual CompositeDerived& ocra::Composite< ComponentDerived, CompositeDerived, ParenthoodInfo >::add |
( |
ComponentDerived & |
child | ) |
|
|
inlinevirtual |
Append and detach a child.
Default implementation forwards the call to the protected methods attach and detach; you can overload these methods to wrap attach and detach with precondition tests and additional operations.
Reimplemented in ocra::CompositeVariable.
Definition at line 677 of file Composite.h.
template<class ComponentDerived, class CompositeDerived, class ParenthoodInfo = NoInfo>
Default implementation of the callbacks, to overload in the private part of class CompositeDerived.
These callbacks are called once a parent and a child have been attached/detached. When the callback is called, the parenthood has already been registered/unregistered by the child and parent (this is guaranteed by the ocra::attach/ detach function).
Definition at line 689 of file Composite.h.