|
Elektra 0.8.26
|
Notification feature. More...
Files | |
| file | kdbnotification.h |
| Elektra-Notification structures and declarations for application developers. | |
| file | kdbnotificationinternal.h |
| Elektra-Notification structures and declarations for developing notification and transport plugins. | |
Typedefs | |
| typedef void(* | ElektraNotificationConversionErrorCallback) (Key *key, void *context) |
| Callback function called when string to number conversion failed. | |
| typedef void(* | ElektraNotificationChangeCallback) (Key *key, void *context) |
| Callback function for key changes. | |
Functions | |
| int | elektraNotificationOpen (KDB *kdb) |
| Initialize the notification system for the given KDB instance. | |
| int | elektraNotificationClose (KDB *kdb) |
| Stop the notification system for the given KDB instance. | |
| int | elektraNotificationRegisterCallback (KDB *kdb, Key *key, ElektraNotificationChangeCallback callback, void *context) |
| Subscribe for updates via callback when a given key value is changed. | |
| int | elektraNotificationRegisterCallbackSameOrBelow (KDB *kdb, Key *key, ElektraNotificationChangeCallback callback, void *context) |
| Subscribe for updates via callback when a given key or a key below changed. | |
| ELEKTRA_NOTIFICATION_REGISTER_SIGNATURE (int, Int) | |
| Subscribe for automatic updates to a given variable when the given key value is changed. | |
Notification feature.
For an introduction to notifications please see the Notification Tutorial.
Examples:
elektraNotificationOpen() loads and mounts the internalnotification plugin globally at run-time. The key database is not altered permanently. elektraNotificationClose() reverts the mounting.
The internalnotification plugin is mounted at its defined positions (see its plugin docs).
Notification transport plugins (or simply transport plugins) export "openNotification" (ElektraNotificationOpenNotification()) and optionally "closeNotification" (ElektraNotificationCloseNotification()) functions as part of their contract.
The function "openNotification" is called during elektraNotificationOpen(). At this point an I/O binding is set and it is save to use it. If no binding is set despite the plugin requires it, it should log a message and perform no additional operations. This ensures that the plugin can be used in applications that do not use I/O bindings or notification features.
ElektraNotificationOpenNotification() receives a callback and additional data. When a key change notification is received (or a change is detected by other means) this callback shall be called with the changed Key and the additional data.
| typedef void(* ElektraNotificationChangeCallback) (Key *key, void *context) |
Callback function for key changes.
| Key | changed key |
| context | user supplied callback context |
| typedef void(* ElektraNotificationConversionErrorCallback) (Key *key, void *context) |
Callback function called when string to number conversion failed.
| Key | key with invalid value |
| context | user supplied callback context |
| ELEKTRA_NOTIFICATION_REGISTER_SIGNATURE | ( | int | , |
| Int | ) |
Subscribe for automatic updates to a given variable when the given key value is changed.
On kdbGet iff the key is present and its content is valid, the registered variable is updated.
| handle | plugin handle |
| Key | key to watch for changes |
| variable | variable |
| 1 | on success |
| 0 | on failure |
| int elektraNotificationClose | ( | KDB * | kdb | ) |
Stop the notification system for the given KDB instance.
May only be called after elektraNotificationOpen() was called for given KDB instance.
| kdb | KDB instance |
| 1 | on success |
| 0 | on error |
| int elektraNotificationOpen | ( | KDB * | kdb | ) |
Initialize the notification system for the given KDB instance.
Asynchronous receiving of notifications requires an I/O binding. Use elektraIoSetBinding() before calling this function.
May only be called once for a KDB instance. Subsequent calls return 0.
| kdb | KDB instance |
| 1 | on success |
| 0 | on error |
| int elektraNotificationRegisterCallback | ( | KDB * | kdb, |
| Key * | key, | ||
| ElektraNotificationChangeCallback | callback, | ||
| void * | context ) |
Subscribe for updates via callback when a given key value is changed.
| handle | plugin handle |
| Key | key to watch for changes |
| callback | callback function |
| context | user supplied context passed to callback function |
| 1 | on success |
| 0 | on failure |
| int elektraNotificationRegisterCallbackSameOrBelow | ( | KDB * | kdb, |
| Key * | key, | ||
| ElektraNotificationChangeCallback | callback, | ||
| void * | context ) |
Subscribe for updates via callback when a given key or a key below changed.
| handle | plugin handle |
| Key | key to watch for changes |
| callback | callback function |
| context | user supplied context passed to callback function |
| 1 | on success |
| 0 | on failure |