This document gives a brief overview of the EiffelPreferences library.
Simply, preferences are name-value pairs. All preferences are descendants of the deferred class PREFERENCE, and therefore all inherit the common properties of name, value, default values and string representations. Common to all PREFERENCE objects is the notion of
manager. All preferences belong to a manager, which is a helper class used for organizational and hierarchical management of your applications preferences.
So, all preferences belong to a PREFERENCE_MANAGER. The manager itself belongs to a set of related PREFERENCES. In fact, when you create a new manager for a group of preferences you must provide a PREFERENCES object to the creation routine to indicate which set of preferences the new manager will be associated:
make (a_preferences: PREFERENCES; a_namespace: STRING)
-- New manager.
preferences_not_void: a_preferences /= Void
namespace_not_void: a_namespace /= Void
namespace_not_empty: not a_namespace.is_empty
has_preferences: preferences /= Void
inserted_in_preferences: preferences.has_manager (namespace)
has_namespace: namespace /= Void
namespace_valid: not a_namespace.is_empty
You can see in the post-condition inserted_in_preferences that indeed the PREFERENCES object will have the new manager in its list of managers.
For every group of preferences or configuration values you therefore wish to create for your project, you will need a corresponding PREFERENCES object. In general one PREFERENCES object should be sufficient for most applications, and will be the point of reference for all preference values in the entire application. This class may be initialized in a number of ways, depending on the specific configuration of your application. It will be used to create new managers, store default preference values, and handle the saving and retrieval of preference values to and from the underlying data store between sessions. In between sessions the preference name and value pairs are persisted to an underlying data store. This may be any imaginable datastore, such as a file, database or external storage device. Support for XML and the Windows Registry is provided in the library by default, but EiffelPreferences allows you to provide an implementation tailored to your specific needs (such as SQL database store).