Elektra
0.8.7
|
Elektra provides a universal and secure framework to store configuration parameters in a global, hierarchical key database. The core is a small library implemented in C. The plugin-based framework fulfills many configuration-related tasks to avoid any unnecessary code duplication across applications while it still allows the core to stay without any external dependency. Elektra abstracts from cross-platform-related issues with an consistent API, and allows applications to be aware of other applications' configurations, leveraging easy application integration.
See the website for more information http://www.libelektra.org
This document occupies with the API implementation, documentation, internals and plugins. On the one hand it gives an overview and an introduction for developers using Elektra, on the other hand it gives an informal descriptions what methods must and may provide to allow an alternative implementation of the API.
The current version (for stable releases) of this document can be found at http://doc.libelektra.org/api/current/html
The latest version (from git master) of this document can be found at http://doc.libelektra.org/api/latest/html
A C or C++ source file that wants to use Elektra should include:
To link an executable with the Elektra library, the correct way is to use the pkg-config
tool:
The API was written in pure C because Elektra was designed to be useful even for the most basic system programs, which are all made in C. Also, being C, bindings to other languages can appear easily.
The API follows an Object Oriented design, and there are 3 main classes as shown by the figure:
Some general things you can do with each class are:
user/
or system/
key, etcThere are 2 trees of keys: system
and user
When using Elektra to store your application's configuration and state, please keep in mind the following rules:
system
or user
. They are reserved for more generic purposes.system/sw/MyApp/current
and user/sw/MyApp/current
system/sw/MyApp/profile
and user/sw/MyApp/profile
and then ksLookupByName() in /sw/MyApp/profile
while profile defaults to current, but may be changed by the user or admin. See Cascading to learn more about that feature.The core of elektra does not store configuration itself to the harddisk. Instead this work is delegated to backends.
If you want to develop a backend, you should already have some experience with Elektra from the user point of view. You should be familiar with the data structures: Key and KeySet Then you can start reading about Backends, which are composed out of Plugins.