Warning, /frameworks/kconfig/docs/DESIGN.kconfig is written in an unsupported language. File is not indexed.
0001 kconfigdata_p.h contains definitions of the data formats used by kconfig.
0002
0003 Configuration entries are stored as "KEntry". They are indexed with "KEntryKey".
0004 The primary store is a "KEntryMap" which is defined as a std::map from "KEntryKey"
0005 to "KEntry"
0006
0007 KEntry's are stored in order in the KEntryMap. The most significant sort
0008 criteria is mGroup. This means that all entries who belong in the same group,
0009 are grouped in the std::map as well.
0010
0011 The start of a group is indicated with a KEntryKey with an empty mKey and a
0012 dummy KEntry. This allows us to search for the start of the group and then to
0013 iterate until we end up in another group. That way we will find all entries
0014 of a certain group.
0015
0016 Entries that are localised with the _current_ locale are stored with bLocal
0017 set to true. Entries that are localised with another locale are either not
0018 stored at all (default), or with the localization as part of the key (when
0019 reading a file in order to merge it).
0020 [WABA: Does it make sense to keep both localized and non-localised around?
0021 Can't we just let the localised version override the non-localised version?]
0022
0023 Currently the localization bit is the least significant sort criteria, that
0024 means that the localised version always follows the non-localised version
0025 immediately.
0026
0027 <Changed for KDE 3.0>
0028 Entries that are being read from a location other than the location to
0029 which is written back are marked as "default" and will be added both as
0030 normal entry as well as an entry with the key marked as default.
0031
0032 When entries are written to disk, it is checked whether the entry to write
0033 is equal to the default, if so the entry will not be written. The default
0034 entry always follows directly after the normal entry, due to the sorting.
0035 (After that the localised version follows)
0036
0037 When entries are written to disk, it is checked whether the entry to write
0038 is equal to the default, if so the entry will not be written.
0039 </Changed>
0040
0041 Open question:
0042 Should unmodified entries that are written back be compared with the default
0043 too? This seems to be mostly a transition issue.
0044
0045 <Changed during KDE 3.0 / 3.2>
0046 Extra functions:
0047
0048 bool isEntryImmutable(key); // Can entry be modified?
0049 bool hasDefault(key); // Is there a system wide default set for the entry?
0050 void revertToDefault(key); // Restore to default
0051 void deleteEntry(key); // Remove entry
0052
0053 Note that there is a subtle difference between revertToDefault() and deleteEntry().
0054 revertToDefault() will change the entry to the default value set by the system
0055 administrator (Via e.g. $KDEDIR/share/config) or, if no such default was set,
0056 non-existent.
0057 deleteEntry() will make the entry non-existent.
0058
0059 Entries are marked "immutable" if the key is followed by [$i]. This means
0060 that a user can not override these entries.
0061
0062 Entries can be marked as deleted if they are followed by [$d]. This
0063 is needed if the system administrator has specified a default value but the
0064 entry was deleted (made 'non-existant'). In that case we can't just leave
0065 the entry out since that would mean we get the default from the system
0066 administrator back the next time we read the file.
0067 </changed>
0068
0069 When an entry is read with readEntry(key, defaultValue), non-existing
0070 entries will return "defaultValue" while hasKey(key) will return "false"
0071 for such entries.
0072
0073 Currently all entries are stored in memory. When KConfig is "sync()'ed"
0074 it reads the file that it is about to overwrite (for the second time), it
0075 then merges in the entries it has in memory and writes the result back to
0076 the file. It does NOT update its map of entries in memory with the entries
0077 (re)read from disk. It only updates the entries in memory when
0078 "reparseConfiguration()" is called.
0079
0080
0081 Open Question: The standard writeEntry() function returns the original value,
0082 is this needed? Nobody seems to use it.
0083
0084 Open Question: The bPersistent flag doesn't seem to be used... could it be removed?
0085
0086 Open Question: Is the bNLS flag needed? Localised entries seem to be mostly
0087 useful for default files, are they ever created by the user itself?
0088
0089 Open Question: Would it be worthwhile to lock a user option that is equal to the
0090 default so that it doesn't change when the default changes?
0091
0092
0093 KDE3.0 Changes
0094 ==============
0095
0096 *) writeEntry now returns void instead of QString.
0097 *) deleteEntry functions added
0098
0099
0100 ------------------------------------------------------------------------------
0101
0102 KConfig XT
0103 ==========
0104
0105 My buzzword picker offered KConfig XT ("eXtended Technology") and KConfig NG
0106 ("Next Generation"). Since the planned changes are meant to be evolutionary
0107 rather than revolutionary, KConfig NG was dropped.
0108
0109 Goals
0110 =====
0111
0112 * Have the default value for config entries defined in 1 place. Currently it is
0113 not uncommon to have them defined in three places:
0114 1) In the application that reads the setting in order to use it
0115 2) In the settings dialog when reading the setting
0116 3) In the settings dialog when selecting "Use defaults".
0117
0118 * Provide type-information about config entries to facilitate "KConfEdit" like
0119 tools. Ideally type-information also includes range-information; this is even
0120 mandatory if enums become an explicit type.
0121
0122 * Facilitate the documentation of config entries.
0123
0124
0125 Instead of relying on the defaults that are hard-coded in the application,
0126 rely on default configuration files being installed in $KDEDIR. The technical
0127 changes required for this are very minimal, it is mostly a change in policy.
0128
0129 Type information can be provide by preceding every entry with a formalized
0130 comment.
0131
0132 Work to be done:
0133 * KConfig needs to be extended to provide access to the default values provided
0134 by the default config files. KConfig already stores this information internally.
0135 (DONE)
0136 * A formal comment structure needs to be designed that can convey type-information.
0137 Preferably in such a way that it is easily parsable by both machine and user.
0138 * KConfig needs to be extended, or another class created, that is able to parse
0139 the formalized comments.
0140 * A tool needs to be developed that can assist developers with the generation
0141 and verification of default configuration files including type-information.
0142
0143 Drawbacks:
0144 * We rely on default configuration files being properly installed.
0145 * The user can break applications by making improper modifications to these
0146 files.
0147 * It is not possible to store defaults settings in a config file that are
0148 of a dynamic nature. Examples are settings derived from other settings,
0149 e.g. a color setting could be derived from the current color theme, or
0150 e.g. the default high score user name which is determined by the user
0151 currently logged in.
0152
0153
0154 Some random ideas:
0155 * The format of the entries would be something like this:
0156
0157 [Mail Settings]
0158 #!Type=string
0159 #!Description=SMTP server to use for sending mail
0160 #!Description[nl]=SMTP server voor het versturen van mail
0161 Host=wantelbos.zogje.fr
0162
0163 - the type could be subclassed more, e.g. strings can be "email", "hostname",
0164 "url", etc.
0165
0166 - having translations in these files is very arguable. external po's would be
0167 better.
0168
0169
0170
0171 Class overview
0172
0173 KConfigBase
0174 |
0175 v
0176 KConfigBackend <-----> KConfig <------> KConfigSkeleton /--< myapp.kcfg
0177 | | | /
0178 v v |*---------------<
0179 KConfigINIBackend KSimpleConfig |kconfig_compiler \
0180 | \--< myconfig.kcfg-codegen
0181 v
0182 MyConfig <-----KConfigDialogManager----> MyConfigWidget *---< myconfigwidget.ui
0183 uic
0184
0185 KConfigBase: defines API for generic config class
0186
0187 KConfig: functional generic config class that supports merging of cascaded
0188 configuration files
0189
0190 KSimpleConfig: functional generic config class without support for cascading
0191 configuration files.
0192
0193 KConfigBackend: defines API for config backend, t.i. the actual handling
0194 of the storage method and storage format.
0195
0196 KConfigINIBackend: the standard (and only one so far) class that implements
0197 the config backend using the file-based .INI format
0198 for configuration files
0199
0200 KConfigSkeleton: base class for deriving classes that store application
0201 specific options providing type-safety and single-point
0202 defaults.
0203
0204 MyConfig: An application specific class that offers configuration options
0205 to the applications via variables or accessor functions and that
0206 handles type-safety and defaults. MyConfig is just an example
0207 name, the application developer choses the actual name.
0208
0209 myapp.kcfg: File describing the configuration options used by a specific
0210 application. myapp.kcfg is just an example name, the application
0211 developer choses the actual name.
0212
0213 myconfig.kcfg-codegen: Implementation specific code generation instructions
0214 for the MyConfig class. myconfig.kcfg-codegen is
0215 just an example name, the application developer
0216 choses the actual name.
0217
0218 KConfigDialogManager: Class that links widgets in a dialog up with their
0219 corresponding configuration options in a configuration
0220 object derived from KConfigSkeleton.
0221
0222 MyConfigWidget: Dialog generated from a .ui description file. Widget names
0223 in the dialog that start with "kcfg_" refer to configuration
0224 options.