diff options
author | Carl Hetherington <carl@carlh.net> | 2010-12-28 03:05:09 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-12-28 03:05:09 +0000 |
commit | 390f18c1152f2007b790a77c873b50ef48209f44 (patch) | |
tree | daef67f1a23a1ade1b4f4c3080fb1a6d234a4cbc /libs/pbd/pbd/properties.h | |
parent | fd0c45ec9745c5330fbb732581ec22ba9a31a3c0 (diff) |
Clarify commentary slightly. No functional changes.
git-svn-id: svn://localhost/ardour2/branches/3.0@8345 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/pbd/properties.h')
-rw-r--r-- | libs/pbd/pbd/properties.h | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/libs/pbd/pbd/properties.h b/libs/pbd/pbd/properties.h index ad9ed2f1f6..d961046760 100644 --- a/libs/pbd/pbd/properties.h +++ b/libs/pbd/pbd/properties.h @@ -33,8 +33,7 @@ namespace PBD { -/** Parent class for classes which represent a single scalar property in a Stateful object - */ +/** Parent class for classes which represent a single scalar property in a Stateful object */ template<class T> class PropertyTemplate : public PropertyBase { @@ -58,6 +57,9 @@ public: , _current (s._current) {} + + /* OPERATORS / ACCESSORS */ + T & operator=(T const& v) { set (v); return _current; @@ -93,16 +95,9 @@ public: return _current; } - void clear_changes () { - _have_old = false; - } - - void get_changes_as_xml (XMLNode* history_node) const { - XMLNode* node = history_node->add_child (property_name()); - node->add_property ("from", to_string (_old)); - node->add_property ("to", to_string (_current)); - } + /* MANAGEMENT OF Stateful State */ + bool set_value (XMLNode const & node) { XMLProperty const* p = node.property (property_name()); @@ -123,27 +118,46 @@ public: node.add_property (property_name(), to_string (_current)); } - bool changed () const { return _have_old; } - void apply_changes (PropertyBase const * p) { - T v = dynamic_cast<const PropertyTemplate<T>* > (p)->val (); - if (v != _current) { - set (v); - } + /* MANAGEMENT OF HISTORY */ + + void clear_changes () { + _have_old = false; } + bool changed () const { return _have_old; } + void invert () { T const tmp = _current; _current = _old; _old = tmp; } + + /* TRANSFERRING HISTORY TO / FROM A StatefulDiffCommand */ + + void get_changes_as_xml (XMLNode* history_node) const { + XMLNode* node = history_node->add_child (property_name()); + node->add_property ("from", to_string (_old)); + node->add_property ("to", to_string (_current)); + } + void get_changes_as_properties (PropertyList& changes, Command *) const { if (this->_have_old) { changes.add (clone ()); } } + + /* VARIOUS */ + + void apply_changes (PropertyBase const * p) { + T v = dynamic_cast<const PropertyTemplate<T>* > (p)->val (); + if (v != _current) { + set (v); + } + } + protected: void set (T const& v) { |