Debian Codegraph @

docs/DESIGN.kconfig

raw
1 kconfigdata_p.h contains definitions of the data formats used by kconfig.
2
3 Configuration entries are stored as "KEntry". They are indexed with "KEntryKey".
4 The primary store is a "KEntryMap" which is defined as a std::map from "KEntryKey"
5 to "KEntry"
6
7 KEntry's are stored in order in the KEntryMap. The most significant sort
8 criteria is mGroup. This means that all entries who belong in the same group,
9 are grouped in the std::map as well.
10
11 The start of a group is indicated with a KEntryKey with an empty mKey and a
12 dummy KEntry. This allows us to search for the start of the group and then to
13 iterate until we end up in another group. That way we will find all entries
14 of a certain group.
15
16 Entries that are localised with the _current_ locale are stored with bLocal
17 set to true. Entries that are localised with another locale are either not
18 stored at all (default), or with the localization as part of the key (when
19 reading a file in order to merge it).
20 [WABA: Does it make sense to keep both localized and non-localised around?
21 Can't we just let the localised version override the non-localised version?]
22
23 Currently the localization bit is the least significant sort criteria, that
24 means that the localised version always follows the non-localised version
25 immediately.
26
27 <Changed for KDE 3.0>
28 Entries that are being read from a location other than the location to
29 which is written back are marked as "default" and will be added both as
30 normal entry as well as an entry with the key marked as default.
31
32 When entries are written to disk, it is checked whether the entry to write
33 is equal to the default, if so the entry will not be written. The default
34 entry always follows directly after the normal entry, due to the sorting.
35 (After that the localised version follows)
36
37 When entries are written to disk, it is checked whether the entry to write
38 is equal to the default, if so the entry will not be written.
39 </Changed>
40
41 Open question:
42 Should unmodified entries that are written back be compared with the default
43 too? This seems to be mostly a transition issue.
44
45 <Changed during KDE 3.0 / 3.2>
46 Extra functions:
47
48 bool isEntryImmutable(key); // Can entry be modified?
49 bool hasDefault(key); // Is there a system wide default set for the entry?
50 void revertToDefault(key); // Restore to default
51 void deleteEntry(key); // Remove entry
52
53 Note that there is a subtle difference between revertToDefault() and deleteEntry().
54 revertToDefault() will change the entry to the default value set by the system
55 administrator (Via e.g. $KDEDIR/share/config) or, if no such default was set,
56 non-existent.
57 deleteEntry() will make the entry non-existent.
58
59 Entries are marked "immutable" if the key is followed by [$i]. This means
60 that a user can not override these entries.
61
62 Entries can be marked as deleted if they are followed by [$d]. This
63 is needed if the system administrator has specified a default value but the
64 entry was deleted (made 'non-existant'). In that case we can't just leave
65 the entry out since that would mean we get the default from the system
66 administrator back the next time we read the file.
67 </changed>
68
69 When an entry is read with readEntry(key, defaultValue), non-existing
70 entries will return "defaultValue" while hasKey(key) will return "false"
71 for such entries.
72
73 Currently all entries are stored in memory. When KConfig is "sync()'ed"
74 it reads the file that it is about to overwrite (for the second time), it
75 then merges in the entries it has in memory and writes the result back to
76 the file. It does NOT update its map of entries in memory with the entries
77 (re)read from disk. It only updates the entries in memory when
78 "reparseConfiguration()" is called.
79
80
81 Open Question: The standard writeEntry() function returns the original value,
82 is this needed? Nobody seems to use it.
83
84 Open Question: The bPersistent flag doesn't seem to be used... could it be removed?
85
86 Open Question: Is the bNLS flag needed? Localised entries seem to be mostly
87 useful for default files, are they ever created by the user itself?
88
89 Open Question: Would it be worthwhile to lock a user option that is equal to the
90 default so that it doesn't change when the default changes?
91
92
93 KDE3.0 Changes
94 ==============
95
96 *) writeEntry now returns void instead of QString.
97 *) deleteEntry functions added
98
99
100 ------------------------------------------------------------------------------
101
102 KConfig XT
103 ==========
104
105 My buzzword picker offered KConfig XT ("eXtended Technology") and KConfig NG
106 ("Next Generation"). Since the planned changes are meant to be evolutionary
107 rather than revolutionary, KConfig NG was dropped.
108
109 Goals
110 =====
111
112 * Have the default value for config entries defined in 1 place. Currently it is
113 not uncommon to have them defined in three places:
114 1) In the application that reads the setting in order to use it
115 2) In the settings dialog when reading the setting
116 3) In the settings dialog when selecting "Use defaults".
117
118 * Provide type-information about config entries to facilitate "KConfEdit" like
119 tools. Ideally type-information also includes range-information; this is even
120 mandatory if enums become an explicit type.
121
122 * Facilitate the documentation of config entries.
123
124
125 Instead of relying on the defaults that are hard-coded in the application,
126 rely on default configuration files being installed in $KDEDIR. The technical
127 changes required for this are very minimal, it is mostly a change in policy.
128
129 Type information can be provide by preceding every entry with a formalized
130 comment.
131
132 Work to be done:
133 * KConfig needs to be extended to provide access to the default values provided
134 by the default config files. KConfig already stores this information internally.
135 (DONE)
136 * A formal comment structure needs to be designed that can convey type-information.
137 Preferably in such a way that it is easily parsable by both machine and user.
138 * KConfig needs to be extended, or another class created, that is able to parse
139 the formalized comments.
140 * A tool needs to be developed that can assist developers with the generation
141 and verification of default configuration files including type-information.
142
143 Drawbacks:
144 * We rely on default configuration files being properly installed.
145 * The user can break applications by making improper modifications to these
146 files.
147 * It is not possible to store defaults settings in a config file that are
148 of a dynamic nature. Examples are settings derived from other settings,
149 e.g. a color setting could be derived from the current color theme, or
150 e.g. the default high score user name which is determined by the user
151 currently logged in.
152
153
154 Some random ideas:
155 * The format of the entries would be something like this:
156
157 [Mail Settings]
158 #!Type=string
159 #!Description=SMTP server to use for sending mail
160 #!Description[nl]=SMTP server voor het versturen van mail
161 Host=wantelbos.zogje.fr
162
163 - the type could be subclassed more, e.g. strings can be "email", "hostname",
164 "url", etc.
165
166 - having translations in these files is very arguable. external po's would be
167 better.
168
169
170
171 Class overview
172
173 KConfigBase
174 |
175 v
176 KConfigBackend <-----> KConfig <------> KConfigSkeleton /--< myapp.kcfg
177 | | | /
178 v v |*---------------<
179 KConfigINIBackend KSimpleConfig |kconfig_compiler \
180 | \--< myconfig.kcfg-codegen
181 v
182 MyConfig <-----KConfigDialogManager----> MyConfigWidget *---< myconfigwidget.ui
183 uic
184
185 KConfigBase: defines API for generic config class
186
187 KConfig: functional generic config class that supports merging of cascaded
188 configuration files
189
190 KSimpleConfig: functional generic config class without support for cascading
191 configuration files.
192
193 KConfigBackend: defines API for config backend, t.i. the actual handling
194 of the storage method and storage format.
195
196 KConfigINIBackend: the standard (and only one so far) class that implements
197 the config backend using the file-based .INI format
198 for configuration files
199
200 KConfigSkeleton: base class for deriving classes that store application
201 specific options providing type-safety and single-point
202 defaults.
203
204 MyConfig: An application specific class that offers configuration options
205 to the applications via variables or accessor functions and that
206 handles type-safety and defaults. MyConfig is just an example
207 name, the application developer choses the actual name.
208
209 myapp.kcfg: File describing the configuration options used by a specific
210 application. myapp.kcfg is just an example name, the application
211 developer choses the actual name.
212
213 myconfig.kcfg-codegen: Implementation specific code generation instructions
214 for the MyConfig class. myconfig.kcfg-codegen is
215 just an example name, the application developer
216 choses the actual name.
217
218 KConfigDialogManager: Class that links widgets in a dialog up with their
219 corresponding configuration options in a configuration
220 object derived from KConfigSkeleton.
221
222 MyConfigWidget: Dialog generated from a .ui description file. Widget names
223 in the dialog that start with "kcfg_" refer to configuration
224 options.