From c1f2c201b0f6b93ad82cf9ffe0bd746e05264d21 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 2 Jun 2010 19:54:05 +0000 Subject: [PATCH] forward port ConfigVariable fix from 2.X git-svn-id: http://subversion.ardour.org/svn/ardour2/ardour2/branches/3.0@7216 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/configuration_variable.h | 38 +++++++++++++++++++++++++++++ libs/ardour/ardour/utils.h | 3 ++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/configuration_variable.h b/libs/ardour/ardour/configuration_variable.h index 9c9cf4463..ec02a86fc 100644 --- a/libs/ardour/ardour/configuration_variable.h +++ b/libs/ardour/ardour/configuration_variable.h @@ -25,6 +25,7 @@ #include "pbd/xml++.h" #include "ardour/types.h" +#include "ardour/utils.h" namespace ARDOUR { @@ -87,6 +88,43 @@ class ConfigVariable : public ConfigVariableBase T value; }; +template<> +class ConfigVariable : public ConfigVariableBase +{ + public: + + ConfigVariable (std::string str) : ConfigVariableBase (str), value (false) {} + ConfigVariable (std::string str, bool val) : ConfigVariableBase (str), value (val) {} + + bool get() const { + return value; + } + + std::string get_as_string () const { + std::ostringstream ss; + ss << value; + return ss.str (); + } + + virtual bool set (bool val) { + if (val == value) { + miss (); + return false; + } + value = val; + notify (); + return true; + } + + void set_from_string (std::string const & s) { + value = string_is_affirmative (s); + } + + protected: + virtual bool get_for_save() { return value; } + bool value; +}; + template class ConfigVariableWithMutation : public ConfigVariable { diff --git a/libs/ardour/ardour/utils.h b/libs/ardour/ardour/utils.h index e7e8f2b82..f4c7e585c 100644 --- a/libs/ardour/ardour/utils.h +++ b/libs/ardour/ardour/utils.h @@ -32,6 +32,8 @@ #include #endif +bool string_is_affirmative (const std::string&); + #include "ardour.h" class XMLNode; @@ -39,7 +41,6 @@ class XMLNode; Glib::ustring legalize_for_path (Glib::ustring str); XMLNode* find_named_node (const XMLNode& node, std::string name); std::string bool_as_string (bool); -bool string_is_affirmative (const std::string&); static inline float f_max(float x, float a) { x -= a; -- 2.11.4.GIT