From a1e0dc13df3cdc7033c940f0f3311a2bd47d3b2e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Feb 2010 23:10:29 +0000 Subject: tweak Stateful/StatefulDiffCommand changes so that SessionObject's actually get a name; make StatefulDiffCommand use a weak_ptr, not a raw ptr; use .val() rather than .get() to avoid confusion with boost:: smart ptr method of the same name git-svn-id: svn://localhost/ardour2/branches/3.0@6678 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/pbd/pbd/stateful.h | 16 +++++++++------- libs/pbd/pbd/stateful_diff_command.h | 13 ++++++++++--- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'libs/pbd/pbd') diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h index 5d3c98439c..02224bb5e1 100644 --- a/libs/pbd/pbd/stateful.h +++ b/libs/pbd/pbd/stateful.h @@ -99,20 +99,20 @@ public: set (_current + v); return _current; } - - bool operator== (std::string const & o) const { - return o == to_string (_current); + + bool operator== (const T& other) const { + return _current == other; } - bool operator!= (std::string const & o) const { - return o != to_string (_current); + bool operator!= (const T& other) const { + return _current != other; } operator T const & () const { return _current; } - T const & get () const { + T const & val () const { return _current; } @@ -165,7 +165,7 @@ protected: template std::ostream& operator<< (std::ostream& os, StateTemplate const & s) { - os << s.get(); + os << s.val(); return os; } @@ -190,6 +190,7 @@ public: private: std::string to_string (T const & v) const { std::stringstream s; + s.precision (12); // in case its floating point s << v; return s.str (); } @@ -197,6 +198,7 @@ private: T from_string (std::string const & s) const { std::stringstream t (s); T v; + t.precision (12); // in case its floating point t >> v; return v; } diff --git a/libs/pbd/pbd/stateful_diff_command.h b/libs/pbd/pbd/stateful_diff_command.h index 41c0c70f69..43efed445d 100644 --- a/libs/pbd/pbd/stateful_diff_command.h +++ b/libs/pbd/pbd/stateful_diff_command.h @@ -17,6 +17,11 @@ */ +#ifndef __pbd_stateful_diff_command_h__ +#define __pbd_stateful_diff_command_h__ + +#include +#include #include "pbd/command.h" namespace PBD @@ -30,8 +35,8 @@ class Stateful; class StatefulDiffCommand : public Command { public: - StatefulDiffCommand (Stateful *); - StatefulDiffCommand (Stateful *, XMLNode const &); + StatefulDiffCommand (boost::shared_ptr); + StatefulDiffCommand (boost::shared_ptr, XMLNode const &); ~StatefulDiffCommand (); void operator() (); @@ -40,9 +45,11 @@ public: XMLNode& get_state (); private: - Stateful* _object; ///< the object in question + boost::weak_ptr _object; ///< the object in question XMLNode* _before; ///< XML node containing the previous values of XML properties which changed XMLNode* _after; ///< XML node containing the new values of XML properties which changed }; }; + +#endif /* __pbd_stateful_diff_command_h__ */ -- cgit v1.2.3