diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-02-11 23:10:29 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-02-11 23:10:29 +0000 |
commit | a1e0dc13df3cdc7033c940f0f3311a2bd47d3b2e (patch) | |
tree | 72cf696511c00bb4dfc135f43f8c0ae0498140cf /libs/pbd/pbd | |
parent | f938687f8798d094c99cd4308ad6aa1c467e4a97 (diff) |
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
Diffstat (limited to 'libs/pbd/pbd')
-rw-r--r-- | libs/pbd/pbd/stateful.h | 16 | ||||
-rw-r--r-- | libs/pbd/pbd/stateful_diff_command.h | 13 |
2 files changed, 19 insertions, 10 deletions
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<class T> std::ostream& operator<< (std::ostream& os, StateTemplate<T> 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 <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> #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<Stateful>); + StatefulDiffCommand (boost::shared_ptr<Stateful>, XMLNode const &); ~StatefulDiffCommand (); void operator() (); @@ -40,9 +45,11 @@ public: XMLNode& get_state (); private: - Stateful* _object; ///< the object in question + boost::weak_ptr<Stateful> _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__ */ |