-
Notifications
You must be signed in to change notification settings - Fork 123
Global plugins: global keyset handle #2307
Changes from all commits
39d3bb7
01ad999
2e34920
1f47cb1
b6ef391
90e7797
a38087a
e376138
f1aed27
544782a
6275de2
cec434d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,7 +127,7 @@ compiled against an older 0.8 version of Elektra will continue to work | |
|
||
### Core | ||
|
||
- <<TODO>> | ||
- Global plugins now get a handle to a global keyset, which makes communication between global plugins easier. *(Mihael Pranjić)* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ", for communication between plugins"? |
||
- <<TODO>> | ||
- <<TODO>> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,6 +325,9 @@ struct _KDB | |
|
||
Plugin * notificationPlugin; /*!< reference to global plugin for notifications.*/ | ||
ElektraNotificationCallbackContext * notificationCallbackContext; /*!< reference to context for notification callbacks.*/ | ||
|
||
KeySet * global; /*!< This keyset can be used by global plugins and the resolver | ||
to pass data through the KDB and communicate with other global plugins.*/ | ||
}; | ||
|
||
|
||
|
@@ -413,6 +416,11 @@ struct _Plugin | |
|
||
void * data; /*!< This handle can be used for a plugin to store | ||
any data its want to. */ | ||
|
||
KeySet * global; /*!< This keyset can be used by global plugins and the resolver | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why special handling of resolver? |
||
to pass data through the KDB and communicate with other global plugins. | ||
Plugins shall clean up their parts of the global keyset, which | ||
they do not need any more.*/ | ||
}; | ||
|
||
|
||
|
@@ -587,9 +595,9 @@ int keyNameIsSystem (const char * keyname); | |
int keyNameIsUser (const char * keyname); | ||
|
||
/* global plugin calls */ | ||
void elektraGlobalGet (KDB * handle, KeySet * ks, Key * parentKey, int position, int subPosition); | ||
void elektraGlobalSet (KDB * handle, KeySet * ks, Key * parentKey, int position, int subPosition); | ||
void elektraGlobalError (KDB * handle, KeySet * ks, Key * parentKey, int position, int subPosition); | ||
int elektraGlobalGet (KDB * handle, KeySet * ks, Key * parentKey, int position, int subPosition); | ||
int elektraGlobalSet (KDB * handle, KeySet * ks, Key * parentKey, int position, int subPosition); | ||
int elektraGlobalError (KDB * handle, KeySet * ks, Key * parentKey, int position, int subPosition); | ||
|
||
/** Test a bit. @see set_bit(), clear_bit() */ | ||
#define test_bit(var, bit) ((var) & (bit)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,3 +140,21 @@ void * elektraPluginGetData (Plugin * plugin) | |
{ | ||
return plugin->data; | ||
} | ||
|
||
/** | ||
* @brief Get a pointer to the global keyset. | ||
* | ||
* Only initialized for global plugins and the resolver. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above |
||
* | ||
* Plugins using this keyset are responsible for cleaning up | ||
* their parts of the keyset which they do not need any more. | ||
* | ||
* If kdbOpen() was not called earlier, NULL will be returned. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this happen? |
||
* @param plugin a pointer to the plugin | ||
* @return a pointer to the global keyset | ||
* @ingroup plugin | ||
*/ | ||
KeySet * elektraPluginGetGlobalKeySet (Plugin * plugin) | ||
{ | ||
return plugin->global; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,20 @@ | |
* Note that you also need to return -1 in the case of error. | ||
* See individual description of entry points to implement below. | ||
* | ||
* @par Global KeySet Handle | ||
* | ||
* Global plugins and the resolver will get a handle to a global keyset. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When is it constructed and deleted? |
||
* This allows them to exchange information with other global plugins. | ||
* | ||
* Obtain a handle to the global keyset and work with it: | ||
* | ||
* @snippet doc.c get global keyset | ||
* | ||
* Clean up keys which you do not need any more, | ||
* to keep the global keyset compact: | ||
* | ||
* @snippet doc.c get global keyset cleanup | ||
* | ||
* @par Further help | ||
* Do not hesitate to open an issue if anything | ||
* is unclear. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not every plugin?