2 * Copyright 2013, Rene Gollent, rene@gollent.com.
3 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
13 #include <ObjectList.h>
14 #include <Referenceable.h>
20 class SettingsDescription
;
23 class Settings
: public BReferenceable
{
28 Settings(SettingsDescription
* description
);
33 bool Lock() { return fLock
.Lock(); }
34 void Unlock() { fLock
.Unlock(); }
36 SettingsDescription
* Description() const { return fDescription
; }
37 const BMessage
& Message() const { return fValues
; }
39 BVariant
Value(Setting
* setting
) const;
40 BVariant
Value(const char* settingID
) const;
41 bool SetValue(Setting
* setting
,
42 const BVariant
& value
);
44 bool RestoreValues(const BMessage
& message
);
46 bool BoolValue(BoolSetting
* setting
) const
47 { return Value(setting
).ToBool(); }
48 SettingsOption
* OptionValue(OptionsSetting
* setting
) const;
49 BVariant
RangeValue(RangeSetting
* setting
) const
50 { return Value(setting
); }
52 bool AddListener(Listener
* listener
);
53 void RemoveListener(Listener
* listener
);
56 typedef BObjectList
<Listener
> ListenerList
;
59 mutable BLocker fLock
;
60 SettingsDescription
* fDescription
;
62 ListenerList fListeners
;
66 class Settings::Listener
{
70 virtual void SettingValueChanged(Setting
* setting
) = 0;