Callback functions are a concept that describes an architecture where a piece of core code makes calls to one or more functions that are application-specific. The concept is often used in user interface systems, where the application developer writes the callback functions, which define the functionality of the specific application. Frequently, the callback functions are invoked in response to events, such as specifc keystrokes or mouse events. The developer defines what happens when these events occur, thus determining the behavior of the application. It is a common API idiom that allows a clean separation of the core library from the application-specific code.
An easy way to see the architecure at work might be to use something like the Glade interface designer. Using the tool, a developer builds the look & feel of the application by dropping down screen widgets such as buttons, entry boxes, menus, etc. Then, a code template is generated, which contains empty callback functions. The developer fills in the details of the callback functions with application-specific code, and then builds the application. At runtime, the callbacks are invoked by the core user-interface code, in response to end-user generated events.
--- rod.
|