diff options
author | Carl Hetherington <carl@carlh.net> | 2012-01-20 18:02:43 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2012-01-20 18:02:43 +0000 |
commit | 3396a9a851180ef73c6af9c42fc63897bb965390 (patch) | |
tree | a6551979b48528e94ab9a8d663f9baeb14fc7bf2 /gtk2_ardour/gui_object.h | |
parent | d03d0363a469a98753a546570bda79f59cba405c (diff) |
Simplify GUIOBjectState a bit by just walking the XML
directly rather than maintaining internal data
structures.
git-svn-id: svn://localhost/ardour2/branches/3.0@11287 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/gui_object.h')
-rw-r--r-- | gtk2_ardour/gui_object.h | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/gtk2_ardour/gui_object.h b/gtk2_ardour/gui_object.h index 849665670f..3cbd85c171 100644 --- a/gtk2_ardour/gui_object.h +++ b/gtk2_ardour/gui_object.h @@ -28,19 +28,13 @@ #include "pbd/xml++.h" #include "pbd/id.h" -class GUIObjectState { - private: - typedef boost::variant<int64_t,std::string> Variant; - typedef std::map<std::string,Variant> PropertyMap; +#include "i18n.h" - public: - typedef std::map<std::string,PropertyMap> StringPropertyMap; +class GUIObjectState +{ +public: + GUIObjectState (); - ~GUIObjectState(); - - StringPropertyMap::const_iterator begin () const; - StringPropertyMap::const_iterator end () const; - XMLNode& get_state () const; int set_state (const XMLNode&); @@ -52,19 +46,24 @@ class GUIObjectState { std::string get_string (const std::string& id, const std::string& prop_name, bool* empty = 0); template<typename T> void set (const std::string& id, const std::string& prop_name, const T& val) { - StringPropertyMap::iterator i = _property_maps.find (id); - - if (i != _property_maps.end()) { - i->second[prop_name] = val; - } else { - _property_maps[id] = PropertyMap(); - _property_maps[id][prop_name] = val; + XMLNode* child = find_node (id); + if (!child) { + child = new XMLNode (X_("Object")); + child->add_property (X_("id"), id); + _state.add_child_nocopy (*child); } + + std::stringstream s; + s << val; + child->add_property (prop_name.c_str(), s.str()); } + + std::list<std::string> all_ids () const; + private: - StringPropertyMap _property_maps; + XMLNode* find_node (const std::string &) const; - void clear_maps (); + XMLNode _state; }; |