Next: , Previous: Interface overview, Up: Interface reference



8.2.2 Composite interface

The composite interface is an interface for non-leaf nodes with more children. It does not have any interesting public methods.

Every object implementing the composite interface must also implement the object interface, the node interface and the container interface. There is one exception – a composite object which has only dead children does not have to support the container interface.

Tree examining methods

There are four private methods needed to implement the down-propagation. They have self-descriptive names. They are based on callbacks – the caller calls vcl_composite_get_children, and a composite object answers with the execution of a callback for each child. The basic order is from front to back (the first answer gives the top child, the last answer is gives the bottom child), the _backwards method variants use the reversed order. Basic variants return all children, _in_bbox method variants are allowed (but not required) to ignore some children situated outside of the *wanted_bbox rectangle (in the children coordinate system).

This is the only place where using dead objects is allowed – a composite node can create dead objects just before the callback answer and free it (on the stack) just after that.

     void vcl_composite_get_children (void * obj, void (* cb)(void *, void * ),
                                      void * cb_data)
     
     void vcl_composite_get_children_backwards (void * obj,
                                      void (* cb)(void *, void * ),
                                      void * cb_data)
     
     void vcl_composite_get_children_in_bbox (void * obj,
                        const struct geom_rectangle * wanted_bbox,
                        void (* cb)(void *, void * ), void * cb_data)
     
     void vcl_composite_get_children_in_bbox_backwards (void * obj,
                        const struct geom_rectangle * wanted_bbox,
                        void (* cb)(void *, void * ), void * cb_data)