From 85aaff2bf3420e7c4a1d4db3c093c589b0c25e78 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 1 Apr 2015 04:21:18 +0000 Subject: Support adding datatype properties. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5649 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/RDFS.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/gui/RDFS.cpp') diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp index 458c0bc5..10367bc8 100644 --- a/src/gui/RDFS.cpp +++ b/src/gui/RDFS.cpp @@ -57,12 +57,9 @@ comment(World* world, const LilvNode* node) return comment; } -void -classes(World* world, URISet& types, bool super) +static void +closure(World* world, const LilvNode* pred, URISet& types, bool super) { - LilvNode* rdfs_subClassOf = lilv_new_uri( - world->lilv_world(), LILV_NS_RDFS "subClassOf"); - unsigned added = 0; do { added = 0; @@ -71,9 +68,9 @@ classes(World* world, URISet& types, bool super) LilvNode* type = lilv_new_uri(world->lilv_world(), t.c_str()); LilvNodes* matches = (super) ? lilv_world_find_nodes( - world->lilv_world(), type, rdfs_subClassOf, NULL) + world->lilv_world(), type, pred, NULL) : lilv_world_find_nodes( - world->lilv_world(), NULL, rdfs_subClassOf, type); + world->lilv_world(), NULL, pred, type); LILV_FOREACH(nodes, m, matches) { const LilvNode* klass_node = lilv_nodes_get(matches, m); if (lilv_node_is_uri(klass_node)) { @@ -89,10 +86,30 @@ classes(World* world, URISet& types, bool super) } types.insert(klasses.begin(), klasses.end()); } while (added > 0); +} + +void +classes(World* world, URISet& types, bool super) +{ + LilvNode* rdfs_subClassOf = lilv_new_uri( + world->lilv_world(), LILV_NS_RDFS "subClassOf"); + + closure(world, rdfs_subClassOf, types, super); lilv_node_free(rdfs_subClassOf); } +void +datatypes(World* world, URISet& types, bool super) +{ + LilvNode* owl_onDatatype = lilv_new_uri( + world->lilv_world(), LILV_NS_OWL "onDatatype"); + + closure(world, owl_onDatatype, types, super); + + lilv_node_free(owl_onDatatype); +} + URISet types(World* world, SPtr model) { @@ -139,6 +156,11 @@ properties(World* world, SPtr model) unsigned n_matching_domains = 0; LILV_FOREACH(nodes, d, domains) { const LilvNode* domain_node = lilv_nodes_get(domains, d); + if (!lilv_node_is_uri(domain_node)) { + // TODO: Blank node domains (e.g. unions) + continue; + } + const Raul::URI domain(lilv_node_as_uri(domain_node)); if (types.count(domain)) { ++n_matching_domains; -- cgit v1.2.1