On 3/22/2013 17:02, John Scipione wrote:
What if we provided a centralized database of key value pairs identified by UUIDs where applications could register and then later read back settings. We could even make a nice program to view this database, sort of like an editor for this "registry" of settings data, maybe we could call it regedit. :)
Well, aside from copy errors from the past... ;-)My thoughts were along the lines of a 'free' BSettings object per BApplication - accessible via be_settings.
The default settings path would be derived from the appsig (application/x-vnd.vendor-appname), so : ~/config/settings/vendor/appname/settings
The format would be inconsequential - but I prefer plain text - though a BMessage would be fine.
BWindow would gain two functions and maybe a new flag: void SavePosition(); void RestorePosition(); B_RESTORE_WINDOW_POSITIONThe BSettings object would have a concept of categories, each category resulting in a different file in the settings directory. You could also create a set of defaults - maybe even as a resource file - so BSettings can fall-back on the defaults and code will look as follows:
bool someSettings = be_settings->GetBool("someBooleanSetting", kSomeCategory);
And setting could happen without error checking be_settings->SetBool("someBooleanSetting", someSetting, kSomeCategory);The category is always last simply because I'm assuming we don't want to create two versions of each call... though that wouldn't bother me, honestly...
bool GetBool(const BString& setting) const;bool GetBool(const BString& category, const BString& setting) const;
bool BSettings :: GetBool (const BString& setting) const { return GetBool(kDefaultCategory, setting); } Or just be macros... #define _GET_SETTING_DEFAULT_CAT( TYPE, TYPENAME ) \TYPE BSettings::Get##TYPENAME## (const BString& setting) const\ return Get##TYPENAME##(kDefaultCategory, setting); }
_GET_SETTINGS_DEFAULT_CAT(bool, Bool); _GET_SETTINGS_DEFAULT_CAT(const BString&, String); _GET_SETTINGS_DEFAULT_CAT(int32, Int32); _GET_SETTINGS_DEFAULT_CAT(int64, Int64); _GET_SETTINGS_DEFAULT_CAT(float, Float); etc... Then again... I'm all about uniform solutions... --The loon