| Customize Help

Hooking to containers



You can hook a callback function to changes in a container using MbufHookFunction(). You can choose to hook to either the container itself, or to all components of the container individually (including components allocated in the future). For more information about hook-handler functions in general, see the Event handling in MIL with hook-handler functions section of Chapter 2: Building an application.

If you hook to the container itself, the callback function will be called after any MIL function that modifies at least one of its components, adds or removes a component, or uses the container as a destination (even if the container is not modified). Using MbufGetHookInfo() with M_MODIFIED_BUFFER within the callback function will return the identifier of the container. The callback function will never be called more than once for a single MIL function call.

If you hook to all components of the container (by specifying M_ON_COMPONENT), the callback function will be called after any MIL function that modifies one of those components (including allocating or freeing the component). Using MbufHookFunction() with M_MODIFIED_BUFFER within the callback function will return the identifier of the component. If a single function modifies multiple components of the container (for example, if the container is a destination for a 3D processing function that modifies or frees multiple components), the callback function will be called once for each modified component.

If you manually specify that a container has been modified (using MbufControlContainer() with M_MODIFIED), MIL will also call functions hooked to the container's components. If you do this for a child container, MIL will also call functions hooked to the parent container(s).