summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-07-19 16:01:07 +0200
committerDavid Robillard <d@drobilla.net>2020-08-01 11:50:43 +0200
commit381c4a77fe5864cd3aed3854b75acf2a52f6a74d (patch)
treee12c428f00b141015c2ad982354fa2fa0f51ddf5
parent62cc04f4a703f034cbf81e19b26797e6271801ae (diff)
downloadingen-381c4a77fe5864cd3aed3854b75acf2a52f6a74d.tar.gz
ingen-381c4a77fe5864cd3aed3854b75acf2a52f6a74d.tar.bz2
ingen-381c4a77fe5864cd3aed3854b75acf2a52f6a74d.zip
Add explicit accessors to Quark
-rw-r--r--ingen/Properties.hpp2
-rw-r--r--ingen/URIs.hpp27
-rw-r--r--src/Resource.cpp8
-rw-r--r--src/URIs.cpp14
-rw-r--r--src/client/PluginModel.cpp4
-rw-r--r--src/client/PluginUI.cpp2
-rw-r--r--src/gui/ObjectMenu.cpp2
-rw-r--r--src/server/ClientUpdate.cpp2
-rw-r--r--src/server/DuplexPort.cpp7
-rw-r--r--src/server/GraphPlugin.hpp2
-rw-r--r--src/server/InputPort.cpp2
-rw-r--r--src/server/InternalPlugin.cpp2
-rw-r--r--src/server/LV2Plugin.cpp2
-rw-r--r--src/server/PortImpl.cpp3
-rw-r--r--src/server/events/CreateGraph.cpp2
15 files changed, 46 insertions, 35 deletions
diff --git a/ingen/Properties.hpp b/ingen/Properties.hpp
index 6f1a8494..cd81ba59 100644
--- a/ingen/Properties.hpp
+++ b/ingen/Properties.hpp
@@ -41,7 +41,7 @@ public:
{}
Property(const URIs::Quark& quark, Graph ctx=Graph::DEFAULT)
- : Atom(quark.urid)
+ : Atom(quark.urid_atom())
, _ctx(ctx)
{}
diff --git a/ingen/URIs.hpp b/ingen/URIs.hpp
index eb657473..9d4b2818 100644
--- a/ingen/URIs.hpp
+++ b/ingen/URIs.hpp
@@ -51,13 +51,20 @@ public:
~Quark();
- operator LV2_URID() const { return urid.get<LV2_URID>(); }
- explicit operator Atom() const { return urid; }
- operator const LilvNode*() const { return lnode; }
+ const Atom& urid_atom() const { return _urid_atom; }
+ const Atom& uri_atom() const { return _uri_atom; }
- Atom urid;
- Atom uri;
- LilvNode* lnode;
+ LV2_URID urid() const { return _urid_atom.get<LV2_URID>(); }
+ const LilvNode* node() const { return _lilv_node; }
+
+ operator LV2_URID() const { return _urid_atom.get<LV2_URID>(); }
+ explicit operator Atom() const { return _urid_atom; }
+ operator const LilvNode*() const { return _lilv_node; }
+
+ private:
+ Atom _urid_atom;
+ Atom _uri_atom;
+ LilvNode* _lilv_node;
};
ingen::Forge& forge;
@@ -203,10 +210,10 @@ public:
inline bool
operator==(const URIs::Quark& lhs, const Atom& rhs)
{
- if (rhs.type() == lhs.urid.type()) {
- return rhs == lhs.urid;
- } else if (rhs.type() == lhs.uri.type()) {
- return rhs == lhs.uri;
+ if (rhs.type() == lhs.urid_atom().type()) {
+ return rhs == lhs.urid_atom();
+ } else if (rhs.type() == lhs.uri_atom().type()) {
+ return rhs == lhs.uri_atom();
}
return false;
}
diff --git a/src/Resource.cpp b/src/Resource.cpp
index fca76572..afd9182a 100644
--- a/src/Resource.cpp
+++ b/src/Resource.cpp
@@ -82,7 +82,7 @@ Resource::set_property(const URI& uri,
const URIs::Quark& value,
Resource::Graph ctx)
{
- return set_property(uri, value.urid, ctx);
+ return set_property(uri, value.urid_atom(), ctx);
}
void
@@ -106,8 +106,8 @@ Resource::remove_property(const URI& uri, const Atom& value)
void
Resource::remove_property(const URI& uri, const URIs::Quark& value)
{
- remove_property(uri, value.urid);
- remove_property(uri, value.uri);
+ remove_property(uri, value.urid_atom());
+ remove_property(uri, value.uri_atom());
}
bool
@@ -196,7 +196,7 @@ Resource::set_properties(const Properties& props)
// Erase existing properties with matching keys
for (const auto& p : props) {
_properties.erase(p.first);
- on_property_removed(p.first, _uris.patch_wildcard.urid);
+ on_property_removed(p.first, _uris.patch_wildcard.urid_atom());
}
// Set new properties
diff --git a/src/URIs.cpp b/src/URIs.cpp
index dfe6b867..f0252e73 100644
--- a/src/URIs.cpp
+++ b/src/URIs.cpp
@@ -41,21 +41,21 @@ URIs::Quark::Quark(Forge& forge,
LilvWorld* lworld,
const char* str)
: URI(str)
- , urid(forge.make_urid(URI(str)))
- , uri(forge.alloc_uri(str))
- , lnode(lilv_new_uri(lworld, str))
+ , _urid_atom(forge.make_urid(URI(str)))
+ , _uri_atom(forge.alloc_uri(str))
+ , _lilv_node(lilv_new_uri(lworld, str))
{}
URIs::Quark::Quark(const Quark& copy)
: URI(copy)
- , urid(copy.urid)
- , uri(copy.uri)
- , lnode(lilv_node_duplicate(copy.lnode))
+ , _urid_atom(copy._urid_atom)
+ , _uri_atom(copy._uri_atom)
+ , _lilv_node(lilv_node_duplicate(copy._lilv_node))
{}
URIs::Quark::~Quark()
{
- lilv_node_free(lnode);
+ lilv_node_free(_lilv_node);
}
#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index f0e3c3a0..23015f51 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -50,9 +50,9 @@ PluginModel::PluginModel(URIs& uris,
{
if (!_type.is_valid()) {
if (uri.string().find("ingen-internals") != string::npos) {
- _type = uris.ingen_Internal.urid;
+ _type = uris.ingen_Internal.urid_atom();
} else {
- _type = uris.lv2_Plugin.urid; // Assume LV2 and hope for the best...
+ _type = uris.lv2_Plugin.urid_atom(); // Assume LV2 and hope for the best...
}
}
diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp
index a997d716..07d37404 100644
--- a/src/client/PluginUI.cpp
+++ b/src/client/PluginUI.cpp
@@ -79,7 +79,7 @@ lv2_ui_write(SuilController controller,
ui->world().forge().make(value),
Resource::Graph::DEFAULT);
- } else if (format == uris.atom_eventTransfer.urid.get<LV2_URID>()) {
+ } else if (format == uris.atom_eventTransfer.urid()) {
const LV2_Atom* atom = (const LV2_Atom*)buffer;
Atom val = ui->world().forge().alloc(
atom->size, atom->type, LV2_ATOM_BODY_CONST(atom));
diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp
index 7a523f4e..11648a30 100644
--- a/src/gui/ObjectMenu.cpp
+++ b/src/gui/ObjectMenu.cpp
@@ -96,7 +96,7 @@ ObjectMenu::on_menu_learn()
{
_app->interface()->set_property(_object->uri(),
_app->uris().midi_binding,
- _app->uris().patch_wildcard.urid);
+ _app->uris().patch_wildcard.urid_atom());
}
void
diff --git a/src/server/ClientUpdate.cpp b/src/server/ClientUpdate.cpp
index 26f45ef1..cb3c34dc 100644
--- a/src/server/ClientUpdate.cpp
+++ b/src/server/ClientUpdate.cpp
@@ -124,7 +124,7 @@ ClientUpdate::put_preset(const URIs& uris,
const std::string& label)
{
const Properties props{
- { uris.rdf_type, uris.pset_Preset.urid },
+ { uris.rdf_type, uris.pset_Preset.urid_atom() },
{ uris.rdfs_label, uris.forge.alloc(label) },
{ uris.lv2_appliesTo, uris.forge.make_urid(plugin) }};
put(preset, props);
diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp
index 8297e3cc..bc827b54 100644
--- a/src/server/DuplexPort.cpp
+++ b/src/server/DuplexPort.cpp
@@ -69,8 +69,11 @@ DuplexPort::DuplexPort(BufferFactory& bufs,
_is_output = is_output;
if (is_output) {
if (parent->graph_type() != Node::GraphType::GRAPH) {
- remove_property(bufs.uris().rdf_type, bufs.uris().lv2_InputPort.urid);
- add_property(bufs.uris().rdf_type, bufs.uris().lv2_OutputPort.urid);
+ remove_property(bufs.uris().rdf_type,
+ bufs.uris().lv2_InputPort.urid_atom());
+
+ add_property(bufs.uris().rdf_type,
+ bufs.uris().lv2_OutputPort.urid_atom());
}
}
diff --git a/src/server/GraphPlugin.hpp b/src/server/GraphPlugin.hpp
index 9e221689..bb97e9c2 100644
--- a/src/server/GraphPlugin.hpp
+++ b/src/server/GraphPlugin.hpp
@@ -37,7 +37,7 @@ public:
const URI& uri,
const Raul::Symbol& symbol,
const std::string& name)
- : PluginImpl(uris, uris.ingen_Graph.urid, uri)
+ : PluginImpl(uris, uris.ingen_Graph.urid_atom(), uri)
{}
BlockImpl* instantiate(BufferFactory& bufs,
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 9d02fd99..15df4d60 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -52,7 +52,7 @@ InputPort::InputPort(BufferFactory& bufs,
const ingen::URIs& uris = bufs.uris();
if (parent->graph_type() != Node::GraphType::GRAPH) {
- add_property(uris.rdf_type, uris.lv2_InputPort.urid);
+ add_property(uris.rdf_type, uris.lv2_InputPort.urid_atom());
}
}
diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp
index 8d43a321..be63fa70 100644
--- a/src/server/InternalPlugin.cpp
+++ b/src/server/InternalPlugin.cpp
@@ -33,7 +33,7 @@ using namespace internals;
InternalPlugin::InternalPlugin(URIs& uris,
const URI& uri,
const Raul::Symbol& symbol)
- : PluginImpl(uris, uris.ingen_Internal.urid, uri)
+ : PluginImpl(uris, uris.ingen_Internal.urid_atom(), uri)
, _symbol(symbol)
{
set_property(uris.rdf_type, uris.ingen_Internal);
diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp
index 01357d8d..1411be1d 100644
--- a/src/server/LV2Plugin.cpp
+++ b/src/server/LV2Plugin.cpp
@@ -32,7 +32,7 @@ namespace server {
LV2Plugin::LV2Plugin(World& world, const LilvPlugin* lplugin)
: PluginImpl(world.uris(),
- world.uris().lv2_Plugin.urid,
+ world.uris().lv2_Plugin.urid_atom(),
URI(lilv_node_as_uri(lilv_plugin_get_uri(lplugin))))
, _world(world)
, _lilv_plugin(lplugin)
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 87022c27..ab5e4ee8 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -103,7 +103,8 @@ PortImpl::PortImpl(BufferFactory& bufs,
if (is_output) {
if (_parent->graph_type() != Node::GraphType::GRAPH) {
- add_property(bufs.uris().rdf_type, bufs.uris().lv2_OutputPort.urid);
+ add_property(bufs.uris().rdf_type,
+ bufs.uris().lv2_OutputPort.urid_atom());
}
}
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index 3e847bdd..4e031276 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -152,7 +152,7 @@ CreateGraph::pre_process(PreProcessContext& ctx)
// Create a new graph
_graph = new GraphImpl(_engine, symbol, ext_poly, _parent,
_engine.sample_rate(), int_poly);
- _graph->add_property(uris.rdf_type, uris.ingen_Graph.urid);
+ _graph->add_property(uris.rdf_type, uris.ingen_Graph.urid_atom());
_graph->add_property(uris.rdf_type,
Property(uris.ingen_Block,
Resource::Graph::EXTERNAL));