If a given component supports pre- and post-method invocation instrumentation,
also known as ``hooks'', their execution can be enabled or disabled at
runtime through the built-in _set_hooks method. For example,
given the following SIDL specification
package hooks version 1.0 { class Basics { /** * Basic illustration of hooks for static methods. */ static int aStaticMeth(in int i, out int o, inout int io); /** * Basic illustration of hooks for static methods. */ int aNonStaticMeth(in int i, out int o, inout int io); } }
which has a single static function and a member function for the
Basics class, the processes for enabling and disabling
execution of the implementation-specific hooks are
hooks_Basics obj; sidl_BaseInterface _ex = NULL; obj = hooks_Basics__create(&exception); SIDL_CHECK(exception); /* Enable hooks execution (enabled by default if hooks generated) */ /* ... for static methods */ hooks_Basics__set_hooks_static(TRUE, &_ex); SIDL_CHECK(exception); /* ... for non-static methods */ hooks_Basics__set_hooks(obj, TRUE, &_ex); SIDL_CHECK(exception); /* ...do something meaningful... */ /* Disable hooks execution */ /* ... for static methods */ hooks_Basics__set_hooks_static(FALSE, &_ex); SIDL_CHECK(exception); /* ... for non-static methods */ hooks_Basics__set_hooks(obj, FALSE, &_ex); SIDL_CHECK(exception); /* ...do something meaningful... */
It is important to keep in mind that the _set_hooks_static method must be used to enable/disable invocation of hooks for static methods and the _set_hooks method must be used for those of non-static methods. Also, Babel does not provide client access to the _pre and _post methods; therefore, they cannot be invoked directly. More information on the instrumentation process is provided in Subsection 6.4.5.