Debugger: Split into core library and application.
[haiku.git] / headers / private / debugger / settings / generic / Setting.h
blobbaa88039575b10567a4c5de0a3ad8b03babe5970
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2011-2013, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef SETTING_H
7 #define SETTING_H
10 #include <String.h>
12 #include <ObjectList.h>
13 #include <Referenceable.h>
14 #include <Variant.h>
17 enum setting_type {
18 SETTING_TYPE_BOOL,
19 SETTING_TYPE_FLOAT,
20 SETTING_TYPE_OPTIONS,
21 SETTING_TYPE_BOUNDED,
22 SETTING_TYPE_RANGE,
23 SETTING_TYPE_RECT
27 class Setting : public BReferenceable {
28 public:
29 virtual ~Setting();
31 virtual setting_type Type() const = 0;
32 virtual const char* ID() const = 0;
33 virtual const char* Name() const = 0;
35 virtual BVariant DefaultValue() const = 0;
39 class BoolSetting : public virtual Setting {
40 public:
41 virtual setting_type Type() const;
43 virtual BVariant DefaultValue() const;
45 virtual bool DefaultBoolValue() const = 0;
49 class FloatSetting : public virtual Setting {
50 public:
51 virtual setting_type Type() const;
53 virtual BVariant DefaultValue() const;
55 virtual float DefaultFloatValue() const = 0;
59 class SettingsOption : public BReferenceable {
60 public:
61 virtual ~SettingsOption();
63 virtual const char* ID() const = 0;
64 virtual const char* Name() const = 0;
68 class OptionsSetting : public virtual Setting {
69 public:
70 virtual setting_type Type() const;
72 virtual BVariant DefaultValue() const;
74 virtual int32 CountOptions() const = 0;
75 virtual SettingsOption* OptionAt(int32 index) const = 0;
76 virtual SettingsOption* OptionByID(const char* id) const = 0;
78 virtual SettingsOption* DefaultOption() const = 0;
82 class BoundedSetting : public virtual Setting {
83 public:
84 virtual setting_type Type() const;
86 virtual BVariant LowerBound() const = 0;
87 virtual BVariant UpperBound() const = 0;
91 class RangeSetting : public virtual BoundedSetting {
92 virtual setting_type Type() const;
94 virtual BVariant LowerValue() const = 0;
95 virtual BVariant UpperValue() const = 0;
99 class RectSetting : public virtual Setting {
100 public:
101 virtual setting_type Type() const;
103 virtual BVariant DefaultValue() const;
105 virtual BRect DefaultRectValue() const = 0;
109 class AbstractSetting : public virtual Setting {
110 public:
111 AbstractSetting(const BString& id,
112 const BString& name);
114 virtual const char* ID() const;
115 virtual const char* Name() const;
117 private:
118 BString fID;
119 BString fName;
123 class BoolSettingImpl : public AbstractSetting, public BoolSetting {
124 public:
125 BoolSettingImpl(const BString& id,
126 const BString& name, bool defaultValue);
128 virtual bool DefaultBoolValue() const;
130 private:
131 bool fDefaultValue;
135 class FloatSettingImpl : public AbstractSetting, public FloatSetting {
136 public:
137 FloatSettingImpl(const BString& id,
138 const BString& name, float defaultValue);
140 virtual float DefaultFloatValue() const;
142 private:
143 float fDefaultValue;
147 class OptionsSettingImpl : public AbstractSetting, public OptionsSetting {
148 public:
149 OptionsSettingImpl(const BString& id,
150 const BString& name);
151 virtual ~OptionsSettingImpl();
153 virtual SettingsOption* DefaultOption() const;
155 virtual int32 CountOptions() const;
156 virtual SettingsOption* OptionAt(int32 index) const;
157 virtual SettingsOption* OptionByID(const char* id) const;
159 bool AddOption(SettingsOption* option);
160 bool AddOption(const BString& id,
161 const BString& name);
163 void SetDefaultOption(SettingsOption* option);
165 private:
166 class Option;
168 typedef BObjectList<SettingsOption> OptionList;
170 private:
171 OptionList fOptions;
172 SettingsOption* fDefaultOption;
176 class BoundedSettingImpl : public AbstractSetting, public BoundedSetting {
177 public:
178 BoundedSettingImpl(const BString& id,
179 const BString& name,
180 const BVariant& lowerBound,
181 const BVariant& upperBound,
182 const BVariant& defaultValue);
184 virtual BVariant DefaultValue() const;
186 virtual BVariant LowerBound() const;
187 virtual BVariant UpperBound() const;
189 private:
190 BVariant fLowerBound;
191 BVariant fUpperBound;
192 BVariant fDefaultValue;
196 class RangeSettingImpl : public AbstractSetting, public RangeSetting {
197 public:
198 RangeSettingImpl(const BString& id,
199 const BString& name,
200 const BVariant& lowerBound,
201 const BVariant& upperBound,
202 const BVariant& lowerValue,
203 const BVariant& upperValue);
205 virtual BVariant DefaultValue() const;
207 virtual BVariant LowerBound() const;
208 virtual BVariant UpperBound() const;
209 virtual BVariant LowerValue() const;
210 virtual BVariant UpperValue() const;
212 private:
213 BVariant fLowerBound;
214 BVariant fUpperBound;
215 BVariant fLowerValue;
216 BVariant fUpperValue;
220 class RectSettingImpl : public AbstractSetting, public RectSetting {
221 public:
222 RectSettingImpl(const BString& id,
223 const BString& name,
224 const BRect& defaultValue);
226 virtual BRect DefaultRectValue() const;
228 private:
229 BRect fDefaultValue;
233 #endif // SETTING_H