From a95e08e48c2d1f68693609627c6d6f52c6982264 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 13 May 2009 06:14:40 +0000 Subject: 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 --- src/client/ClientStore.cpp | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'src/client/ClientStore.cpp') 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 +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 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 subject = object(subject_path); + SharedPtr 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 om = PtrCast(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 obj = object(subject_path); - if (obj) - obj->set_property(predicate, value); - else + SharedPtr 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; + } } -- cgit v1.2.1