summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-12 00:41:00 +0000
committerDavid Robillard <d@drobilla.net>2006-06-12 00:41:00 +0000
commit190e2cf3c91f8bd5b1a6f69d00e84a108c743898 (patch)
tree2c7e2d52fd51cfbab6b18d523821bd456cbd6edd /src/libs
parentf43bdc8241e1bfab0980199bcd995e214ff94720 (diff)
downloadingen-190e2cf3c91f8bd5b1a6f69d00e84a108c743898.tar.gz
ingen-190e2cf3c91f8bd5b1a6f69d00e84a108c743898.tar.bz2
ingen-190e2cf3c91f8bd5b1a6f69d00e84a108c743898.zip
Metadata working based on Store signals (node positions restored)
git-svn-id: http://svn.drobilla.net/lad/grauph@29 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/ObjectModel.h5
-rw-r--r--src/libs/client/Store.cpp12
-rw-r--r--src/libs/client/Store.h5
-rw-r--r--src/libs/engine/ObjectSender.cpp5
4 files changed, 24 insertions, 3 deletions
diff --git a/src/libs/client/ObjectModel.h b/src/libs/client/ObjectModel.h
index be58a00f..94103c53 100644
--- a/src/libs/client/ObjectModel.h
+++ b/src/libs/client/ObjectModel.h
@@ -23,6 +23,7 @@
#include <string>
#include <algorithm>
#include <cassert>
+#include <sigc++/sigc++.h>
#include "util/Path.h"
using std::string; using std::map; using std::find;
@@ -49,7 +50,7 @@ public:
const map<string, string>& metadata() const { return m_metadata; }
string get_metadata(const string& key) const;
void set_metadata(const string& key, const string& value)
- { assert(value.length() > 0); m_metadata[key] = value; }
+ { assert(value.length() > 0); m_metadata[key] = value; metadata_update_sig.emit(key, value); }
inline const Path& path() const { return m_path; }
virtual void set_path(const Path& p) { m_path = p; }
@@ -65,6 +66,8 @@ public:
string base_path() const;
const string name() const { return m_path.name(); }
+ // Signals
+ sigc::signal<void, const string&, const string&> metadata_update_sig;
protected:
Path m_path;
ObjectModel* m_parent;
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index ae285305..65b3080e 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -33,6 +33,7 @@ Store::Store(SigClientInterface& emitter)
emitter.new_patch_sig.connect(sigc::mem_fun(this, &Store::new_patch_event));
emitter.new_node_sig.connect(sigc::mem_fun(this, &Store::new_node_event));
emitter.new_port_sig.connect(sigc::mem_fun(this, &Store::new_port_event));
+ emitter.metadata_update_sig.connect(sigc::mem_fun(this, &Store::metadata_update_event));
}
@@ -259,5 +260,16 @@ Store::new_port_event(const string& path, const string& type, bool is_output)
}
+void
+Store::metadata_update_event(const string& subject_path, const string& predicate, const string& value)
+{
+ CountedPtr<ObjectModel> subject = object(subject_path);
+ if (subject)
+ subject->set_metadata(predicate, value);
+ else
+ cerr << "ERROR: metadata for nonexistant object." << endl;
+}
+
+
} // namespace LibOmClient
diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h
index 2b32dde6..3c3f72fa 100644
--- a/src/libs/client/Store.h
+++ b/src/libs/client/Store.h
@@ -41,7 +41,7 @@ class PortModel;
*/
class Store {
public:
- CountedPtr<PluginModel> plugin(const string& uri);
+ CountedPtr<PluginModel> plugin(const string& uri);
CountedPtr<ObjectModel> object(const string& path);
CountedPtr<PatchModel> patch(const string& path);
CountedPtr<NodeModel> node(const string& path);
@@ -73,7 +73,8 @@ private:
void new_patch_event(const string& path, uint32_t poly);
void new_node_event(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports);
void new_port_event(const string& path, const string& data_type, bool is_output);
-
+ void metadata_update_event(const string& subject_path, const string& predicate, const string& value);
+
map<string, CountedPtr<ObjectModel> > m_objects; ///< Keyed by Om path
map<string, CountedPtr<PluginModel> > m_plugins; ///< Keyed by URI
};
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
index 3db6915d..9d3e535d 100644
--- a/src/libs/engine/ObjectSender.cpp
+++ b/src/libs/engine/ObjectSender.cpp
@@ -133,6 +133,11 @@ ObjectSender::send_node(ClientInterface* client, const Node* node)
}
client->bundle_end();
+
+ // Send metadata
+ const map<string, string>& data = node->metadata();
+ for (map<string, string>::const_iterator j = data.begin(); j != data.end(); ++j)
+ client->metadata_update(node->path(), (*j).first, (*j).second);
}