diff options
author | David Robillard <d@drobilla.net> | 2009-05-13 06:14:40 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-13 06:14:40 +0000 |
commit | a95e08e48c2d1f68693609627c6d6f52c6982264 (patch) | |
tree | 0feed2d49d10d6e8880bef4a7e88c52584c094cf /src/client/ClientStore.cpp | |
parent | f62ef545425476959b1335f3a303d6d5f80ca0e5 (diff) | |
download | ingen-a95e08e48c2d1f68693609627c6d6f52c6982264.tar.gz ingen-a95e08e48c2d1f68693609627c6d6f52c6982264.tar.bz2 ingen-a95e08e48c2d1f68693609627c6d6f52c6982264.zip |
Generic simple query system for both objects and plugins.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1997 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client/ClientStore.cpp')
-rw-r--r-- | src/client/ClientStore.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index f120e7ed..21ace7de 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -185,6 +185,15 @@ ClientStore::object(const Path& path) } } +SharedPtr<Resource> +ClientStore::resource(const URI& uri) +{ + if (uri.scheme() == Path::scheme && Path::is_valid(uri.str())) + return object(uri.str()); + else + return plugin(uri); +} + void ClientStore::add_plugin(SharedPtr<PluginModel> pm) { @@ -353,14 +362,18 @@ ClientStore::clear_patch(const Path& path) void -ClientStore::set_variable(const Path& subject_path, const URI& predicate, const Atom& value) +ClientStore::set_variable(const URI& subject_path, const URI& predicate, const Atom& value) { - SharedPtr<ObjectModel> subject = object(subject_path); + SharedPtr<Resource> subject = resource(subject_path); if (!value.is_valid()) { - cerr << "ERROR: variable '" << predicate << "' has no type" << endl; + cerr << "ERROR: variable '" << predicate << "' is invalid" << endl; } else if (subject) { - subject->set_variable(predicate, value); + SharedPtr<ObjectModel> om = PtrCast<ObjectModel>(subject); + if (om) + om->set_variable(predicate, value); + else + subject->set_property(predicate, value); } else { //add_variable_orphan(subject_path, predicate, value); cerr << "WARNING: variable '" << predicate << "' for unknown object " << subject_path << endl; @@ -369,16 +382,16 @@ ClientStore::set_variable(const Path& subject_path, const URI& predicate, const void -ClientStore::set_property(const Path& subject_path, const URI& predicate, const Atom& value) +ClientStore::set_property(const URI& subject_path, const URI& predicate, const Atom& value) { - if (!value.is_valid()) - cerr << "WARNING: property '" << predicate << "' is NULL" << endl; - - SharedPtr<ObjectModel> obj = object(subject_path); - if (obj) - obj->set_property(predicate, value); - else + SharedPtr<Resource> subject = resource(subject_path); + if (!value.is_valid()) { + cerr << "ERROR: property '" << predicate << "' is invalid" << endl; + } else if (subject) { + subject->set_property(predicate, value); + } else { cerr << "WARNING: property '" << predicate << "' for unknown object " << subject_path << endl; + } } |