From 25ec63dbf549021ab04886bc960d771fcc2ef488 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 25 Nov 2016 18:03:23 -0500 Subject: [PATCH] libdebugger: Add string setting type. - Needed in order to properly implement a settings description for a remote interface. --- .../debugger/settings/generic/Setting.h | 28 +++++++++++++- .../debugger/settings/generic/Setting.cpp | 38 ++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/headers/private/debugger/settings/generic/Setting.h b/headers/private/debugger/settings/generic/Setting.h index baa8803957..3a1a1c2ddb 100644 --- a/headers/private/debugger/settings/generic/Setting.h +++ b/headers/private/debugger/settings/generic/Setting.h @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011-2013, Rene Gollent, rene@gollent.com. + * Copyright 2011-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef SETTING_H @@ -20,7 +20,8 @@ enum setting_type { SETTING_TYPE_OPTIONS, SETTING_TYPE_BOUNDED, SETTING_TYPE_RANGE, - SETTING_TYPE_RECT + SETTING_TYPE_RECT, + SETTING_TYPE_STRING }; @@ -106,6 +107,16 @@ public: }; +class StringSetting : public virtual Setting { +public: + virtual setting_type Type() const; + + virtual BVariant DefaultValue() const; + + virtual const BString& DefaultStringValue() const = 0; +}; + + class AbstractSetting : public virtual Setting { public: AbstractSetting(const BString& id, @@ -230,4 +241,17 @@ private: }; +class StringSettingImpl : public AbstractSetting, public StringSetting { +public: + StringSettingImpl(const BString& id, + const BString& name, + const BString& defaultValue); + + virtual const BString& DefaultStringValue() const; + +private: + BString fDefaultValue; +}; + + #endif // SETTING_H diff --git a/src/kits/debugger/settings/generic/Setting.cpp b/src/kits/debugger/settings/generic/Setting.cpp index 3213649dd9..440bae3c60 100644 --- a/src/kits/debugger/settings/generic/Setting.cpp +++ b/src/kits/debugger/settings/generic/Setting.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013, Rene Gollent, rene@gollent.com. + * Copyright 2013-2016, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -115,6 +115,23 @@ RectSetting::DefaultValue() const } +// #pragma mark - StringSetting + + +setting_type +StringSetting::Type() const +{ + return SETTING_TYPE_STRING; +} + + +BVariant +StringSetting::DefaultValue() const +{ + return DefaultStringValue().String(); +} + + // #pragma mark - AbstractSetting @@ -399,3 +416,22 @@ RectSettingImpl::DefaultRectValue() const { return fDefaultValue; } + + +// #pragma mark - StringSettingImpl + + +StringSettingImpl::StringSettingImpl(const BString& id, const BString& name, + const BString& defaultValue) + : + AbstractSetting(id, name), + fDefaultValue(defaultValue) +{ +} + + +const BString& +StringSettingImpl::DefaultStringValue() const +{ + return fDefaultValue; +}