conf_d.pl -- Load configuration directories
This module deals with loading configuration-files from a directory. This is pretty simple because we assume that configuration files are Prolog source-files. We (can) use file_search_path/2 to define one or more configuration directories.
Files are loaded in alphabetical order. If one config file requires another, there are two solutions:
- Use some numbering scheme, e.g., name the files 00-
prefixes.pl
, 01-paths.pl
, etc. - Use a use_module/1 call to include the config
file(s)
on which we depend.
- load_conf_d(+Spec, +Options) is det
- Locate configuration directories and load their config files.
Config files themselves are Prolog source files. Options:
- solutions(+Sols)
- Passed to absolute_file_name/3. Default is
all
, loading config files from all directories described by Spec. - extension(+Ext)
- File-name extension for the config files. Default is
pl
.
Other options are passed to load_files/2.
- keep_last(+PairsIn, -PairsOut) is det[private]
- PairsIn is a list Dir-Files holding Files to be loaded from Dir. We remove all files from Files that appear with a later directory.
- conf_d_enabled(-Dir) is nondet
- True if Dir is a directory from which config files are loaded.
- conf_d_reload is det
- Reload configuration files after adding or deleting config files. Note that this is not exactly the same as restarting the server. First of all, the order in which the files are loaded may be different and second, wiping a config file only wipes the clauses and module. Side effects, for example due to executed directives, are not reverted.
- conf_d_members(+Dir, -InfoRecords:list, Options) is det
- Provide information about config files in Dir.
- conf_d_member_data(?Field, +ConfigInfo, ?Value) is nondet
- True if Value is the value for Field in ConfigInfo. ConfigInfo
is an opaque term as returned by conf_d_info/3. Defined fields
are:
- file
- Absolute path of the file
- module
- Module defined in the file (can fail)
- title
- Comment-title (from /** <module> Title .. */)
- loaded
- Boolean, indicating whether the file is currently loaded.
- set_top_dir[private]
- Maintains a file search path
cp_application
to point to the directory from which the configuration is loaded. Normally, that is the directory holdingrun.pl
. - conf_d_configuration(+Available, +Enabled, -Configs) is det
- merge_pairlists(+PairLists, -Merged)[private]
- PairLists is a list of lists of K-V pairs. Merged is a K-VL
list, where each VL is a list of values on K in PairLists.
Missing values are returned as (-). For example:
?- merge_pairlists([ [a-1, d-4], [a-1, c-3], [b-2] ], Merged). Merged = [a-[1,1,-], b-[-,-,2], d-[4,-,-], c-[-,3,-]].