TutCbSetFunction set the callback function
cb
callback to set function for
func
callback function to be used
TRUE
if successful, FALSE
otherwise.
None
TutCbSetFunction changes the callback function referenced by cb
to func
. It is useful for situations where the purpose of a callback has changed, but the need for the callback still exists. This capability eliminates the need to destroy and recreate a new callback just to change the purpose of the callback.
This function uses the generic callback function definition, so it is usually necessary to cast any type-specific callback function to the generic T_CB_FUNC for use with this function. This results in some loss of type checking, but greater flexibility.
The value provided for func
must not be NULL
.
This example creates a callback and then alternates between two functions for the callback function:
static void T_ENTRY time_change_cb_odd(dummy, data, arg) T_PTR dummy;/* always NULL */
T_TIME_CHANGE_CB_DATA data; T_CB_ARG arg; { T_CB_FUNC cb_func;
/* Forward declaration of the other callback function so the */
/* compiler will recognize this symbol */
extern T_TIME_CHANGE_CB_FUNC time_change_cb_even; TutOut("Time change odd callback called\n");/* Make sure the callback function is set properly. */
if (!TutCbGetFunction(data, &cb_func)) {/* error */
} if (cb_func != (T_CB_FUNC)time_change_cb_odd) {/* error */
} if (!TutCbSetFunction(data->cb, (T_CB_FUNC)time_change_cb_even)) {/* error */
} } static void T_ENTRY time_change_cb_even(dummy, data, arg) T_PTR dummy;/* always NULL */
T_TIME_CHANGE_CB_DATA data; T_CB_ARG arg; { T_CB_FUNC cb_func; TutOut("Time change even callback called\n");/* Make sure the callback function is set properly. */
if (!TutCbGetFunction(data, &cb_func)) {/* error */
} if (cb_func != (T_CB_FUNC)time_change_cb_even) {/* error */
} if (!TutCbSetFunction(data->cb, (T_CB_FUNC)time_change_cb_odd)) {/* error */
} } if (TutTimeChangeCbCreate(time_change_cb_even, NULL) == NULL) {/* error */
}
TIBCO SmartSockets™ Utilities Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |