mark the step entry dialog as a dialog even though it is an ArdourWindow, to help...
[ardour.git] / gtk2_ardour / gui_object.h
index a109e625ae0a1600f987ba8220fa6fb3fb52887d..ee6d1cdf4ccaf42a2b4277dab98fd790687bcc09 100644 (file)
 #include "pbd/xml++.h"
 #include "pbd/id.h"
 
-class GUIObjectState {
-  public:
-       GUIObjectState() {}
-       ~GUIObjectState();
+class GUIObjectState
+{
+public:
+       GUIObjectState ();
 
        XMLNode& get_state () const;
        int set_state (const XMLNode&);
@@ -39,61 +39,23 @@ class GUIObjectState {
        static const std::string xml_node_name;
        void load (const XMLNode&);
 
-       GUIObjectState& operator= (const GUIObjectState& other);
+       std::string get_string (const std::string& id, const std::string& prop_name, bool* empty = 0);
 
-  private:
-       typedef boost::variant<int64_t,std::string> Variant;
-       typedef std::map<std::string,Variant> PropertyMap;
-       typedef std::map<std::string,PropertyMap> StringPropertyMap;
-
-       StringPropertyMap _property_maps;
-
-       template<typename T> T get (const std::string& id, const std::string& prop_name, const T& type_determination_placeholder, bool* empty = 0) {
-               StringPropertyMap::iterator i = _property_maps.find (id);
-               
-               if (i == _property_maps.end()) {
-                       if (empty) {
-                               *empty = true;
-                       }
-                       return T();
-               }
-
-               const PropertyMap& pmap (i->second);
-               PropertyMap::const_iterator p = pmap.find (prop_name);
-
-               if (p == pmap.end()) {
-                       return T();
-               }
-
-               return boost::get<T> (p->second);
-       }
-
-       void clear_maps ();
-
-  public:
-       int get_int (const std::string& id, const std::string& prop_name) {
-               int i = 0;
-               return get (id, prop_name, i);
+       template<typename T> void set_property (const std::string& id, const std::string& prop_name, const T& val) {
+               XMLNode* child = get_or_add_node (id);
+               std::stringstream s;
+               s << val;
+               child->add_property (prop_name.c_str(), s.str());
        }
 
-       std::string get_string (const std::string& id, const std::string& prop_name) {
-               std::string s;
-               return get (id, prop_name, s);
-       }
-
-       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;
-                       // std::cerr << id << " REset " << prop_name << " = [" << val << "]\n";
-               } else {
-                       _property_maps[id] = PropertyMap();
-                       _property_maps[id][prop_name] = val;
-                       // std::cerr << id << " set " << prop_name << " = [" << val << "]\n";
-               }
-       }
+       std::list<std::string> all_ids () const;
 
+       static XMLNode* get_node (const XMLNode *, const std::string &);
+       XMLNode* get_or_add_node (const std::string &);
+       static XMLNode* get_or_add_node (XMLNode *, const std::string &);
+       
+  private:
+       XMLNode _state;
 };