Make UEFI boot-platform build again
[haiku.git] / headers / private / debugger / settings / generic / Settings.h
blobb921702c1ea0543a8017daf666ae7a50c83f322c
1 /*
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.
5 */
6 #ifndef SETTINGS_H
7 #define SETTINGS_H
10 #include <Locker.h>
11 #include <Message.h>
13 #include <ObjectList.h>
14 #include <Referenceable.h>
15 #include <Variant.h>
17 #include "Setting.h"
20 class SettingsDescription;
23 class Settings : public BReferenceable {
24 public:
25 class Listener;
27 public:
28 Settings(SettingsDescription* description);
29 virtual ~Settings();
31 status_t Init();
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);
55 private:
56 typedef BObjectList<Listener> ListenerList;
58 private:
59 mutable BLocker fLock;
60 SettingsDescription* fDescription;
61 BMessage fValues;
62 ListenerList fListeners;
66 class Settings::Listener {
67 public:
68 virtual ~Listener();
70 virtual void SettingValueChanged(Setting* setting) = 0;
74 #endif // SETTINGS_H