summaryrefslogtreecommitdiffstats
path: root/src/gui/RDFS.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-03-28 09:47:19 +0000
committerDavid Robillard <d@drobilla.net>2015-03-28 09:47:19 +0000
commitc0da1cf368b7d43c9c886b81768b4a62a07fae3f (patch)
tree83b651a2b680e32b990dd1e1909156aee475a181 /src/gui/RDFS.cpp
parentd0b4376df39e95cb9389f5c42fc1c2333e8c0c97 (diff)
downloadingen-c0da1cf368b7d43c9c886b81768b4a62a07fae3f.tar.gz
ingen-c0da1cf368b7d43c9c886b81768b4a62a07fae3f.tar.bz2
ingen-c0da1cf368b7d43c9c886b81768b4a62a07fae3f.zip
Unify value widgets in properties dialog.
This shows the fancy URI selector for URI properties, and can show numeric controls for the property-to-add. The ontologies need some work, along with smarter widget creation, before the latter will actually be useful. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5648 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui/RDFS.cpp')
-rw-r--r--src/gui/RDFS.cpp52
1 files changed, 43 insertions, 9 deletions
diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp
index a24ae002..458c0bc5 100644
--- a/src/gui/RDFS.cpp
+++ b/src/gui/RDFS.cpp
@@ -25,7 +25,7 @@ namespace Ingen {
namespace GUI {
namespace RDFS {
-Glib::ustring
+std::string
label(World* world, const LilvNode* node)
{
LilvNode* rdfs_label = lilv_new_uri(
@@ -34,14 +34,14 @@ label(World* world, const LilvNode* node)
world->lilv_world(), node, rdfs_label, NULL);
const LilvNode* first = lilv_nodes_get_first(labels);
- Glib::ustring label = first ? lilv_node_as_string(first) : "";
+ std::string label = first ? lilv_node_as_string(first) : "";
lilv_nodes_free(labels);
lilv_node_free(rdfs_label);
return label;
}
-Glib::ustring
+std::string
comment(World* world, const LilvNode* node)
{
LilvNode* rdfs_comment = lilv_new_uri(
@@ -49,8 +49,8 @@ comment(World* world, const LilvNode* node)
LilvNodes* comments = lilv_world_find_nodes(
world->lilv_world(), node, rdfs_comment, NULL);
- const LilvNode* first = lilv_nodes_get_first(comments);
- Glib::ustring comment = first ? lilv_node_as_string(first) : "";
+ const LilvNode* first = lilv_nodes_get_first(comments);
+ std::string comment = first ? lilv_node_as_string(first) : "";
lilv_nodes_free(comments);
lilv_node_free(rdfs_comment);
@@ -178,11 +178,10 @@ instances(World* world, const URISet& types)
if (!lilv_node_is_uri(object)) {
continue;
}
- const Glib::ustring label = RDFS::label(world, object);
+ const std::string label = RDFS::label(world, object);
result.insert(
- std::make_pair(
- Raul::URI(lilv_node_as_string(object)),
- label));
+ std::make_pair(label,
+ Raul::URI(lilv_node_as_string(object))));
}
lilv_node_free(type);
}
@@ -191,6 +190,41 @@ instances(World* world, const URISet& types)
return result;
}
+URISet
+range(World* world, const LilvNode* prop, bool recursive)
+{
+ LilvNode* rdfs_range = lilv_new_uri(
+ world->lilv_world(), LILV_NS_RDFS "range");
+
+ LilvNodes* nodes = lilv_world_find_nodes(
+ world->lilv_world(), prop, rdfs_range, NULL);
+
+ URISet ranges;
+ LILV_FOREACH(nodes, n, nodes) {
+ ranges.insert(Raul::URI(lilv_node_as_string(lilv_nodes_get(nodes, n))));
+ }
+
+ if (recursive) {
+ RDFS::classes(world, ranges, false);
+ }
+
+ lilv_nodes_free(nodes);
+ lilv_node_free(rdfs_range);
+ return ranges;
+}
+
+bool
+is_a(World* world, const LilvNode* inst, const LilvNode* klass)
+{
+ LilvNode* rdf_type = lilv_new_uri(world->lilv_world(), LILV_NS_RDF "type");
+
+ const bool is_instance = lilv_world_ask(
+ world->lilv_world(), inst, rdf_type, klass);
+
+ lilv_node_free(rdf_type);
+ return is_instance;
+}
+
} // namespace RDFS
} // namespace GUI
} // namespace Ingen