diff options
130 files changed, 831 insertions, 626 deletions
diff --git a/ingen/AtomReader.hpp b/ingen/AtomReader.hpp index bca56022..7ea4654a 100644 --- a/ingen/AtomReader.hpp +++ b/ingen/AtomReader.hpp @@ -28,11 +28,11 @@ namespace Raul { class Path; -class URI; } namespace Ingen { +class URI; class Atom; class Interface; class Log; @@ -58,7 +58,7 @@ public: private: void get_atom(const LV2_Atom* in, Atom& out); - boost::optional<Raul::URI> atom_to_uri(const LV2_Atom* atom); + boost::optional<URI> atom_to_uri(const LV2_Atom* atom); boost::optional<Raul::Path> atom_to_path(const LV2_Atom* atom); Resource::Graph atom_to_context(const LV2_Atom* atom); diff --git a/ingen/AtomWriter.hpp b/ingen/AtomWriter.hpp index 725d4a81..5e765c75 100644 --- a/ingen/AtomWriter.hpp +++ b/ingen/AtomWriter.hpp @@ -27,7 +27,6 @@ #include "ingen/ingen.h" #include "lv2/lv2plug.in/ns/ext/atom/forge.h" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" -#include "raul/URI.hpp" namespace Raul { class Path; } @@ -45,9 +44,7 @@ public: AtomWriter(URIMap& map, URIs& uris, AtomSink& sink); - Raul::URI uri() const override { - return Raul::URI("ingen:/clients/atom_writer"); - } + URI uri() const override { return URI("ingen:/clients/atom_writer"); } void message(const Message& message) override; @@ -69,7 +66,7 @@ public: void operator()(const Undo&); private: - void forge_uri(const Raul::URI& uri); + void forge_uri(const URI& uri); void forge_properties(const Properties& properties); void forge_arc(const Raul::Path& tail, const Raul::Path& head); void forge_request(LV2_Atom_Forge_Frame* frame, LV2_URID type, int32_t id); diff --git a/ingen/ClashAvoider.hpp b/ingen/ClashAvoider.hpp index a5cd3643..069c8fef 100644 --- a/ingen/ClashAvoider.hpp +++ b/ingen/ClashAvoider.hpp @@ -21,11 +21,11 @@ #include "ingen/ingen.h" #include "raul/Path.hpp" -#include "raul/URI.hpp" namespace Ingen { class Store; +class URI; /** Maps paths so they do not clash with an existing object in a store. * @@ -36,7 +36,7 @@ class INGEN_API ClashAvoider public: explicit ClashAvoider(const Store& store); - const Raul::URI map_uri(const Raul::URI& in); + const URI map_uri(const URI& in); const Raul::Path map_path(const Raul::Path& in); bool exists(const Raul::Path& path) const; diff --git a/ingen/Forge.hpp b/ingen/Forge.hpp index 3dd7bfa3..32822f89 100644 --- a/ingen/Forge.hpp +++ b/ingen/Forge.hpp @@ -25,11 +25,10 @@ #include "ingen/ingen.h" #include "lv2/lv2plug.in/ns/ext/atom/forge.h" -namespace Raul { class URI; } - namespace Ingen { class URIMap; +class URI; /** Forge for Atoms. * @ingroup IngenShared @@ -54,7 +53,7 @@ public: Atom make_urid(int32_t v) { return Atom(sizeof(int32_t), URID, &v); } - Atom make_urid(const Raul::URI& u); + Atom make_urid(const Ingen::URI& u); Atom alloc(uint32_t size, uint32_t type, const void* val) { return Atom(size, type, val); diff --git a/ingen/Interface.hpp b/ingen/Interface.hpp index 2221f8f0..a6654afe 100644 --- a/ingen/Interface.hpp +++ b/ingen/Interface.hpp @@ -33,12 +33,12 @@ namespace Raul { class Path; -class URI; } namespace Ingen { class Atom; +class URI; /** Abstract interface for Ingen servers and clients. * @@ -53,7 +53,7 @@ public: virtual ~Interface() = default; - virtual Raul::URI uri() const = 0; + virtual URI uri() const = 0; virtual SPtr<Interface> respondee() const { return SPtr<Interface>(); } @@ -67,22 +67,19 @@ public: inline void operator()(const Message& msg) { message(msg); } - inline void set_response_id(int32_t id) { - _seq = id; - } + inline void set_response_id(int32_t id) { _seq = id; } inline void bundle_begin() { message(BundleBegin{_seq++}); } + inline void bundle_end() { message(BundleEnd{_seq++}); } - inline void bundle_end() { message(BundleEnd{_seq++}); } - - inline void put(const Raul::URI& uri, + inline void put(const URI& uri, const Properties& properties, Resource::Graph ctx = Resource::Graph::DEFAULT) { message(Put{_seq++, uri, properties, ctx}); } - inline void delta(const Raul::URI& uri, + inline void delta(const URI& uri, const Properties& remove, const Properties& add, Resource::Graph ctx = Resource::Graph::DEFAULT) @@ -90,7 +87,7 @@ public: message(Delta{_seq++, uri, remove, add, ctx}); } - inline void copy(const Raul::URI& old_uri, const Raul::URI& new_uri) + inline void copy(const URI& old_uri, const URI& new_uri) { message(Copy{_seq++, old_uri, new_uri}); } @@ -100,7 +97,7 @@ public: message(Move{_seq++, old_path, new_path}); } - inline void del(const Raul::URI& uri) { message(Del{_seq++, uri}); } + inline void del(const URI& uri) { message(Del{_seq++, uri}); } inline void connect(const Raul::Path& tail, const Raul::Path& head) { @@ -117,10 +114,10 @@ public: message(DisconnectAll{_seq++, graph, path}); } - inline void set_property(const Raul::URI& subject, - const Raul::URI& predicate, - const Atom& value, - Resource::Graph ctx = Resource::Graph::DEFAULT) + inline void set_property(const URI& subject, + const URI& predicate, + const Atom& value, + Resource::Graph ctx = Resource::Graph::DEFAULT) { message(SetProperty{_seq++, subject, predicate, value, ctx}); } @@ -129,15 +126,15 @@ public: inline void redo() { message(Redo{_seq++}); } - inline void get(const Raul::URI& uri) { message(Get{_seq++, uri}); } + inline void get(const URI& uri) { message(Get{_seq++, uri}); } - inline void response(int32_t id, - Status status, - const std::string& subject) { + inline void response(int32_t id, Status status, const std::string& subject) + { message(Response{id, status, subject}); } - inline void error(const std::string& error_message) { + inline void error(const std::string& error_message) + { message(Error{_seq++, error_message}); } diff --git a/ingen/Message.hpp b/ingen/Message.hpp index 83608dae..515a2e1f 100644 --- a/ingen/Message.hpp +++ b/ingen/Message.hpp @@ -27,7 +27,6 @@ #include "ingen/Resource.hpp" #include "ingen/Status.hpp" #include "raul/Path.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -50,21 +49,21 @@ struct Connect struct Copy { - int32_t seq; - Raul::URI old_uri; - Raul::URI new_uri; + int32_t seq; + URI old_uri; + URI new_uri; }; struct Del { - int32_t seq; - Raul::URI uri; + int32_t seq; + URI uri; }; struct Delta { int32_t seq; - Raul::URI uri; + URI uri; Properties remove; Properties add; Resource::Graph ctx; @@ -92,8 +91,8 @@ struct Error struct Get { - int32_t seq; - Raul::URI subject; + int32_t seq; + URI subject; }; struct Move @@ -106,7 +105,7 @@ struct Move struct Put { int32_t seq; - Raul::URI uri; + URI uri; Properties properties; Resource::Graph ctx; }; @@ -126,8 +125,8 @@ struct Response struct SetProperty { int32_t seq; - Raul::URI subject; - Raul::URI predicate; + URI subject; + URI predicate; Atom value; Resource::Graph ctx; }; diff --git a/ingen/Node.hpp b/ingen/Node.hpp index 5b2a5ee5..e023e9e2 100644 --- a/ingen/Node.hpp +++ b/ingen/Node.hpp @@ -27,7 +27,6 @@ #include "ingen/paths.hpp" #include "ingen/types.hpp" #include "lilv/lilv.h" -#include "raul/URI.hpp" namespace Raul { class Path; @@ -83,11 +82,11 @@ public: virtual const Raul::Symbol& symbol() const = 0; virtual Node* graph_parent() const = 0; - Raul::URI base_uri() const { - if (uri()[uri().size() - 1] == '/') { + URI base_uri() const { + if (uri().string()[uri().string().size() - 1] == '/') { return uri(); } - return Raul::URI(uri() + '/'); + return URI(uri().string() + '/'); } protected: diff --git a/ingen/Parser.hpp b/ingen/Parser.hpp index 852fa0a5..ac9d8320 100644 --- a/ingen/Parser.hpp +++ b/ingen/Parser.hpp @@ -17,23 +17,25 @@ #ifndef INGEN_PARSER_HPP #define INGEN_PARSER_HPP -#include <string> #include <set> +#include <string> +#include <utility> #include <boost/optional/optional.hpp> #include "ingen/Properties.hpp" +#include "ingen/URI.hpp" #include "ingen/ingen.h" #include "raul/Path.hpp" #include "raul/Symbol.hpp" -namespace Raul { class URI; } namespace Sord { class World; } namespace Ingen { class Interface; class World; +class URI; /** Parser for reading graphs from Turtle files or strings. @@ -48,7 +50,7 @@ public: /** Record of a resource listed in a bundle manifest. */ struct ResourceRecord { - inline ResourceRecord(std::string u, std::string f) + inline ResourceRecord(URI u, std::string f) : uri(std::move(u)), filename(std::move(f)) {} @@ -56,15 +58,14 @@ public: return uri < r.uri; } - std::string uri; ///< URI of resource (e.g. a Graph) + URI uri; ///< URI of resource (e.g. a Graph) std::string filename; ///< Path of describing file (seeAlso) }; /** Find all resources of a given type listed in a manifest file. */ - virtual std::set<ResourceRecord> find_resources( - Sord::World& world, - const std::string& manifest_uri, - const Raul::URI& type_uri); + virtual std::set<ResourceRecord> find_resources(Sord::World& world, + const URI& manifest_uri, + const URI& type_uri); /** Parse a graph from RDF into a Interface (engine or client). * @@ -83,7 +84,7 @@ public: boost::optional<Raul::Symbol> symbol = boost::optional<Raul::Symbol>(), boost::optional<Properties> data = boost::optional<Properties>()); - virtual boost::optional<Raul::URI> parse_string( + virtual boost::optional<URI> parse_string( World* world, Interface* target, const std::string& str, diff --git a/ingen/Properties.hpp b/ingen/Properties.hpp index a80a00d9..e148c542 100644 --- a/ingen/Properties.hpp +++ b/ingen/Properties.hpp @@ -23,7 +23,6 @@ #include "ingen/Atom.hpp" #include "ingen/URIs.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -53,7 +52,7 @@ private: Graph _ctx; }; -class Properties : public std::multimap<Raul::URI, Property> { +class Properties : public std::multimap<URI, Property> { public: using Graph = Property::Graph; @@ -61,22 +60,22 @@ public: Properties(const Properties& copy) = default; Properties(std::initializer_list<value_type> l) - : std::multimap<Raul::URI, Property>(l) + : std::multimap<URI, Property>(l) {} - void put(const Raul::URI& key, - const Atom& value, - Graph ctx = Graph::DEFAULT) { + void put(const URI& key, + const Atom& value, + Graph ctx = Graph::DEFAULT) { emplace(key, Property(value, ctx)); } - void put(const Raul::URI& key, + void put(const URI& key, const URIs::Quark& value, Graph ctx = Graph::DEFAULT) { emplace(key, Property(value, ctx)); } - bool contains(const Raul::URI& key, const Atom& value) { + bool contains(const URI& key, const Atom& value) { for (const_iterator i = find(key); i != end() && i->first == key; ++i) { if (i->second == value) { return true; diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp index 8cfdb02a..9fc854c7 100644 --- a/ingen/Resource.hpp +++ b/ingen/Resource.hpp @@ -21,10 +21,10 @@ #include <string> #include "ingen/Properties.hpp" +#include "ingen/URI.hpp" #include "ingen/URIs.hpp" #include "ingen/ingen.h" #include "raul/Deletable.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -42,7 +42,7 @@ class INGEN_API Resource : public Raul::Deletable public: using Graph = Property::Graph; - Resource(const URIs& uris, const Raul::URI& uri) + Resource(const URIs& uris, const URI& uri) : _uris(uris) , _uri(uri) {} @@ -56,15 +56,15 @@ public: return *this; } - static Raul::URI graph_to_uri(Graph g) { + static URI graph_to_uri(Graph g) { switch (g) { - case Graph::EXTERNAL: return Raul::URI(INGEN_NS "externalContext"); - case Graph::INTERNAL: return Raul::URI(INGEN_NS "internalContext"); - default: return Raul::URI(INGEN_NS "defaultContext"); + case Graph::EXTERNAL: return URI(INGEN_NS "externalContext"); + case Graph::INTERNAL: return URI(INGEN_NS "internalContext"); + default: return URI(INGEN_NS "defaultContext"); } } - static Graph uri_to_graph(const Raul::URI& uri) { + static Graph uri_to_graph(const URI& uri) { if (uri == INGEN_NS "externalContext") { return Graph::EXTERNAL; } else if (uri == INGEN_NS "internalContext") { @@ -78,27 +78,25 @@ public: * This is only useful for properties with a single value. If the * requested property has several values, the first will be returned. */ - virtual const Atom& get_property(const Raul::URI& uri) const; + virtual const Atom& get_property(const URI& uri) const; /** Set (replace) a property value. * * This will first erase any properties with the given `uri`, so after * this call exactly one property with predicate `uri` will be set. */ - virtual const Atom& set_property( - const Raul::URI& uri, - const Atom& value, - Graph ctx = Graph::DEFAULT); + virtual const Atom& set_property(const URI& uri, + const Atom& value, + Graph ctx = Graph::DEFAULT); /** Set (replace) a property value. * * This will first erase any properties with the given `uri`, so after * this call exactly one property with predicate `uri` will be set. */ - virtual const Atom& set_property( - const Raul::URI& uri, - const URIs::Quark& value, - Graph ctx = Graph::DEFAULT); + virtual const Atom& set_property(const URI& uri, + const URIs::Quark& value, + Graph ctx = Graph::DEFAULT); /** Add a property value. * @@ -108,32 +106,32 @@ public: * * @return True iff a new property was added. */ - virtual bool add_property(const Raul::URI& uri, - const Atom& value, - Graph ctx = Graph::DEFAULT); + virtual bool add_property(const URI& uri, + const Atom& value, + Graph ctx = Graph::DEFAULT); /** Remove a property. * * If `value` is patch:wildcard then any property with `uri` for a * predicate will be removed. */ - virtual void remove_property(const Raul::URI& uri, - const Atom& value); + virtual void remove_property(const URI& uri, + const Atom& value); /** Remove a property. * * If `value` is patch:wildcard then any property with `uri` for a * predicate will be removed. */ - virtual void remove_property(const Raul::URI& uri, + virtual void remove_property(const URI& uri, const URIs::Quark& value); /** Return true iff a property is set with a specific value. */ - virtual bool has_property(const Raul::URI& uri, - const Atom& value) const; + virtual bool has_property(const URI& uri, + const Atom& value) const; /** Return true iff a property is set with a specific value. */ - virtual bool has_property(const Raul::URI& uri, + virtual bool has_property(const URI& uri, const URIs::Quark& value) const; /** Set (replace) several properties at once. @@ -159,7 +157,7 @@ public: * This can be used by derived classes to implement special behaviour for * particular properties (e.g. ingen:value for ports). */ - virtual void on_property(const Raul::URI& uri, const Atom& value) {} + virtual void on_property(const URI& uri, const Atom& value) {} /** Hook called whenever a property value is removed. * @@ -168,7 +166,7 @@ public: * This can be used by derived classes to implement special behaviour for * particular properties (e.g. ingen:value for ports). */ - virtual void on_property_removed(const Raul::URI& uri, const Atom& value) {} + virtual void on_property_removed(const URI& uri, const Atom& value) {} /** Get the ingen type from a set of Properties. * @@ -182,23 +180,23 @@ public: bool& port, bool& is_output); - virtual void set_uri(const Raul::URI& uri) { _uri = uri; } + virtual void set_uri(const URI& uri) { _uri = uri; } /** Get all the properties with a given context. */ Properties properties(Resource::Graph ctx) const; const URIs& uris() const { return _uris; } - const Raul::URI& uri() const { return _uri; } + const URI& uri() const { return _uri; } const Properties& properties() const { return _properties; } Properties& properties() { return _properties; } protected: - const Atom& set_property(const Raul::URI& uri, const Atom& value) const; + const Atom& set_property(const URI& uri, const Atom& value) const; const URIs& _uris; private: - Raul::URI _uri; + URI _uri; mutable Properties _properties; }; diff --git a/ingen/Serialiser.hpp b/ingen/Serialiser.hpp index 00466350..50d4f693 100644 --- a/ingen/Serialiser.hpp +++ b/ingen/Serialiser.hpp @@ -30,6 +30,7 @@ namespace Ingen { class Arc; class Node; +class URI; class World; /** @@ -44,8 +45,8 @@ public: virtual ~Serialiser(); /** Write a graph and all its contents as a complete bundle. */ - virtual void write_bundle(SPtr<const Node> graph, - const std::string& uri); + virtual void write_bundle(SPtr<const Node> graph, + const URI& uri); /** Begin a serialization to a string. * @@ -57,8 +58,8 @@ public: * All serialized paths will have the root path chopped from their prefix * (therefore all serialized paths must be descendants of the root) */ - virtual void start_to_string(const Raul::Path& root, - const std::string& base_uri); + virtual void start_to_string(const Raul::Path& root, + const URI& base_uri); /** Begin a serialization to a file. * diff --git a/ingen/SocketWriter.hpp b/ingen/SocketWriter.hpp index bfd9b0f6..1dcc077b 100644 --- a/ingen/SocketWriter.hpp +++ b/ingen/SocketWriter.hpp @@ -25,11 +25,11 @@ namespace Raul { class Socket; -class URI; } namespace Ingen { +class URI; class URIMap; class URIs; @@ -40,7 +40,7 @@ class INGEN_API SocketWriter : public TurtleWriter public: SocketWriter(URIMap& map, URIs& uris, - const Raul::URI& uri, + const URI& uri, SPtr<Raul::Socket> sock); size_t text_sink(const void* buf, size_t len) override; diff --git a/ingen/StreamWriter.hpp b/ingen/StreamWriter.hpp index 3fe38646..66a03216 100644 --- a/ingen/StreamWriter.hpp +++ b/ingen/StreamWriter.hpp @@ -23,10 +23,9 @@ #include "ingen/ColorContext.hpp" #include "ingen/TurtleWriter.hpp" -namespace Raul { class URI; } - namespace Ingen { +class URI; class URIMap; class URIs; @@ -37,7 +36,7 @@ class INGEN_API StreamWriter : public TurtleWriter public: StreamWriter(URIMap& map, URIs& uris, - const Raul::URI& uri, + const URI& uri, FILE* stream, ColorContext::Color color); diff --git a/ingen/Tee.hpp b/ingen/Tee.hpp index b739e134..2a6f00df 100644 --- a/ingen/Tee.hpp +++ b/ingen/Tee.hpp @@ -25,7 +25,6 @@ #include "ingen/Interface.hpp" #include "ingen/Message.hpp" #include "ingen/types.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -52,7 +51,7 @@ public: } } - Raul::URI uri() const override { return Raul::URI("ingen:/tee"); } + URI uri() const override { return URI("ingen:/tee"); } private: std::mutex _sinks_mutex; diff --git a/ingen/TurtleWriter.hpp b/ingen/TurtleWriter.hpp index b11e3d37..8cf7ceb8 100644 --- a/ingen/TurtleWriter.hpp +++ b/ingen/TurtleWriter.hpp @@ -24,7 +24,6 @@ #include "ingen/AtomWriter.hpp" #include "ingen/ingen.h" #include "lv2/lv2plug.in/ns/ext/atom/atom.h" -#include "raul/URI.hpp" #include "serd/serd.h" #include "sratom/sratom.h" @@ -41,9 +40,7 @@ class URIs; class INGEN_API TurtleWriter : public AtomWriter, public AtomSink { public: - TurtleWriter(URIMap& map, - URIs& uris, - const Raul::URI& uri); + TurtleWriter(URIMap& map, URIs& uris, const URI& uri); ~TurtleWriter() override; @@ -53,7 +50,7 @@ public: /** Pure virtual text sink which receives calls serialized to Turtle. */ virtual size_t text_sink(const void* buf, size_t len) = 0; - Raul::URI uri() const override { return _uri; } + URI uri() const override { return _uri; } protected: URIMap& _map; @@ -62,7 +59,7 @@ protected: SerdURI _base_uri; SerdEnv* _env; SerdWriter* _writer; - Raul::URI _uri; + URI _uri; bool _wrote_prefixes; }; diff --git a/ingen/URI.hpp b/ingen/URI.hpp new file mode 100644 index 00000000..6b2adff4 --- /dev/null +++ b/ingen/URI.hpp @@ -0,0 +1,149 @@ +/* + This file is part of Ingen. + Copyright 2018 David Robillard <http://drobilla.net/> + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or any later version. + + Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef INGEN_URI_HPP +#define INGEN_URI_HPP + +#include <iosfwd> +#include <string> + +#include <boost/utility/string_view.hpp> + +#include "ingen/ingen.h" +#include "serd/serd.h" +#include "sord/sordmm.hpp" + +namespace Ingen { + +class INGEN_API URI +{ +public: + using Chunk = boost::string_view; + + URI(); + explicit URI(const std::string& str); + explicit URI(const char* str); + URI(const std::string& str, const URI& base); + explicit URI(const Sord::Node& node); + + URI(const URI& uri); + URI& operator=(const URI& uri); + + URI(URI&& uri); + URI& operator=(URI&& uri); + + ~URI(); + + bool empty() const { return !_node.buf; } + + std::string string() const { return std::string(c_str(), _node.n_bytes); } + size_t length() const { return _node.n_bytes; } + const char* c_str() const { return (const char*)_node.buf; } + + operator std::string() const { return string(); } + + const char* begin() const { return (const char*)_node.buf; } + const char* end() const { return (const char*)_node.buf + _node.n_bytes; } + + Chunk scheme() const { return make_chunk(_uri.scheme); } + Chunk authority() const { return make_chunk(_uri.authority); } + Chunk path() const { return make_chunk(_uri.path); } + Chunk query() const { return make_chunk(_uri.query); } + Chunk fragment() const { return make_chunk(_uri.fragment); } + + static bool is_valid(const char* str) { + return serd_uri_string_has_scheme((const uint8_t*)str); + } + + static bool is_valid(const std::string& str) + { + return is_valid(str.c_str()); + } + +private: + static Chunk make_chunk(const SerdChunk& chunk) { + return Chunk((const char*)chunk.buf, chunk.len); + } + + SerdNode _node; + SerdURI _uri; +}; + +inline bool operator==(const URI& lhs, const URI& rhs) +{ + return lhs.string() == rhs.string(); +} + +inline bool operator==(const URI& lhs, const std::string& rhs) +{ + return lhs.string() == rhs; +} + +inline bool operator==(const URI& lhs, const char* rhs) +{ + return lhs.string() == rhs; +} + +inline bool operator==(const URI& lhs, const Sord::Node& rhs) +{ + return rhs.type() == Sord::Node::URI && lhs.string() == rhs.to_string(); +} + +inline bool operator==(const Sord::Node& lhs, const URI& rhs) +{ + return rhs == lhs; +} + +inline bool operator!=(const URI& lhs, const URI& rhs) +{ + return lhs.string() != rhs.string(); +} + +inline bool operator!=(const URI& lhs, const std::string& rhs) +{ + return lhs.string() != rhs; +} + +inline bool operator!=(const URI& lhs, const char* rhs) +{ + return lhs.string() != rhs; +} + +inline bool operator!=(const URI& lhs, const Sord::Node& rhs) +{ + return !(lhs == rhs); +} + +inline bool operator!=(const Sord::Node& lhs, const URI& rhs) +{ + return !(lhs == rhs); +} + +inline bool operator<(const URI& lhs, const URI& rhs) +{ + return lhs.string() < rhs.string(); +} + +template <typename Char, typename Traits> +inline std::basic_ostream<Char, Traits>& +operator<<(std::basic_ostream<Char, Traits>& os, const URI& uri) +{ + return os << uri.string(); +} + +} // namespace Ingen + +#endif // INGEN_URI_HPP diff --git a/ingen/URIs.hpp b/ingen/URIs.hpp index c718322d..71c14d14 100644 --- a/ingen/URIs.hpp +++ b/ingen/URIs.hpp @@ -18,11 +18,11 @@ #define INGEN_URIS_HPP #include "ingen/Atom.hpp" +#include "ingen/URI.hpp" #include "ingen/ingen.h" #include "lilv/lilv.h" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" #include "raul/Noncopyable.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -41,7 +41,7 @@ class INGEN_API URIs : public Raul::Noncopyable { public: URIs(Ingen::Forge& forge, URIMap* map, LilvWorld* lworld); - struct Quark : public Raul::URI { + struct Quark : public URI { Quark(Ingen::Forge& forge, URIMap* map, LilvWorld* lworld, @@ -55,19 +55,6 @@ public: explicit operator Atom() const { return urid; } operator const LilvNode*() const { return lnode; } - inline bool operator==(const Atom& rhs) const { - if (rhs.type() == urid.type()) { - return rhs == urid; - } else if (rhs.type() == uri.type()) { - return rhs == uri; - } - return false; - } - - inline bool operator!=(const Atom& rhs) const { - return !operator==(rhs); - } - Atom urid; Atom uri; LilvNode* lnode; @@ -213,12 +200,33 @@ public: const Quark work_schedule; }; -inline bool operator==(const Atom& a, const URIs::Quark& b) { - return b == a; +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; + } + return false; +} + +inline bool +operator==(const Atom& lhs, const URIs::Quark& rhs) +{ + return rhs == lhs; +} + +inline bool +operator!=(const Atom& lhs, const URIs::Quark& rhs) +{ + return !(lhs == rhs); } -inline bool operator!=(const Atom& a, const URIs::Quark& b) { - return b != a; +inline bool +operator!=(const URIs::Quark& lhs, const Atom& rhs) +{ + return !(lhs == rhs); } } // namespace Ingen diff --git a/ingen/World.hpp b/ingen/World.hpp index 21d6c33b..13bd7001 100644 --- a/ingen/World.hpp +++ b/ingen/World.hpp @@ -28,7 +28,6 @@ typedef struct LilvWorldImpl LilvWorld; -namespace Raul { class URI; } namespace Sord { class World; } namespace Ingen { @@ -42,6 +41,7 @@ class Log; class Parser; class Serialiser; class Store; +class URI; class URIMap; class URIs; @@ -89,10 +89,9 @@ public: virtual bool run_module(const char* name); /** A function to create a new remote Interface. */ - typedef SPtr<Interface> (*InterfaceFactory)( - World* world, - const Raul::URI& engine_uri, - SPtr<Interface> respondee); + typedef SPtr<Interface> (*InterfaceFactory)(World* world, + const URI& engine_uri, + SPtr<Interface> respondee); /** Register an InterfaceFactory (for module implementations). */ virtual void add_interface_factory(const std::string& scheme, @@ -103,8 +102,8 @@ public: * @param respondee The Interface that will receive responses to commands * and broadcasts, if applicable. */ - virtual SPtr<Interface> new_interface(const Raul::URI& engine_uri, - SPtr<Interface> respondee); + virtual SPtr<Interface> new_interface(const URI& engine_uri, + SPtr<Interface> respondee); /** Run a script. */ virtual bool run(const std::string& mime_type, diff --git a/ingen/client/BlockModel.hpp b/ingen/client/BlockModel.hpp index 22613eca..38e8987e 100644 --- a/ingen/client/BlockModel.hpp +++ b/ingen/client/BlockModel.hpp @@ -58,7 +58,7 @@ public: Node* port(uint32_t index) const; - const Raul::URI& plugin_uri() const { return _plugin_uri; } + const URI& plugin_uri() const { return _plugin_uri; } const Resource* plugin() const { return _plugin.get(); } Resource* plugin() { return _plugin.get(); } SPtr<PluginModel> plugin_model() const { return _plugin; } @@ -86,7 +86,7 @@ protected: friend class ClientStore; BlockModel(URIs& uris, - const Raul::URI& plugin_uri, + const URI& plugin_uri, const Raul::Path& path); BlockModel(URIs& uris, SPtr<PluginModel> plugin, @@ -103,7 +103,7 @@ protected: virtual void clear(); Ports _ports; ///< Vector of ports - Raul::URI _plugin_uri; ///< Plugin URI (if PluginModel is unknown) + URI _plugin_uri; ///< Plugin URI (if PluginModel is unknown) SPtr<PluginModel> _plugin; ///< The plugin this block is an instance of private: diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp index 8850f401..797052ef 100644 --- a/ingen/client/ClientStore.hpp +++ b/ingen/client/ClientStore.hpp @@ -58,15 +58,15 @@ public: Log& log, SPtr<SigClientInterface> emitter = SPtr<SigClientInterface>()); - Raul::URI uri() const override { return Raul::URI("ingen:/clients/store"); } + URI uri() const override { return URI("ingen:/clients/store"); } SPtr<const ObjectModel> object(const Raul::Path& path) const; - SPtr<const PluginModel> plugin(const Raul::URI& uri) const; - SPtr<const Resource> resource(const Raul::URI& uri) const; + SPtr<const PluginModel> plugin(const URI& uri) const; + SPtr<const Resource> resource(const URI& uri) const; void clear(); - typedef std::map< const Raul::URI, SPtr<PluginModel> > Plugins; + typedef std::map< const URI, SPtr<PluginModel> > Plugins; SPtr<const Plugins> plugins() const { return _plugins; } SPtr<Plugins> plugins() { return _plugins; } void set_plugins(SPtr<Plugins> p) { _plugins = p; } @@ -94,13 +94,13 @@ public: INGEN_SIGNAL(new_object, void, SPtr<ObjectModel>); INGEN_SIGNAL(new_plugin, void, SPtr<PluginModel>); - INGEN_SIGNAL(plugin_deleted, void, Raul::URI); + INGEN_SIGNAL(plugin_deleted, void, URI); private: SPtr<ObjectModel> _object(const Raul::Path& path); - SPtr<PluginModel> _plugin(const Raul::URI& uri); + SPtr<PluginModel> _plugin(const URI& uri); SPtr<PluginModel> _plugin(const Atom& uri); - SPtr<Resource> _resource(const Raul::URI& uri); + SPtr<Resource> _resource(const URI& uri); void add_object(SPtr<ObjectModel> object); SPtr<ObjectModel> remove_object(const Raul::Path& path); diff --git a/ingen/client/ObjectModel.hpp b/ingen/client/ObjectModel.hpp index 4250efc5..a5a68f1e 100644 --- a/ingen/client/ObjectModel.hpp +++ b/ingen/client/ObjectModel.hpp @@ -27,7 +27,6 @@ #include "ingen/types.hpp" #include "raul/Path.hpp" -#include "raul/URI.hpp" #include "ingen/Node.hpp" #include "ingen/Resource.hpp" @@ -58,10 +57,10 @@ class INGEN_API ObjectModel : public Node public: bool is_a(const URIs::Quark& type) const; - const Atom& get_property(const Raul::URI& key) const; + const Atom& get_property(const URI& key) const; - void on_property(const Raul::URI& uri, const Atom& value); - void on_property_removed(const Raul::URI& uri, const Atom& value); + void on_property(const URI& uri, const Atom& value); + void on_property_removed(const URI& uri, const Atom& value); const Raul::Path& path() const { return _path; } const Raul::Symbol& symbol() const { return _symbol; } @@ -73,8 +72,8 @@ public: // Signals INGEN_SIGNAL(new_child, void, SPtr<ObjectModel>); INGEN_SIGNAL(removed_child, void, SPtr<ObjectModel>); - INGEN_SIGNAL(property, void, const Raul::URI&, const Atom&); - INGEN_SIGNAL(property_removed, void, const Raul::URI&, const Atom&); + INGEN_SIGNAL(property, void, const URI&, const Atom&); + INGEN_SIGNAL(property_removed, void, const URI&, const Atom&); INGEN_SIGNAL(destroyed, void); INGEN_SIGNAL(moved, void); diff --git a/ingen/client/PluginModel.hpp b/ingen/client/PluginModel.hpp index 585ac7d7..61de0f1a 100644 --- a/ingen/client/PluginModel.hpp +++ b/ingen/client/PluginModel.hpp @@ -50,18 +50,19 @@ class INGEN_API PluginModel : public Ingen::Resource { public: PluginModel(URIs& uris, - const Raul::URI& uri, + const URI& uri, const Atom& type, const Ingen::Properties& properties); - const Atom& type() const { return _type; } - const Raul::URI type_uri() const { - return Raul::URI(_type.is_valid() - ? _uris.forge.str(_type, false) - : "http://www.w3.org/2002/07/owl#Nothing"); + const Atom& type() const { return _type; } + + const URI type_uri() const + { + return URI(_type.is_valid() ? _uris.forge.str(_type, false) + : "http://www.w3.org/2002/07/owl#Nothing"); } - virtual const Atom& get_property(const Raul::URI& key) const; + virtual const Atom& get_property(const URI& key) const; Raul::Symbol default_block_symbol() const; std::string human_name() const; @@ -70,7 +71,7 @@ public: typedef std::map<float, std::string> ScalePoints; ScalePoints port_scale_points(uint32_t i) const; - typedef std::map<Raul::URI, std::string> Presets; + typedef std::map<URI, std::string> Presets; const Presets& presets() const { return _presets; } static LilvWorld* lilv_world() { return _lilv_world; } @@ -96,8 +97,8 @@ public: // Signals INGEN_SIGNAL(changed, void); - INGEN_SIGNAL(property, void, const Raul::URI&, const Atom&); - INGEN_SIGNAL(preset, void, const Raul::URI&, const std::string&); + INGEN_SIGNAL(property, void, const URI&, const Atom&); + INGEN_SIGNAL(preset, void, const URI&, const std::string&); bool fetched() const { return _fetched; } void set_fetched(bool f) { _fetched = f; } @@ -106,7 +107,7 @@ protected: friend class ClientStore; void set(SPtr<PluginModel> p); - void add_preset(const Raul::URI& uri, const std::string& label); + void add_preset(const URI& uri, const std::string& label); private: std::string get_documentation(const LilvNode* subject, bool html) const; diff --git a/ingen/client/PluginUI.hpp b/ingen/client/PluginUI.hpp index 45475cfe..a98df61d 100644 --- a/ingen/client/PluginUI.hpp +++ b/ingen/client/PluginUI.hpp @@ -76,8 +76,8 @@ public: * engine and/or update itself as necessary. */ INGEN_SIGNAL(property_changed, void, - const Raul::URI&, // Subject - const Raul::URI&, // Predicate + const URI&, // Subject + const URI&, // Predicate const Atom&, // Object Resource::Graph); // Context diff --git a/ingen/client/PortModel.hpp b/ingen/client/PortModel.hpp index f03e5bc1..9ad37378 100644 --- a/ingen/client/PortModel.hpp +++ b/ingen/client/PortModel.hpp @@ -63,7 +63,7 @@ public: inline bool operator==(const PortModel& pm) const { return (path() == pm.path()); } - void on_property(const Raul::URI& uri, const Atom& value); + void on_property(const URI& uri, const Atom& value); // Signals INGEN_SIGNAL(value_changed, void, const Atom&); diff --git a/ingen/client/SigClientInterface.hpp b/ingen/client/SigClientInterface.hpp index 4acc903b..6e94b257 100644 --- a/ingen/client/SigClientInterface.hpp +++ b/ingen/client/SigClientInterface.hpp @@ -46,7 +46,7 @@ class INGEN_API SigClientInterface : public Ingen::Interface, public: SigClientInterface() {} - Raul::URI uri() const override { return Raul::URI("ingen:/clients/sig"); } + URI uri() const override { return URI("ingen:/clients/sig"); } INGEN_SIGNAL(message, void, Message) diff --git a/ingen/client/SocketClient.hpp b/ingen/client/SocketClient.hpp index cceba9a3..8236200b 100644 --- a/ingen/client/SocketClient.hpp +++ b/ingen/client/SocketClient.hpp @@ -30,7 +30,7 @@ class INGEN_API SocketClient : public SocketWriter { public: SocketClient(World& world, - const Raul::URI& uri, + const URI& uri, SPtr<Raul::Socket> sock, SPtr<Interface> respondee) : SocketWriter(world.uri_map(), world.uris(), uri, sock) @@ -48,7 +48,7 @@ public: static SPtr<Ingen::Interface> new_socket_interface(Ingen::World* world, - const Raul::URI& uri, + const URI& uri, SPtr<Ingen::Interface> respondee) { const Raul::Socket::Type type = (uri.scheme() == "unix" diff --git a/ingen/client/ThreadedSigClientInterface.hpp b/ingen/client/ThreadedSigClientInterface.hpp index 6457d559..751ea37b 100644 --- a/ingen/client/ThreadedSigClientInterface.hpp +++ b/ingen/client/ThreadedSigClientInterface.hpp @@ -55,9 +55,7 @@ public: : message_slot(_signal_message.make_slot()) {} - Raul::URI uri() const override { - return Raul::URI("ingen:/clients/sig_queue"); - } + URI uri() const override { return URI("ingen:/clients/sig_queue"); } void message(const Message& msg) override { std::lock_guard<std::mutex> lock(_mutex); @@ -87,7 +85,6 @@ private: using Graph = Resource::Graph; using Path = Raul::Path; - using URI = Raul::URI; sigc::slot<void, Message> message_slot; }; diff --git a/ingen/paths.hpp b/ingen/paths.hpp index 3269a2ab..e75e71e0 100644 --- a/ingen/paths.hpp +++ b/ingen/paths.hpp @@ -20,33 +20,34 @@ #include <cstddef> #include <string> -#include "raul/URI.hpp" +#include "ingen/URI.hpp" #include "raul/Path.hpp" namespace Ingen { -inline Raul::URI main_uri() { return Raul::URI("ingen:/main"); } +inline URI main_uri() { return URI("ingen:/main"); } -inline bool uri_is_path(const Raul::URI& uri) +inline bool uri_is_path(const URI& uri) { - const size_t root_len = main_uri().length(); + const size_t root_len = main_uri().string().length(); if (uri == main_uri()) { return true; } else { - return uri.substr(0, root_len + 1) == main_uri() + "/"; + return uri.string().substr(0, root_len + 1) == + main_uri().string() + "/"; } } -inline Raul::Path uri_to_path(const Raul::URI& uri) +inline Raul::Path uri_to_path(const URI& uri) { return (uri == main_uri()) ? Raul::Path("/") - : Raul::Path(uri.substr(main_uri().length())); + : Raul::Path(uri.string().substr(main_uri().string().length())); } -inline Raul::URI path_to_uri(const Raul::Path& path) +inline URI path_to_uri(const Raul::Path& path) { - return Raul::URI(main_uri() + path.c_str()); + return URI(main_uri().string() + path.c_str()); } } // namespace Ingen diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp index 5aa39657..218110e4 100644 --- a/src/AtomReader.cpp +++ b/src/AtomReader.cpp @@ -64,44 +64,44 @@ AtomReader::get_props(const LV2_Atom_Object* obj, LV2_ATOM_OBJECT_FOREACH(obj, p) { Atom val; get_atom(&p->value, val); - props.emplace(Raul::URI(_map.unmap_uri(p->key)), val); + props.emplace(URI(_map.unmap_uri(p->key)), val); } } -boost::optional<Raul::URI> +boost::optional<URI> AtomReader::atom_to_uri(const LV2_Atom* atom) { if (!atom) { - return boost::optional<Raul::URI>(); + return boost::optional<URI>(); } else if (atom->type == _uris.atom_URI) { const char* str = (const char*)LV2_ATOM_BODY_CONST(atom); - if (Raul::URI::is_valid(str)) { - return Raul::URI(str); + if (URI::is_valid(str)) { + return URI(str); } else { _log.warn(fmt("Invalid URI <%1%>\n") % str); } } else if (atom->type == _uris.atom_Path) { const char* str = (const char*)LV2_ATOM_BODY_CONST(atom); if (!strncmp(str, "file://", 5)) { - return Raul::URI(str); + return URI(str); } else { - return Raul::URI(std::string("file://") + str); + return URI(std::string("file://") + str); } } else if (atom->type == _uris.atom_URID) { const char* str = _map.unmap_uri(((const LV2_Atom_URID*)atom)->body); if (str) { - return Raul::URI(str); + return URI(str); } else { _log.warn(fmt("Unknown URID %1%\n") % str); } } - return boost::optional<Raul::URI>(); + return boost::optional<URI>(); } boost::optional<Raul::Path> AtomReader::atom_to_path(const LV2_Atom* atom) { - boost::optional<Raul::URI> uri = atom_to_uri(atom); + boost::optional<URI> uri = atom_to_uri(atom); if (uri && uri_is_path(*uri)) { return uri_to_path(*uri); } @@ -113,7 +113,7 @@ AtomReader::atom_to_context(const LV2_Atom* atom) { Resource::Graph ctx = Resource::Graph::DEFAULT; if (atom) { - boost::optional<Raul::URI> maybe_uri = atom_to_uri(atom); + boost::optional<URI> maybe_uri = atom_to_uri(atom); if (maybe_uri) { ctx = Resource::uri_to_graph(*maybe_uri); } else { @@ -158,7 +158,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) (LV2_URID)_uris.patch_sequenceNumber, &number, NULL); - const boost::optional<Raul::URI> subject_uri = atom_to_uri(subject); + const boost::optional<URI> subject_uri = atom_to_uri(subject); const int32_t seq = ((number && number->type == _uris.atom_Int) ? ((const LV2_Atom_Int*)number)->body @@ -267,7 +267,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) get_atom(value, atom); _iface(SetProperty{seq, *subject_uri, - Raul::URI(_map.unmap_uri(prop->body)), + URI(_map.unmap_uri(prop->body)), atom, atom_to_context(context)}); } else if (obj->body.otype == _uris.patch_Patch) { @@ -313,13 +313,13 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) return false; } - boost::optional<Raul::URI> subject_uri(atom_to_uri(subject)); + boost::optional<URI> subject_uri(atom_to_uri(subject)); if (!subject_uri) { _log.warn("Copy message has non-path subject\n"); return false; } - boost::optional<Raul::URI> dest_uri(atom_to_uri(dest)); + boost::optional<URI> dest_uri(atom_to_uri(dest)); if (!dest_uri) { _log.warn("Copy message has non-URI destination\n"); return false; diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index 611b20d9..f235aafc 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -122,7 +122,7 @@ AtomWriter::operator()(const BundleEnd& message) } void -AtomWriter::forge_uri(const Raul::URI& uri) +AtomWriter::forge_uri(const URI& uri) { if (serd_uri_string_has_scheme((const uint8_t*)uri.c_str())) { lv2_atom_forge_urid(&_forge, _map.map_uri(uri.c_str())); @@ -137,7 +137,7 @@ AtomWriter::forge_properties(const Properties& properties) for (auto p : properties) { lv2_atom_forge_key(&_forge, _map.map_uri(p.first.c_str())); if (p.second.type() == _forge.URI) { - forge_uri(Raul::URI(p.second.ptr<char>())); + forge_uri(URI(p.second.ptr<char>())); } else { lv2_atom_forge_atom(&_forge, p.second.size(), p.second.type()); lv2_atom_forge_write(&_forge, p.second.get_body(), p.second.size()); @@ -606,7 +606,7 @@ AtomWriter::operator()(const Response& response) forge_request(&msg, _uris.patch_Response, 0); lv2_atom_forge_key(&_forge, _uris.patch_sequenceNumber); lv2_atom_forge_int(&_forge, response.id); - if (!subject.empty() && Raul::URI::is_valid(subject)) { + if (!subject.empty()) { lv2_atom_forge_key(&_forge, _uris.patch_subject); lv2_atom_forge_uri(&_forge, subject.c_str(), subject.length()); } diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp index dafd4472..ae4438a4 100644 --- a/src/ClashAvoider.cpp +++ b/src/ClashAvoider.cpp @@ -30,8 +30,8 @@ ClashAvoider::ClashAvoider(const Store& store) : _store(store) {} -const Raul::URI -ClashAvoider::map_uri(const Raul::URI& in) +const URI +ClashAvoider::map_uri(const URI& in) { if (uri_is_path(in)) { return path_to_uri(map_path(uri_to_path(in))); diff --git a/src/Forge.cpp b/src/Forge.cpp index a075d5a1..688d994d 100644 --- a/src/Forge.cpp +++ b/src/Forge.cpp @@ -17,9 +17,9 @@ #include <sstream> #include "ingen/Forge.hpp" +#include "ingen/URI.hpp" #include "ingen/URIMap.hpp" #include "lv2/lv2plug.in/ns/ext/atom/atom.h" -#include "raul/URI.hpp" namespace Ingen { @@ -30,9 +30,9 @@ Forge::Forge(URIMap& map) } Atom -Forge::make_urid(const Raul::URI& u) +Forge::make_urid(const Ingen::URI& u) { - const LV2_URID urid = _map.map_uri(u); + const LV2_URID urid = _map.map_uri(u.string()); return Atom(sizeof(int32_t), URID, &urid); } diff --git a/src/Parser.cpp b/src/Parser.cpp index d761c84e..e0ec0d35 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -44,19 +44,19 @@ namespace Ingen { std::set<Parser::ResourceRecord> -Parser::find_resources(Sord::World& world, - const std::string& manifest_uri, - const Raul::URI& type_uri) +Parser::find_resources(Sord::World& world, + const URI& manifest_uri, + const URI& type_uri) { - const Sord::URI base (world, manifest_uri); - const Sord::URI type (world, type_uri); + const Sord::URI base (world, manifest_uri.string()); + const Sord::URI type (world, type_uri.string()); const Sord::URI rdf_type (world, NS_RDF "type"); const Sord::URI rdfs_seeAlso(world, NS_RDFS "seeAlso"); const Sord::Node nil; SerdEnv* env = serd_env_new(sord_node_to_serd_node(base.c_obj())); - Sord::Model model(world, manifest_uri); - model.load_file(env, SERD_TURTLE, manifest_uri); + Sord::Model model(world, manifest_uri.string()); + model.load_file(env, SERD_TURTLE, manifest_uri.string()); std::set<ResourceRecord> resources; for (Sord::Iter i = model.find(nil, rdf_type, type); !i.end(); ++i) { @@ -69,7 +69,7 @@ Parser::find_resources(Sord::World& world, file_path = (const char*)p; free(p); } - resources.insert(ResourceRecord(resource.to_string(), file_path)); + resources.insert(ResourceRecord(URI(resource.to_string()), file_path)); } serd_env_free(env); @@ -117,9 +117,9 @@ static bool skip_property(Ingen::URIs& uris, const Sord::Node& predicate) { return (predicate.to_string() == INGEN__file || - predicate.to_string() == uris.ingen_arc || - predicate.to_string() == uris.ingen_block || - predicate.to_string() == uris.lv2_port); + predicate == uris.ingen_arc || + predicate == uris.ingen_block || + predicate == uris.lv2_port); } static Properties @@ -147,7 +147,7 @@ get_properties(Ingen::World* world, Atom atomm; atomm = world->forge().alloc( atom->size, atom->type, LV2_ATOM_BODY_CONST(atom)); - props.emplace(Raul::URI(i.get_predicate().to_string()), + props.emplace(URI(i.get_predicate().to_string()), Property(atomm, ctx)); } } @@ -250,7 +250,7 @@ parse_properties( Sord::Model& model, const Sord::Node& subject, Resource::Graph ctx, - const Raul::URI& uri, + const URI& uri, boost::optional<Properties> data = boost::optional<Properties>()); static bool @@ -535,7 +535,7 @@ parse_properties(Ingen::World* world, Sord::Model& model, const Sord::Node& subject, Resource::Graph ctx, - const Raul::URI& uri, + const URI& uri, boost::optional<Properties> data) { Properties properties = get_properties(world, model, subject, ctx); @@ -647,9 +647,9 @@ Parser::parse_file(Ingen::World* world, ? Glib::build_filename(file_path, "manifest.ttl") : file_path); - std::string manifest_uri; + URI manifest_uri; try { - manifest_uri = Glib::filename_to_uri(manifest_path); + manifest_uri = URI(Glib::filename_to_uri(manifest_path)); } catch (const Glib::ConvertError& e) { world->log().error(fmt("URI conversion error (%1%)\n") % e.what()); return false; @@ -657,7 +657,7 @@ Parser::parse_file(Ingen::World* world, // Find graphs in manifest const std::set<ResourceRecord> resources = find_resources( - *world->rdf_world(), manifest_uri, Raul::URI(INGEN__Graph)); + *world->rdf_world(), manifest_uri, URI(INGEN__Graph)); if (resources.empty()) { world->log().error(fmt("No graphs found in %1%\n") % path); @@ -667,7 +667,7 @@ Parser::parse_file(Ingen::World* world, /* Choose the graph to load. If this is a manifest, then there should only be one, but if this is a graph file, subgraphs will be returned as well. In this case, choose the one with the file URI. */ - std::string uri; + URI uri; for (const ResourceRecord& r : resources) { if (r.uri == Glib::filename_to_uri(manifest_path)) { uri = r.uri; @@ -694,7 +694,7 @@ Parser::parse_file(Ingen::World* world, SerdEnv* env = serd_env_new(&base_node); // Load graph into model - Sord::Model model(*world->rdf_world(), uri, SORD_SPO|SORD_PSO, false); + Sord::Model model(*world->rdf_world(), uri.string(), SORD_SPO|SORD_PSO, false); model.load_file(env, SERD_TURTLE, file_uri); serd_env_free(env); @@ -706,15 +706,15 @@ Parser::parse_file(Ingen::World* world, world->log().info(fmt("Symbol: %1%\n") % symbol->c_str()); } - Sord::Node subject(*world->rdf_world(), Sord::Node::URI, uri); + Sord::Node subject(*world->rdf_world(), Sord::Node::URI, uri.string()); boost::optional<Raul::Path> parsed_path = parse(world, target, model, model.base_uri().to_string(), subject, parent, symbol, data); if (parsed_path) { target->set_property(path_to_uri(*parsed_path), - Raul::URI(INGEN__file), - world->forge().alloc_uri(uri)); + URI(INGEN__file), + world->forge().alloc_uri(uri.string())); return true; } else { world->log().warn("Document URI lost\n"); @@ -722,7 +722,7 @@ Parser::parse_file(Ingen::World* world, } } -boost::optional<Raul::URI> +boost::optional<URI> Parser::parse_string(Ingen::World* world, Ingen::Interface* target, const std::string& str, @@ -742,7 +742,7 @@ Parser::parse_string(Ingen::World* world, } model.load_string(env, SERD_TURTLE, str.c_str(), str.length(), base_uri); - Raul::URI actual_base((const char*)serd_env_get_base_uri(env, nullptr)->buf); + URI actual_base((const char*)serd_env_get_base_uri(env, nullptr)->buf); serd_env_free(env); world->log().info(fmt("Parsing string (base %1%)\n") % base_uri); diff --git a/src/Resource.cpp b/src/Resource.cpp index 05c4fb4e..d0261eee 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -25,9 +25,7 @@ namespace Ingen { bool -Resource::add_property(const Raul::URI& uri, - const Atom& value, - Graph ctx) +Resource::add_property(const URI& uri, const Atom& value, Graph ctx) { // Ignore duplicate statements typedef Properties::const_iterator iterator; @@ -51,9 +49,7 @@ Resource::add_property(const Raul::URI& uri, } const Atom& -Resource::set_property(const Raul::URI& uri, - const Atom& value, - Resource::Graph ctx) +Resource::set_property(const URI& uri, const Atom& value, Resource::Graph ctx) { // Erase existing property in this context for (auto i = _properties.find(uri); @@ -81,7 +77,7 @@ Resource::set_property(const Raul::URI& uri, } const Atom& -Resource::set_property(const Raul::URI& uri, +Resource::set_property(const URI& uri, const URIs::Quark& value, Resource::Graph ctx) { @@ -89,7 +85,7 @@ Resource::set_property(const Raul::URI& uri, } void -Resource::remove_property(const Raul::URI& uri, const Atom& value) +Resource::remove_property(const URI& uri, const Atom& value) { if (_uris.patch_wildcard == value) { _properties.erase(uri); @@ -107,20 +103,20 @@ Resource::remove_property(const Raul::URI& uri, const Atom& value) } void -Resource::remove_property(const Raul::URI& uri, const URIs::Quark& value) +Resource::remove_property(const URI& uri, const URIs::Quark& value) { remove_property(uri, value.urid); remove_property(uri, value.uri); } bool -Resource::has_property(const Raul::URI& uri, const Atom& value) const +Resource::has_property(const URI& uri, const Atom& value) const { return _properties.contains(uri, value); } bool -Resource::has_property(const Raul::URI& uri, const URIs::Quark& value) const +Resource::has_property(const URI& uri, const URIs::Quark& value) const { Properties::const_iterator i = _properties.find(uri); for (; (i != _properties.end()) && (i->first == uri); ++i) { @@ -132,13 +128,13 @@ Resource::has_property(const Raul::URI& uri, const URIs::Quark& value) const } const Atom& -Resource::set_property(const Raul::URI& uri, const Atom& value) const +Resource::set_property(const URI& uri, const Atom& value) const { return const_cast<Resource*>(this)->set_property(uri, value); } const Atom& -Resource::get_property(const Raul::URI& uri) const +Resource::get_property(const URI& uri) const { static const Atom nil; Properties::const_iterator i = _properties.find(uri); diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index 13a0f96d..b572b453 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -38,6 +38,7 @@ #include "ingen/Resource.hpp" #include "ingen/Serialiser.hpp" #include "ingen/Store.hpp" +#include "ingen/URI.hpp" #include "ingen/URIMap.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" @@ -81,8 +82,7 @@ struct Serialiser::Impl { void serialise_properties(Sord::Node id, const Properties& props); - void write_bundle(SPtr<const Node> graph, - const std::string& uri); + void write_bundle(SPtr<const Node> graph, const URI& uri); Sord::Node path_rdf_node(const Raul::Path& path); @@ -100,7 +100,7 @@ struct Serialiser::Impl { Raul::Path _root_path; Mode _mode; - std::string _base_uri; + URI _base_uri; std::string _basename; World& _world; Sord::Model* _model; @@ -129,7 +129,7 @@ Serialiser::Impl::write_manifest(const std::string& bundle_path, const URIs& uris = _world.uris(); const string filename("main.ttl"); - const Sord::URI subject(world, filename, _base_uri); + const Sord::URI subject(world, filename, _base_uri.string()); _model->add_statement(subject, Sord::URI(world, uris.rdf_type), @@ -139,7 +139,7 @@ Serialiser::Impl::write_manifest(const std::string& bundle_path, Sord::URI(world, uris.lv2_Plugin)); _model->add_statement(subject, Sord::URI(world, uris.rdfs_seeAlso), - Sord::URI(world, filename, _base_uri)); + Sord::URI(world, filename, _base_uri.string())); _model->add_statement(subject, Sord::URI(world, uris.lv2_prototype), Sord::URI(world, uris.ingen_GraphPrototype)); @@ -180,17 +180,15 @@ Serialiser::Impl::write_plugins(const std::string& bundle_path, } void -Serialiser::write_bundle(SPtr<const Node> graph, - const std::string& uri) +Serialiser::write_bundle(SPtr<const Node> graph, const URI& uri) { me->write_bundle(graph, uri); } void -Serialiser::Impl::write_bundle(SPtr<const Node> graph, - const std::string& uri) +Serialiser::Impl::write_bundle(SPtr<const Node> graph, const URI& uri) { - std::string path = Glib::filename_from_uri(uri); + std::string path = Glib::filename_from_uri(uri.string()); if (Glib::file_test(path, Glib::FILE_TEST_EXISTS) && !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) { path = Glib::path_get_dirname(path); @@ -210,7 +208,7 @@ Serialiser::Impl::write_bundle(SPtr<const Node> graph, start_to_file(graph->path(), main_file); std::set<const Resource*> plugins = serialise_graph( - graph, Sord::URI(_model->world(), main_file, _base_uri)); + graph, Sord::URI(_model->world(), main_file, _base_uri.string())); finish(); write_manifest(path, graph); @@ -229,9 +227,9 @@ Serialiser::Impl::start_to_file(const Raul::Path& root, const string& filename) // Set Base URI assert(filename.find(":") == string::npos || filename.substr(0, 5) == "file:"); if (filename.find(":") == string::npos) { - _base_uri = "file://" + filename; + _base_uri = URI("file://" + filename); } else { - _base_uri = filename; + _base_uri = URI(filename); } // Find graph basename to use as symbol / fallback name @@ -240,17 +238,17 @@ Serialiser::Impl::start_to_file(const Raul::Path& root, const string& filename) _basename = Glib::path_get_basename(Glib::path_get_dirname(filename)); } - _model = new Sord::Model(*_world.rdf_world(), _base_uri); + _model = new Sord::Model(*_world.rdf_world(), _base_uri.string()); _mode = Mode::TO_FILE; _root_path = root; } void -Serialiser::start_to_string(const Raul::Path& root, const string& base_uri) +Serialiser::start_to_string(const Raul::Path& root, const URI& base_uri) { me->_root_path = root; me->_base_uri = base_uri; - me->_model = new Sord::Model(*me->_world.rdf_world(), base_uri); + me->_model = new Sord::Model(*me->_world.rdf_world(), base_uri.string()); me->_mode = Impl::Mode::TO_STRING; } @@ -271,18 +269,18 @@ Serialiser::Impl::finish() { string ret = ""; if (_mode == Mode::TO_FILE) { - SerdStatus st = _model->write_to_file(_base_uri, SERD_TURTLE); + SerdStatus st = _model->write_to_file(_base_uri.string(), SERD_TURTLE); if (st) { _world.log().error(fmt("Error writing file %1% (%2%)\n") % _base_uri % serd_strerror(st)); } } else { - ret = _model->write_to_string(_base_uri, SERD_TURTLE); + ret = _model->write_to_string(_base_uri.string(), SERD_TURTLE); } delete _model; _model = nullptr; - _base_uri = ""; + _base_uri = URI(); return ret; } @@ -294,7 +292,7 @@ Serialiser::Impl::path_rdf_node(const Raul::Path& path) assert(path == _root_path || path.is_child_of(_root_path)); return Sord::URI(_model->world(), path.substr(_root_path.base().length()), - _base_uri); + _base_uri.string()); } void @@ -378,11 +376,11 @@ Serialiser::Impl::serialise_graph(SPtr<const Node> graph, const Sord::URI subgraph_id(world, (const char*)subgraph_node.buf); // Save our state - std::string my_base_uri = _base_uri; + URI my_base_uri = _base_uri; Sord::Model* my_model = _model; // Write child bundle within this bundle - write_bundle(subgraph, subgraph_id.to_string()); + write_bundle(subgraph, URI(subgraph_id.to_string())); // Restore our state _base_uri = my_base_uri; @@ -451,8 +449,8 @@ Serialiser::Impl::serialise_block(SPtr<const Node> block, props.erase(uris.state_state); serialise_properties(block_id, props); - if (_base_uri.substr(0, 5) == "file:") { - const std::string base = Glib::filename_from_uri(_base_uri); + if (_base_uri.scheme() == "file") { + const std::string base = Glib::filename_from_uri(_base_uri.string()); const std::string graph_dir = Glib::path_get_dirname(base); const std::string state_dir = Glib::build_filename(graph_dir, block->symbol()); const std::string state_file = Glib::build_filename(state_dir, "state.ttl"); @@ -557,9 +555,9 @@ static bool skip_property(Ingen::URIs& uris, const Sord::Node& predicate) { return (predicate.to_string() == INGEN__file || - predicate.to_string() == uris.ingen_arc || - predicate.to_string() == uris.ingen_block || - predicate.to_string() == uris.lv2_port); + predicate == uris.ingen_arc || + predicate == uris.ingen_block || + predicate == uris.lv2_port); } void diff --git a/src/SocketWriter.cpp b/src/SocketWriter.cpp index 9274fe57..68091bcc 100644 --- a/src/SocketWriter.cpp +++ b/src/SocketWriter.cpp @@ -29,7 +29,7 @@ namespace Ingen { SocketWriter::SocketWriter(URIMap& map, URIs& uris, - const Raul::URI& uri, + const URI& uri, SPtr<Raul::Socket> sock) : TurtleWriter(map, uris, uri) , _socket(std::move(sock)) diff --git a/src/StreamWriter.cpp b/src/StreamWriter.cpp index a4e5b761..45853055 100644 --- a/src/StreamWriter.cpp +++ b/src/StreamWriter.cpp @@ -21,7 +21,7 @@ namespace Ingen { StreamWriter::StreamWriter(URIMap& map, URIs& uris, - const Raul::URI& uri, + const URI& uri, FILE* stream, ColorContext::Color color) : TurtleWriter(map, uris, uri) diff --git a/src/TurtleWriter.cpp b/src/TurtleWriter.cpp index 630906e7..368184d4 100644 --- a/src/TurtleWriter.cpp +++ b/src/TurtleWriter.cpp @@ -35,14 +35,12 @@ write_prefix(void* handle, const SerdNode* name, const SerdNode* uri) return SERD_SUCCESS; } -TurtleWriter::TurtleWriter(URIMap& map, - URIs& uris, - const Raul::URI& uri) - : AtomWriter(map, uris, *this) - , _map(map) - , _sratom(sratom_new(&map.urid_map_feature()->urid_map)) - , _uri(uri) - , _wrote_prefixes(false) +TurtleWriter::TurtleWriter(URIMap& map, URIs& uris, const URI& uri) + : AtomWriter(map, uris, *this) + , _map(map) + , _sratom(sratom_new(&map.urid_map_feature()->urid_map)) + , _uri(uri) + , _wrote_prefixes(false) { // Use <ingen:/> as base URI, so relative URIs are like bundle paths _base = serd_node_from_string(SERD_URI, (const uint8_t*)"ingen:/"); diff --git a/src/URI.cpp b/src/URI.cpp new file mode 100644 index 00000000..cc7dde46 --- /dev/null +++ b/src/URI.cpp @@ -0,0 +1,85 @@ +/* + This file is part of Ingen. + Copyright 2018 David Robillard <http://drobilla.net/> + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or any later version. + + Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <cassert> + +#include "ingen/URI.hpp" + +namespace Ingen { + +URI::URI() + : _node(SERD_NODE_NULL) + , _uri(SERD_URI_NULL) +{} + +URI::URI(const std::string& str) + : _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(), + NULL, + &_uri)) +{} + +URI::URI(const char* str) + : _node(serd_node_new_uri_from_string((const uint8_t*)str, NULL, &_uri)) +{} + +URI::URI(const std::string& str, const URI& base) + : _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(), + &base._uri, + &_uri)) +{} + +URI::URI(const Sord::Node& node) + : _node(serd_node_new_uri_from_node(node.to_serd_node(), NULL, &_uri)) +{ + assert(node.type() == Sord::Node::URI); +} + +URI::URI(const URI& uri) + : _node(serd_node_new_uri(&uri._uri, NULL, &_uri)) +{} + +URI& +URI::operator=(const URI& uri) +{ + serd_node_free(&_node); + _node = serd_node_new_uri(&uri._uri, NULL, &_uri); + return *this; +} + +URI::URI(URI&& uri) + : _node(uri._node) + , _uri(uri._uri) +{ + uri._node = SERD_NODE_NULL; + uri._uri = SERD_URI_NULL; +} + +URI& +URI::operator=(URI&& uri) +{ + _node = uri._node; + _uri = uri._uri; + uri._node = SERD_NODE_NULL; + uri._uri = SERD_URI_NULL; + return *this; +} + +URI::~URI() +{ + serd_node_free(&_node); +} + +} // namespace Ingen diff --git a/src/URIMap.cpp b/src/URIMap.cpp index 1dcf8a24..0be308d7 100644 --- a/src/URIMap.cpp +++ b/src/URIMap.cpp @@ -19,8 +19,8 @@ #include <glib.h> #include "ingen/Log.hpp" +#include "ingen/URI.hpp" #include "ingen/URIMap.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -54,7 +54,7 @@ URIMap::URIDMapFeature::default_map(LV2_URID_Map_Handle h, LV2_URID URIMap::URIDMapFeature::map(const char* uri) { - if (!Raul::URI::is_valid(uri)) { + if (!URI::is_valid(uri)) { log.error(fmt("Attempt to map invalid URI <%1%>\n") % uri); return 0; } diff --git a/src/URIs.cpp b/src/URIs.cpp index 3e56e4f4..af03b7b5 100644 --- a/src/URIs.cpp +++ b/src/URIs.cpp @@ -40,14 +40,14 @@ URIs::Quark::Quark(Forge& forge, URIMap* map, LilvWorld* lworld, const char* str) - : Raul::URI(str) - , urid(forge.make_urid(Raul::URI(str))) + : URI(str) + , urid(forge.make_urid(URI(str))) , uri(forge.alloc_uri(str)) , lnode(lilv_new_uri(lworld, str)) {} URIs::Quark::Quark(const Quark& copy) - : Raul::URI(copy) + : URI(copy) , urid(copy.urid) , uri(copy.uri) , lnode(lilv_node_duplicate(copy.lnode)) diff --git a/src/World.cpp b/src/World.cpp index 8797bb3e..7834c3df 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -312,10 +312,10 @@ World::run_module(const char* name) /** Get an interface for a remote engine at `engine_uri` */ SPtr<Interface> -World::new_interface(const Raul::URI& engine_uri, - SPtr<Interface> respondee) +World::new_interface(const URI& engine_uri, SPtr<Interface> respondee) { - const Impl::InterfaceFactories::const_iterator i = _impl->interface_factories.find(engine_uri.scheme()); + const Impl::InterfaceFactories::const_iterator i = + _impl->interface_factories.find(std::string(engine_uri.scheme())); if (i == _impl->interface_factories.end()) { log().warn(fmt("Unknown URI scheme `%1%'\n") % engine_uri.scheme()); return SPtr<Interface>(); diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp index cf778408..910f7037 100644 --- a/src/client/BlockModel.cpp +++ b/src/client/BlockModel.cpp @@ -38,7 +38,7 @@ BlockModel::BlockModel(URIs& uris, } BlockModel::BlockModel(URIs& uris, - const Raul::URI& plugin_uri, + const URI& plugin_uri, const Raul::Path& path) : ObjectModel(uris, path) , _plugin_uri(plugin_uri) @@ -245,7 +245,7 @@ BlockModel::label() const std::string BlockModel::port_label(SPtr<const PortModel> port) const { - const Atom& name = port->get_property(Raul::URI(LV2_CORE__name)); + const Atom& name = port->get_property(URI(LV2_CORE__name)); if (name.is_valid() && name.type() == _uris.forge.String) { return name.ptr<char>(); } diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 706b2c5b..792f8949 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -124,7 +124,7 @@ ClientStore::remove_object(const Raul::Path& path) } SPtr<PluginModel> -ClientStore::_plugin(const Raul::URI& uri) +ClientStore::_plugin(const URI& uri) { const Plugins::iterator i = _plugins->find(uri); return (i == _plugins->end()) ? SPtr<PluginModel>() : (*i).second; @@ -136,12 +136,12 @@ ClientStore::_plugin(const Atom& uri) /* FIXME: Should probably be stored with URIs rather than strings, to make this a fast case. */ - const Plugins::iterator i = _plugins->find(Raul::URI(_uris.forge.str(uri, false))); + const Plugins::iterator i = _plugins->find(URI(_uris.forge.str(uri, false))); return (i == _plugins->end()) ? SPtr<PluginModel>() : (*i).second; } SPtr<const PluginModel> -ClientStore::plugin(const Raul::URI& uri) const +ClientStore::plugin(const URI& uri) const { return const_cast<ClientStore*>(this)->_plugin(uri); } @@ -167,7 +167,7 @@ ClientStore::object(const Raul::Path& path) const } SPtr<Resource> -ClientStore::_resource(const Raul::URI& uri) +ClientStore::_resource(const URI& uri) { if (uri_is_path(uri)) { return _object(uri_to_path(uri)); @@ -177,7 +177,7 @@ ClientStore::_resource(const Raul::URI& uri) } SPtr<const Resource> -ClientStore::resource(const Raul::URI& uri) const +ClientStore::resource(const URI& uri) const { return const_cast<ClientStore*>(this)->_resource(uri); } @@ -304,7 +304,7 @@ ClientStore::operator()(const Put& msg) SPtr<PluginModel> plug; if (p->second.is_valid() && (p->second.type() == _uris.forge.URI || p->second.type() == _uris.forge.URID)) { - const Raul::URI uri(_uris.forge.str(p->second, false)); + const URI uri(_uris.forge.str(p->second, false)); if (!(plug = _plugin(uri))) { plug = SPtr<PluginModel>( new PluginModel(uris(), uri, Atom(), Properties())); @@ -339,7 +339,7 @@ void ClientStore::operator()(const Delta& msg) { const auto& uri = msg.uri; - if (uri == Raul::URI("ingen:/clients/this")) { + if (uri == URI("ingen:/clients/this")) { // Client property, which we don't store (yet?) return; } @@ -368,7 +368,7 @@ ClientStore::operator()(const SetProperty& msg) const auto& predicate = msg.predicate; const auto& value = msg.value; - if (subject_uri == Raul::URI("ingen:/engine")) { + if (subject_uri == URI("ingen:/engine")) { _log.info(fmt("Engine property <%1%> = %2%\n") % predicate.c_str() % _uris.forge.str(value, false)); return; diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 45136546..8d40b120 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -43,19 +43,19 @@ ObjectModel::is_a(const URIs::Quark& type) const } void -ObjectModel::on_property(const Raul::URI& uri, const Atom& value) +ObjectModel::on_property(const URI& uri, const Atom& value) { _signal_property.emit(uri, value); } void -ObjectModel::on_property_removed(const Raul::URI& uri, const Atom& value) +ObjectModel::on_property_removed(const URI& uri, const Atom& value) { _signal_property_removed.emit(uri, value); } const Atom& -ObjectModel::get_property(const Raul::URI& key) const +ObjectModel::get_property(const URI& key) const { static const Atom null_atom; auto i = properties().find(key); diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 2ab4ccae..0cf1419d 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -41,7 +41,7 @@ const LilvPlugins* PluginModel::_lilv_plugins = nullptr; Sord::World* PluginModel::_rdf_world = nullptr; PluginModel::PluginModel(URIs& uris, - const Raul::URI& uri, + const URI& uri, const Atom& type, const Properties& properties) : Resource(uris, uri) @@ -49,7 +49,7 @@ PluginModel::PluginModel(URIs& uris, , _fetched(false) { if (!_type.is_valid()) { - if (uri.find("ingen-internals") != string::npos) { + if (uri.string().find("ingen-internals") != string::npos) { _type = uris.ingen_Internal.urid; } else { _type = uris.lv2_Plugin.urid; // Assume LV2 and hope for the best... @@ -65,7 +65,7 @@ PluginModel::PluginModel(URIs& uris, if (uris.ingen_Internal == _type) { set_property(uris.doap_name, - uris.forge.alloc(uri.substr(uri.find_last_of('#') + 1))); + uris.forge.alloc(std::string(uri.fragment().substr(1)))); } } @@ -93,7 +93,7 @@ contains_alpha_after(const std::string& str, size_t begin) } const Atom& -PluginModel::get_property(const Raul::URI& key) const +PluginModel::get_property(const URI& key) const { static const Atom nil; const Atom& val = Resource::get_property(key); @@ -126,7 +126,7 @@ PluginModel::get_property(const Raul::URI& key) const const LilvNode* val = lilv_nodes_get(values, i); if (lilv_node_is_uri(val)) { ret = set_property( - key, _uris.forge.make_urid(Raul::URI(lilv_node_as_uri(val)))); + key, _uris.forge.make_urid(URI(lilv_node_as_uri(val)))); break; } else if (lilv_node_is_string(val)) { ret = set_property( @@ -170,7 +170,7 @@ PluginModel::set(SPtr<PluginModel> p) } void -PluginModel::add_preset(const Raul::URI& uri, const std::string& label) +PluginModel::add_preset(const URI& uri, const std::string& label) { _presets.emplace(uri, label); _signal_preset.emit(uri, label); diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp index 7e5456dd..5c9a8c77 100644 --- a/src/client/PortModel.cpp +++ b/src/client/PortModel.cpp @@ -21,7 +21,7 @@ namespace Ingen { namespace Client { void -PortModel::on_property(const Raul::URI& uri, const Atom& value) +PortModel::on_property(const URI& uri, const Atom& value) { if (uri == _uris.ingen_activity) { // Don't store activity, it is transient diff --git a/src/gui/App.cpp b/src/gui/App.cpp index 1473320b..a8128d8d 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -177,7 +177,7 @@ App::attach(SPtr<SigClientInterface> client) if (_world->conf().option("dump").get<int32_t>()) { _dumper = SPtr<StreamWriter>(new StreamWriter(_world->uri_map(), _world->uris(), - Raul::URI("ingen:/client"), + URI("ingen:/client"), stderr, ColorContext::Color::CYAN)); @@ -207,7 +207,7 @@ void App::request_plugins_if_necessary() { if (!_requested_plugins) { - _world->interface()->get(Raul::URI("ingen:/plugins")); + _world->interface()->get(URI("ingen:/plugins")); _requested_plugins = true; } } @@ -251,10 +251,10 @@ App::error_message(const std::string& str) } void -App::set_property(const Raul::URI& subject, - const Raul::URI& key, - const Atom& value, - Resource::Graph ctx) +App::set_property(const URI& subject, + const URI& key, + const Atom& value, + Resource::Graph ctx) { // Send message to server interface()->set_property(subject, key, value, ctx); @@ -278,7 +278,7 @@ App::set_tooltip(Gtk::Widget* widget, const LilvNode* node) } void -App::put(const Raul::URI& uri, +App::put(const URI& uri, const Properties& properties, Resource::Graph ctx) { @@ -292,12 +292,12 @@ App::put(const Raul::URI& uri, } void -App::property_change(const Raul::URI& subject, - const Raul::URI& key, - const Atom& value, - Resource::Graph ctx) +App::property_change(const URI& subject, + const URI& key, + const Atom& value, + Resource::Graph ctx) { - if (subject != Raul::URI("ingen:/engine")) { + if (subject != URI("ingen:/engine")) { return; } else if (key == uris().param_sampleRate && value.type() == forge().Int) { _sample_rate = value.get<int32_t>(); diff --git a/src/gui/App.hpp b/src/gui/App.hpp index 22451846..573925e6 100644 --- a/src/gui/App.hpp +++ b/src/gui/App.hpp @@ -33,7 +33,6 @@ #include "ingen/types.hpp" #include "lilv/lilv.h" #include "raul/Deletable.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -100,10 +99,10 @@ public: return old; } - void set_property(const Raul::URI& subject, - const Raul::URI& key, - const Atom& value, - Resource::Graph ctx = Resource::Graph::DEFAULT); + void set_property(const URI& subject, + const URI& key, + const Atom& value, + Resource::Graph ctx = Resource::Graph::DEFAULT); /** Set the tooltip for a widget from its RDF documentation. */ void set_tooltip(Gtk::Widget* widget, const LilvNode* node); @@ -147,14 +146,14 @@ protected: bool animate(); void response(int32_t id, Ingen::Status status, const std::string& subject); - void put(const Raul::URI& uri, + void put(const URI& uri, const Properties& properties, Resource::Graph ctx); - void property_change(const Raul::URI& subject, - const Raul::URI& key, - const Atom& value, - Resource::Graph ctx = Resource::Graph::DEFAULT); + void property_change(const URI& subject, + const URI& key, + const Atom& value, + Resource::Graph ctx = Resource::Graph::DEFAULT); static Gtk::Main* _main; diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp index 693b81e1..3f69e998 100644 --- a/src/gui/BreadCrumbs.cpp +++ b/src/gui/BreadCrumbs.cpp @@ -200,7 +200,7 @@ BreadCrumbs::message(const Message& msg) } void -BreadCrumbs::object_destroyed(const Raul::URI& uri) +BreadCrumbs::object_destroyed(const URI& uri) { for (auto i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) { if ((*i)->path() == uri.c_str()) { diff --git a/src/gui/BreadCrumbs.hpp b/src/gui/BreadCrumbs.hpp index 22bbd7af..467d3bfc 100644 --- a/src/gui/BreadCrumbs.hpp +++ b/src/gui/BreadCrumbs.hpp @@ -104,7 +104,7 @@ private: void breadcrumb_clicked(BreadCrumb* crumb); void message(const Message& msg); - void object_destroyed(const Raul::URI& uri); + void object_destroyed(const URI& uri); void object_moved(const Raul::Path& old_path, const Raul::Path& new_path); Raul::Path _active_path; diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index 7cacb498..8f235264 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -141,7 +141,7 @@ ConnectWindow::set_connected_to(SPtr<Ingen::Interface> engine) _progress_bar->set_fraction(1.0); _progress_label->set_text("Connected to engine"); _url_entry->set_sensitive(false); - _url_entry->set_text(engine->uri()); + _url_entry->set_text(engine->uri().string()); _connect_button->set_sensitive(false); _disconnect_button->set_label("gtk-disconnect"); _disconnect_button->set_sensitive(true); @@ -190,7 +190,7 @@ ConnectWindow::set_connecting_widget_states() } bool -ConnectWindow::connect_remote(const Raul::URI& uri) +ConnectWindow::connect_remote(const URI& uri) { Ingen::World* world = _app->world(); @@ -241,12 +241,12 @@ ConnectWindow::connect(bool existing) uri_str = _url_entry->get_text(); } - if (!Raul::URI::is_valid(uri_str)) { + if (!URI::is_valid(uri_str)) { error((fmt("Invalid socket URI %1%") % uri_str).str()); return; } - _connect_uri = Raul::URI(uri_str); + _connect_uri = URI(uri_str); } else if (_mode == Mode::LAUNCH_REMOTE) { const std::string port = std::to_string(_port_spinbutton->get_value_as_int()); @@ -257,7 +257,7 @@ ConnectWindow::connect(bool existing) return; } - _connect_uri = Raul::URI(std::string("tcp://localhost:") + port); + _connect_uri = URI(std::string("tcp://localhost:") + port); } else if (_mode == Mode::INTERNAL) { if (!world->engine()) { @@ -310,7 +310,7 @@ ConnectWindow::activate() return; } - _app->interface()->set_property(Raul::URI("ingen:/driver"), + _app->interface()->set_property(URI("ingen:/driver"), _app->uris().ingen_enabled, _app->forge().make(true)); } @@ -322,7 +322,7 @@ ConnectWindow::deactivate() return; } - _app->interface()->set_property(Raul::URI("ingen:/driver"), + _app->interface()->set_property(URI("ingen:/driver"), _app->uris().ingen_enabled, _app->forge().make(false)); } @@ -376,8 +376,8 @@ ConnectWindow::load_widgets() sigc::mem_fun(this, &ConnectWindow::quit_clicked)); _url_entry->set_text(_app->world()->conf().option("connect").ptr<char>()); - if (Raul::URI::is_valid(_url_entry->get_text())) { - _connect_uri = Raul::URI(_url_entry->get_text()); + if (URI::is_valid(_url_entry->get_text())) { + _connect_uri = URI(_url_entry->get_text()); } _port_spinbutton->set_range(1, std::numeric_limits<uint16_t>::max()); @@ -499,7 +499,7 @@ ConnectWindow::gtk_callback() _ping_id = g_random_int_range(1, std::numeric_limits<int32_t>::max()); _app->interface()->set_response_id(_ping_id); - _app->interface()->get(Raul::URI("ingen:/engine")); + _app->interface()->get(URI("ingen:/engine")); last = now; attempts = 0; next_stage(); @@ -515,13 +515,13 @@ ConnectWindow::gtk_callback() _connect_stage = -1; } else if (ms_since_last > 1000) { _app->interface()->set_response_id(_ping_id); - _app->interface()->get(Raul::URI("ingen:/engine")); + _app->interface()->get(URI("ingen:/engine")); last = now; ++attempts; } } } else if (_connect_stage == 3) { - _app->interface()->get(Raul::URI(main_uri() + "/")); + _app->interface()->get(URI(main_uri().string() + "/")); next_stage(); } else if (_connect_stage == 4) { if (_app->store()->size() > 0) { diff --git a/src/gui/ConnectWindow.hpp b/src/gui/ConnectWindow.hpp index 015a6e76..08560361 100644 --- a/src/gui/ConnectWindow.hpp +++ b/src/gui/ConnectWindow.hpp @@ -70,7 +70,7 @@ private: void disconnect(); void next_stage(); - bool connect_remote(const Raul::URI& uri); + bool connect_remote(const URI& uri); void connect(bool existing); void activate(); void deactivate(); @@ -101,7 +101,7 @@ private: Gtk::Button* _quit_button; Mode _mode; - Raul::URI _connect_uri; + URI _connect_uri; int32_t _ping_id; bool _attached; bool _finished_connecting; diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index def101a7..6f9969be 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -216,7 +216,7 @@ GraphBox::init_box(App& app) { _app = &app; - const Raul::URI engine_uri(_app->interface()->uri()); + const URI engine_uri(_app->interface()->uri()); if (engine_uri == "ingen:/clients/event_writer") { _status_bar->push("Running internal engine", STATUS_CONTEXT_ENGINE); } else { @@ -381,7 +381,7 @@ GraphBox::graph_port_removed(SPtr<const PortModel> port) } void -GraphBox::property_changed(const Raul::URI& predicate, const Atom& value) +GraphBox::property_changed(const URI& predicate, const Atom& value) { if (predicate == _app->uris().ingen_sprungLayout) { if (value.type() == _app->uris().forge.Bool) { @@ -506,7 +506,7 @@ GraphBox::event_save() if (!document.is_valid() || document.type() != _app->uris().forge.URI) { event_save_as(); } else { - save_graph(Raul::URI(document.ptr<char>())); + save_graph(URI(document.ptr<char>())); } } @@ -537,9 +537,9 @@ GraphBox::confirm(const Glib::ustring& message, } void -GraphBox::save_graph(const Raul::URI& uri) +GraphBox::save_graph(const URI& uri) { - if (_app->interface()->uri().substr(0, 3) == "tcp") { + if (_app->interface()->uri().string().substr(0, 3) == "tcp") { _status_bar->push( (boost::format("Saved %1% to %2% on client") % _graph->path() % uri).str(), @@ -642,7 +642,7 @@ GraphBox::event_save_as() if (confirmed) { const Glib::ustring uri = Glib::filename_to_uri(filename); - save_graph(Raul::URI(uri)); + save_graph(URI(uri)); const_cast<GraphModel*>(_graph.get())->set_property( uris.ingen_file, @@ -876,7 +876,7 @@ void GraphBox::event_animate_signals_toggled() { _app->interface()->set_property( - Raul::URI("ingen:/clients/this"), + URI("ingen:/clients/this"), _app->uris().ingen_broadcast, _app->forge().make((bool)_menu_animate_signals->get_active())); } diff --git a/src/gui/GraphBox.hpp b/src/gui/GraphBox.hpp index ee054e17..fd9bf9c0 100644 --- a/src/gui/GraphBox.hpp +++ b/src/gui/GraphBox.hpp @@ -40,6 +40,8 @@ class Path; namespace Ingen { +class URI; + namespace Client { class GraphModel; class PortModel; @@ -97,7 +99,7 @@ public: private: void graph_port_added(SPtr<const Client::PortModel> port); void graph_port_removed(SPtr<const Client::PortModel> port); - void property_changed(const Raul::URI& predicate, const Atom& value); + void property_changed(const URI& predicate, const Atom& value); void show_status(const Client::ObjectModel* model); void error(const Glib::ustring& message, @@ -106,7 +108,7 @@ private: bool confirm(const Glib::ustring& message, const Glib::ustring& secondary_text=""); - void save_graph(const Raul::URI& uri); + void save_graph(const URI& uri); void event_import(); void event_save(); diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 4c7c34c8..a17915a5 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -320,7 +320,7 @@ GraphCanvas::add_plugin(SPtr<PluginModel> p) } void -GraphCanvas::remove_plugin(const Raul::URI& uri) +GraphCanvas::remove_plugin(const URI& uri) { // Flag menus as dirty so they will be rebuilt when needed next _menu_dirty = true; @@ -683,7 +683,7 @@ GraphCanvas::paste() {{uris.rdf_type, Property(uris.ingen_Graph)}}); // Parse clipboard text into clipboard store - boost::optional<Raul::URI> base_uri = parser->parse_string( + boost::optional<URI> base_uri = parser->parse_string( _app.world(), &clipboard, str, main_uri()); // Figure out the copy graph base path @@ -693,7 +693,7 @@ GraphCanvas::paste() if (base[base.size() - 1] == '/') { base = base.substr(0, base.size() - 1); } - copy_root = uri_to_path(Raul::URI(base)); + copy_root = uri_to_path(URI(base)); } // Find the minimum x and y coordinate of objects to be pasted @@ -730,7 +730,7 @@ GraphCanvas::paste() const SPtr<Node> node = c.second; const Raul::Path& old_path = copy_root.child(node->path()); - const Raul::URI& old_uri = path_to_uri(old_path); + const URI& old_uri = path_to_uri(old_path); const Raul::Path& new_path = avoider.map_path(parent.child(node->path())); Properties props{{uris.lv2_prototype, @@ -793,8 +793,10 @@ GraphCanvas::generate_port_name( } void -GraphCanvas::menu_add_port(const string& sym_base, const string& name_base, - const Raul::URI& type, bool is_output) +GraphCanvas::menu_add_port(const string& sym_base, + const string& name_base, + const URI& type, + bool is_output) { string sym, name; generate_port_name(sym_base, sym, name_base, name); diff --git a/src/gui/GraphCanvas.hpp b/src/gui/GraphCanvas.hpp index f283354e..a7340744 100644 --- a/src/gui/GraphCanvas.hpp +++ b/src/gui/GraphCanvas.hpp @@ -63,7 +63,7 @@ public: bool show_port_names() const { return _show_port_names; } void add_plugin(SPtr<Client::PluginModel> p); - void remove_plugin(const Raul::URI& uri); + void remove_plugin(const URI& uri); void add_block(SPtr<const Client::BlockModel> bm); void remove_block(SPtr<const Client::BlockModel> bm); void add_port(SPtr<const Client::PortModel> pm); @@ -90,7 +90,7 @@ private: void menu_add_port(const std::string& sym_base, const std::string& name_base, - const Raul::URI& type, + const URI& type, bool is_output); void menu_load_plugin(); diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp index 7dc24a20..5987b0e3 100644 --- a/src/gui/GraphPortModule.cpp +++ b/src/gui/GraphPortModule.cpp @@ -130,7 +130,7 @@ GraphPortModule::set_name(const std::string& n) } void -GraphPortModule::property_changed(const Raul::URI& key, const Atom& value) +GraphPortModule::property_changed(const URI& key, const Atom& value) { const URIs& uris = app().uris(); if (value.type() == uris.forge.Float) { diff --git a/src/gui/GraphPortModule.hpp b/src/gui/GraphPortModule.hpp index 79229be6..97bc2e5b 100644 --- a/src/gui/GraphPortModule.hpp +++ b/src/gui/GraphPortModule.hpp @@ -20,7 +20,6 @@ #include <string> #include "ganv/Module.hpp" -#include "raul/URI.hpp" #include "Port.hpp" @@ -68,7 +67,7 @@ protected: void set_port(Port* port) { _port = port; } - void property_changed(const Raul::URI& key, const Atom& value); + void property_changed(const URI& key, const Atom& value); SPtr<const Client::PortModel> _model; Port* _port; diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp index e5522a74..1eb6557b 100644 --- a/src/gui/GraphTreeWindow.cpp +++ b/src/gui/GraphTreeWindow.cpp @@ -88,7 +88,7 @@ GraphTreeWindow::add_graph(SPtr<GraphModel> pm) Gtk::TreeModel::iterator iter = _graph_treestore->append(); Gtk::TreeModel::Row row = *iter; if (pm->path().is_root()) { - row[_graph_tree_columns.name_col] = _app->interface()->uri(); + row[_graph_tree_columns.name_col] = _app->interface()->uri().string(); } else { row[_graph_tree_columns.name_col] = pm->symbol().c_str(); } @@ -193,7 +193,7 @@ GraphTreeWindow::event_graph_enabled_toggled(const Glib::ustring& path_str) } void -GraphTreeWindow::graph_property_changed(const Raul::URI& key, +GraphTreeWindow::graph_property_changed(const URI& key, const Atom& value, SPtr<GraphModel> graph) { diff --git a/src/gui/GraphTreeWindow.hpp b/src/gui/GraphTreeWindow.hpp index af767a2a..005f39a8 100644 --- a/src/gui/GraphTreeWindow.hpp +++ b/src/gui/GraphTreeWindow.hpp @@ -49,7 +49,7 @@ public: void new_object(SPtr<Client::ObjectModel> object); - void graph_property_changed(const Raul::URI& key, + void graph_property_changed(const URI& key, const Atom& value, SPtr<Client::GraphModel> graph); diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp index cb722066..e6361249 100644 --- a/src/gui/GraphView.cpp +++ b/src/gui/GraphView.cpp @@ -135,7 +135,7 @@ GraphView::poly_changed() } void -GraphView::property_changed(const Raul::URI& predicate, const Atom& value) +GraphView::property_changed(const URI& predicate, const Atom& value) { _enable_signal = false; if (predicate == _app->uris().ingen_enabled) { diff --git a/src/gui/GraphView.hpp b/src/gui/GraphView.hpp index 54d47c72..03569831 100644 --- a/src/gui/GraphView.hpp +++ b/src/gui/GraphView.hpp @@ -27,7 +27,6 @@ #include <gtkmm/toolitem.h> #include "ingen/types.hpp" -#include "raul/URI.hpp" namespace Raul { class Atom; } @@ -77,7 +76,7 @@ private: void poly_changed(); void clear_clicked(); - void property_changed(const Raul::URI& predicate, const Atom& value); + void property_changed(const URI& predicate, const Atom& value); App* _app; diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index 0eb65f8d..c96634cc 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -296,7 +296,7 @@ LoadPluginWindow::set_row(Gtk::TreeModel::Row& row, row[_plugins_columns._col_type] = ""; } - row[_plugins_columns._col_uri] = plugin->uri(); + row[_plugins_columns._col_uri] = plugin->uri().string(); row[_plugins_columns._col_plugin] = plugin; } @@ -498,9 +498,9 @@ LoadPluginWindow::on_key_press_event(GdkEventKey* event) } void -LoadPluginWindow::plugin_property_changed(const Raul::URI& plugin, - const Raul::URI& predicate, - const Atom& value) +LoadPluginWindow::plugin_property_changed(const URI& plugin, + const URI& predicate, + const Atom& value) { const URIs& uris = _app->uris(); if (predicate == uris.doap_name) { diff --git a/src/gui/LoadPluginWindow.hpp b/src/gui/LoadPluginWindow.hpp index 71ac76e2..3874b8dd 100644 --- a/src/gui/LoadPluginWindow.hpp +++ b/src/gui/LoadPluginWindow.hpp @@ -116,9 +116,9 @@ private: void new_plugin(SPtr<const Client::PluginModel> pm); - void plugin_property_changed(const Raul::URI& plugin, - const Raul::URI& predicate, - const Atom& value); + void plugin_property_changed(const URI& plugin, + const URI& predicate, + const Atom& value); void plugin_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* col); void plugin_selection_changed(); @@ -132,7 +132,7 @@ private: SPtr<const Client::GraphModel> _graph; - typedef std::map<Raul::URI, Gtk::TreeModel::iterator> Rows; + typedef std::map<URI, Gtk::TreeModel::iterator> Rows; Rows _rows; Glib::RefPtr<Gtk::ListStore> _plugins_liststore; diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index 73564f9d..1b1b1677 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -137,7 +137,7 @@ NodeMenu::init(App& app, SPtr<const Client::BlockModel> block) } void -NodeMenu::add_preset(const Raul::URI& uri, const std::string& label) +NodeMenu::add_preset(const URI& uri, const std::string& label) { if (_presets_menu) { _presets_menu->items().push_back( @@ -225,7 +225,7 @@ NodeMenu::on_save_preset_activated() _app->forge().alloc(basename) }, { _app->uris().lv2_prototype, _app->forge().make_urid(block()->uri()) }}; - _app->interface()->put(Raul::URI(real_uri), props); + _app->interface()->put(URI(real_uri), props); } } @@ -234,7 +234,7 @@ NodeMenu::on_preset_activated(const std::string& uri) { _app->set_property(block()->uri(), _app->uris().pset_preset, - _app->forge().make_urid(Raul::URI(uri))); + _app->forge().make_urid(URI(uri))); } bool diff --git a/src/gui/NodeMenu.hpp b/src/gui/NodeMenu.hpp index c8ac3daf..5d9f1e6d 100644 --- a/src/gui/NodeMenu.hpp +++ b/src/gui/NodeMenu.hpp @@ -52,7 +52,7 @@ protected: return dynamic_ptr_cast<const Client::BlockModel>(_object); } - void add_preset(const Raul::URI& uri, const std::string& label); + void add_preset(const URI& uri, const std::string& label); void on_menu_disconnect(); void on_menu_embed_gui(); diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 2e81128a..dadffff0 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -457,7 +457,7 @@ NodeModule::store_location(double ax, double ay) } void -NodeModule::property_changed(const Raul::URI& key, const Atom& value) +NodeModule::property_changed(const URI& key, const Atom& value) { const URIs& uris = app().uris(); if (value.type() == uris.forge.Float) { diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp index f2381999..863b6ffb 100644 --- a/src/gui/NodeModule.hpp +++ b/src/gui/NodeModule.hpp @@ -79,7 +79,7 @@ protected: bool on_selected(gboolean selected); void rename(); - void property_changed(const Raul::URI& key, const Atom& value); + void property_changed(const URI& key, const Atom& value); void new_port_view(SPtr<const Client::PortModel> port); diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp index c113cac9..bfce4248 100644 --- a/src/gui/ObjectMenu.cpp +++ b/src/gui/ObjectMenu.cpp @@ -119,7 +119,7 @@ ObjectMenu::on_menu_polyphonic() } void -ObjectMenu::property_changed(const Raul::URI& predicate, const Atom& value) +ObjectMenu::property_changed(const URI& predicate, const Atom& value) { const URIs& uris = _app->uris(); _enable_signal = false; diff --git a/src/gui/ObjectMenu.hpp b/src/gui/ObjectMenu.hpp index a9766614..a9b07fd5 100644 --- a/src/gui/ObjectMenu.hpp +++ b/src/gui/ObjectMenu.hpp @@ -55,7 +55,7 @@ protected: void on_menu_destroy(); void on_menu_properties(); - void property_changed(const Raul::URI& predicate, const Atom& value); + void property_changed(const URI& predicate, const Atom& value); App* _app; SPtr<const Client::ObjectModel> _object; diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 9622a7f5..9742cee3 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -246,7 +246,7 @@ Port::build_enum_menu() } void -Port::on_uri_activated(const Raul::URI& uri) +Port::on_uri_activated(const URI& uri) { _app.set_property(model()->uri(), _app.world()->uris().ingen_value, @@ -278,7 +278,7 @@ Port::build_uri_menu() LilvNodes* range = lilv_world_find_nodes( world->lilv_world(), designation, rdfs_range, nullptr); LILV_FOREACH(nodes, r, range) { - ranges.insert(Raul::URI(lilv_node_as_string(lilv_nodes_get(range, r)))); + ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(range, r)))); } RDFS::classes(world, ranges, false); @@ -450,7 +450,7 @@ Port::port_properties_changed() } void -Port::property_changed(const Raul::URI& key, const Atom& value) +Port::property_changed(const URI& key, const Atom& value) { const URIs& uris = _app.uris(); if (value.type() == uris.forge.Float) { @@ -495,7 +495,7 @@ Port::property_changed(const Raul::URI& key, const Atom& value) } void -Port::property_removed(const Raul::URI& key, const Atom& value) +Port::property_removed(const URI& key, const Atom& value) { const URIs& uris = _app.uris(); if (key == uris.lv2_minimum || key == uris.lv2_maximum) { diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 5f683412..c714feae 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -27,11 +27,12 @@ namespace Raul { class Atom; -class URI; } namespace Ingen { +class URI; + namespace Client { class PortModel; } namespace GUI { @@ -78,13 +79,13 @@ private: Gtk::Menu* build_uri_menu(); GraphBox* get_graph_box() const; - void property_changed(const Raul::URI& key, const Atom& value); - void property_removed(const Raul::URI& key, const Atom& value); + void property_changed(const URI& key, const Atom& value); + void property_removed(const URI& key, const Atom& value); void moved(); void on_value_changed(double value); void on_scale_point_activated(float f); - void on_uri_activated(const Raul::URI& uri); + void on_uri_activated(const URI& uri); bool on_event(GdkEvent* ev); void port_properties_changed(); void set_type_tag(); diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index db939b73..4d47b3ae 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -39,7 +39,7 @@ using namespace Client; namespace GUI { -typedef std::set<Raul::URI> URISet; +typedef std::set<URI> URISet; PropertiesWindow::PropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& xml) @@ -100,7 +100,7 @@ PropertiesWindow::present(SPtr<const ObjectModel> model) } void -PropertiesWindow::add_property(const Raul::URI& key, const Atom& value) +PropertiesWindow::add_property(const URI& key, const Atom& value) { World* world = _app->world(); @@ -114,7 +114,9 @@ PropertiesWindow::add_property(const Raul::URI& key, const Atom& value) name = world->rdf_world()->prefixes().qualify(key); } Gtk::Label* label = new Gtk::Label( - std::string("<a href=\"") + key + "\">" + name + "</a>", 1.0, 0.5); + std::string("<a href=\"") + key.string() + "\">" + name + "</a>", + 1.0, + 0.5); label->set_use_markup(true); _app->set_tooltip(label, prop); _table->attach(*Gtk::manage(label), 0, 1, n_rows, n_rows + 1, @@ -144,7 +146,7 @@ PropertiesWindow::add_property(const Raul::URI& key, const Atom& value) bool PropertiesWindow::datatype_supported(const RDFS::URISet& types, - Raul::URI* widget_type) + URI* widget_type) { if (types.find(_app->uris().atom_Int) != types.end()) { *widget_type = _app->uris().atom_Int; @@ -211,8 +213,8 @@ PropertiesWindow::set_object(SPtr<const ObjectModel> model) world->lilv_world(), LILV_NS_RDFS "Datatype"); // Populate key combo - const URISet props = RDFS::properties(world, model); - std::map<std::string, Raul::URI> entries; + const URISet props = RDFS::properties(world, model); + std::map<std::string, URI> entries; for (const auto& p : props) { LilvNode* prop = lilv_new_uri(world->lilv_world(), p.c_str()); const std::string label = RDFS::label(world, prop); @@ -228,7 +230,7 @@ PropertiesWindow::set_object(SPtr<const ObjectModel> model) if (RDFS::is_a(world, range, rdfs_DataType)) { // Range is a datatype, show if type or any subtype is supported RDFS::datatypes(_app->world(), ranges, false); - Raul::URI widget_type("urn:nothing"); + URI widget_type("urn:nothing"); if (datatype_supported(ranges, &widget_type)) { entries.emplace(label, p); } @@ -243,7 +245,7 @@ PropertiesWindow::set_object(SPtr<const ObjectModel> model) for (const auto& e : entries) { Gtk::ListStore::iterator ki = _key_store->append(); Gtk::ListStore::Row row = *ki; - row[_combo_columns.uri_col] = e.second; + row[_combo_columns.uri_col] = e.second.string(); row[_combo_columns.label_col] = e.first; } @@ -263,23 +265,23 @@ PropertiesWindow::set_object(SPtr<const ObjectModel> model) } Gtk::Widget* -PropertiesWindow::create_value_widget(const Raul::URI& key, - const char* type_uri, - const Atom& value) +PropertiesWindow::create_value_widget(const URI& key, + const char* type_uri, + const Atom& value) { - if (!type_uri || !Raul::URI::is_valid(type_uri)) { + if (!type_uri || !URI::is_valid(type_uri)) { return nullptr; } - Raul::URI type(type_uri); + URI type(type_uri); Ingen::World* world = _app->world(); LilvWorld* lworld = world->lilv_world(); // See if type is a datatype we support - std::set<Raul::URI> types{type}; + std::set<URI> types{type}; RDFS::datatypes(_app->world(), types, false); - Raul::URI widget_type("urn:nothing"); + URI widget_type("urn:nothing"); const bool supported = datatype_supported(types, &widget_type); if (supported) { type = widget_type; @@ -390,7 +392,7 @@ PropertiesWindow::on_show() } void -PropertiesWindow::change_property(const Raul::URI& key, const Atom& value) +PropertiesWindow::change_property(const URI& key, const Atom& value) { auto r = _records.find(key); if (r == _records.end()) { @@ -413,7 +415,7 @@ PropertiesWindow::change_property(const Raul::URI& key, const Atom& value) } void -PropertiesWindow::remove_property(const Raul::URI& key, const Atom& value) +PropertiesWindow::remove_property(const URI& key, const Atom& value) { // Bleh, there doesn't seem to be an easy way to remove a Gtk::Table row... _records.clear(); @@ -449,8 +451,8 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) } } else if (type == forge.URI || type == forge.URID) { URIEntry* uri_entry = dynamic_cast<URIEntry*>(value_widget); - if (uri_entry && Raul::URI::is_valid(uri_entry->get_text())) { - return _app->forge().make_urid(Raul::URI(uri_entry->get_text())); + if (uri_entry && URI::is_valid(uri_entry->get_text())) { + return _app->forge().make_urid(URI(uri_entry->get_text())); } else { _app->log().error(fmt("Invalid URI <%1%>\n") % uri_entry->get_text()); } @@ -465,7 +467,7 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) } void -PropertiesWindow::on_change(const Raul::URI& key) +PropertiesWindow::on_change(const URI& key) { auto r = _records.find(key); if (r == _records.end()) { @@ -512,7 +514,7 @@ PropertiesWindow::key_changed() const URISet ranges = RDFS::range(_app->world(), prop, true); for (const auto& r : ranges) { Gtk::Widget* value_widget = create_value_widget( - Raul::URI(key_uri), r.c_str(), Atom()); + URI(key_uri), r.c_str(), Atom()); if (value_widget) { _add_button->set_sensitive(true); @@ -542,7 +544,7 @@ PropertiesWindow::add_clicked() if (value.is_valid()) { // Send property to engine Properties properties; - properties.emplace(Raul::URI(key_uri.c_str()), Property(value)); + properties.emplace(URI(key_uri.c_str()), Property(value)); _app->interface()->put(_model->uri(), properties); } } @@ -560,8 +562,8 @@ PropertiesWindow::apply_clicked() Properties remove; Properties add; for (const auto& r : _records) { - const Raul::URI& uri = r.first; - const Record& record = r.second; + const URI& uri = r.first; + const Record& record = r.second; if (record.present_button->get_active()) { if (!_model->has_property(uri, record.value)) { add.emplace(uri, record.value); diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp index c9a2c9f4..f4a8dd0d 100644 --- a/src/gui/PropertiesWindow.hpp +++ b/src/gui/PropertiesWindow.hpp @@ -76,19 +76,19 @@ private: Gtk::TreeModelColumn<Glib::ustring> uri_col; }; - void add_property(const Raul::URI& key, const Atom& value); - void change_property(const Raul::URI& key, const Atom& value); - void remove_property(const Raul::URI& key, const Atom& value); - void on_change(const Raul::URI& key); + void add_property(const URI& key, const Atom& value); + void change_property(const URI& key, const Atom& value); + void remove_property(const URI& key, const Atom& value); + void on_change(const URI& key); - bool datatype_supported(const std::set<Raul::URI>& types, - Raul::URI* widget_type); + bool datatype_supported(const std::set<URI>& types, + URI* widget_type); - bool class_supported(const std::set<Raul::URI>& types); + bool class_supported(const std::set<URI>& types); - Gtk::Widget* create_value_widget(const Raul::URI& key, - const char* type_uri, - const Atom& value = Atom()); + Gtk::Widget* create_value_widget(const URI& key, + const char* type_uri, + const Atom& value = Atom()); Atom get_value(LV2_URID type, Gtk::Widget* value_widget); @@ -103,7 +103,7 @@ private: void apply_clicked(); void ok_clicked(); - typedef std::map<Raul::URI, Record> Records; + typedef std::map<URI, Record> Records; Records _records; SPtr<const Client::ObjectModel> _model; diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp index b524aed7..71b3441a 100644 --- a/src/gui/RDFS.cpp +++ b/src/gui/RDFS.cpp @@ -76,7 +76,7 @@ closure(World* world, const LilvNode* pred, URISet& types, bool super) LILV_FOREACH(nodes, m, matches) { const LilvNode* klass_node = lilv_nodes_get(matches, m); if (lilv_node_is_uri(klass_node)) { - Raul::URI klass(lilv_node_as_uri(klass_node)); + URI klass(lilv_node_as_uri(klass_node)); if (!types.count(klass)) { ++added; klasses.insert(klass); @@ -120,12 +120,12 @@ types(World* world, SPtr<const Client::ObjectModel> model) // Start with every rdf:type URISet types; - types.insert(Raul::URI(LILV_NS_RDFS "Resource")); + types.insert(URI(LILV_NS_RDFS "Resource")); PropRange range = model->properties().equal_range(world->uris().rdf_type); for (auto t = range.first; t != range.second; ++t) { if (t->second.type() == world->forge().URI || t->second.type() == world->forge().URID) { - const Raul::URI type(world->forge().str(t->second, false)); + const URI type(world->forge().str(t->second, false)); types.insert(type); if (world->uris().ingen_Graph == type) { // Add lv2:Plugin as a type for graphs so plugin properties show up @@ -170,7 +170,7 @@ properties(World* world, SPtr<const Client::ObjectModel> model) continue; } - const Raul::URI domain(lilv_node_as_uri(domain_node)); + const URI domain(lilv_node_as_uri(domain_node)); if (types.count(domain)) { ++n_matching_domains; } @@ -179,7 +179,7 @@ properties(World* world, SPtr<const Client::ObjectModel> model) if (lilv_nodes_size(domains) == 0 || ( n_matching_domains > 0 && n_matching_domains == lilv_nodes_size(domains))) { - properties.insert(Raul::URI(lilv_node_as_uri(prop))); + properties.insert(URI(lilv_node_as_uri(prop))); } lilv_nodes_free(domains); @@ -210,7 +210,7 @@ instances(World* world, const URISet& types) continue; } const std::string label = RDFS::label(world, object); - result.emplace(label, Raul::URI(lilv_node_as_string(object))); + result.emplace(label, URI(lilv_node_as_string(object))); } lilv_node_free(type); } @@ -230,7 +230,7 @@ range(World* world, const LilvNode* prop, bool recursive) URISet ranges; LILV_FOREACH(nodes, n, nodes) { - ranges.insert(Raul::URI(lilv_node_as_string(lilv_nodes_get(nodes, n)))); + ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(nodes, n)))); } if (recursive) { diff --git a/src/gui/RDFS.hpp b/src/gui/RDFS.hpp index 7208c638..f59bbdf5 100644 --- a/src/gui/RDFS.hpp +++ b/src/gui/RDFS.hpp @@ -23,7 +23,6 @@ #include "ingen/types.hpp" #include "lilv/lilv.h" -#include "raul/URI.hpp" namespace Ingen { @@ -36,10 +35,10 @@ namespace GUI { namespace RDFS { /** Set of URIs. */ -typedef std::set<Raul::URI> URISet; +typedef std::set<URI> URISet; /** Label => Resource map. */ -typedef std::map<std::string, Raul::URI> Objects; +typedef std::map<std::string, URI> Objects; /** Return the label of `node`. */ std::string label(World* world, const LilvNode* node); diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index 93c97cbd..891502f7 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -14,6 +14,7 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include <cassert> #include <string> #include "ingen/Log.hpp" @@ -30,11 +31,11 @@ namespace Ingen { namespace GUI { ThreadedLoader::ThreadedLoader(App& app, SPtr<Interface> engine) - : _app(app) - , _sem(0) - , _engine(std::move(engine)) - , _exit_flag(false) - , _thread(&ThreadedLoader::run, this) + : _app(app) + , _sem(0) + , _engine(std::move(engine)) + , _exit_flag(false) + , _thread(&ThreadedLoader::run, this) { if (!parser()) { app.log().warn("Parser unavailable, graph loading disabled\n"); @@ -85,13 +86,12 @@ ThreadedLoader::load_graph(bool merge, } } - _events.push_back( - sigc::hide_return( - sigc::bind(sigc::mem_fun(this, &ThreadedLoader::load_graph_event), - document_uri, - engine_parent, - engine_symbol, - engine_data))); + _events.push_back(sigc::hide_return( + sigc::bind(sigc::mem_fun(this, &ThreadedLoader::load_graph_event), + document_uri, + engine_parent, + engine_symbol, + engine_data))); _mutex.unlock(); _sem.post(); @@ -114,15 +114,14 @@ ThreadedLoader::load_graph_event(const Glib::ustring& document_uri, } void -ThreadedLoader::save_graph(SPtr<const Client::GraphModel> model, - const std::string& filename) +ThreadedLoader::save_graph(SPtr<const Client::GraphModel> model, const URI& uri) { _mutex.lock(); - _events.push_back( - sigc::hide_return( - sigc::bind(sigc::mem_fun(this, &ThreadedLoader::save_graph_event), - model, filename))); + _events.push_back(sigc::hide_return( + sigc::bind(sigc::mem_fun(this, &ThreadedLoader::save_graph_event), + model, + uri))); _mutex.unlock(); _sem.post(); @@ -130,15 +129,16 @@ ThreadedLoader::save_graph(SPtr<const Client::GraphModel> model, void ThreadedLoader::save_graph_event(SPtr<const Client::GraphModel> model, - const std::string& filename) + const URI& uri) { + assert(uri.scheme() == "file"); if (_app.serialiser()) { std::lock_guard<std::mutex> lock(_app.world()->rdf_mutex()); - if (filename.find(".ingen") != std::string::npos) { - _app.serialiser()->write_bundle(model, filename); + if (uri.string().find(".ingen") != std::string::npos) { + _app.serialiser()->write_bundle(model, uri); } else { - _app.serialiser()->start_to_file(model->path(), filename); + _app.serialiser()->start_to_file(model->path(), std::string(uri.path())); _app.serialiser()->serialise(model); _app.serialiser()->finish(); } diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp index c0a4ed6a..64968230 100644 --- a/src/gui/ThreadedLoader.hpp +++ b/src/gui/ThreadedLoader.hpp @@ -32,6 +32,9 @@ #include "raul/Semaphore.hpp" namespace Ingen { + +class URI; + namespace GUI { /** Thread for loading graph files. @@ -59,8 +62,7 @@ public: boost::optional<Raul::Symbol> engine_symbol, boost::optional<Properties> engine_data); - void save_graph(SPtr<const Client::GraphModel> model, - const std::string& filename); + void save_graph(SPtr<const Client::GraphModel> model, const URI& uri); SPtr<Parser> parser(); @@ -71,7 +73,7 @@ private: boost::optional<Properties> engine_data); void save_graph_event(SPtr<const Client::GraphModel> model, - const std::string& filename); + const URI& filename); /** Returns nothing and takes no parameters (because they have all been bound) */ typedef sigc::slot<void> Closure; diff --git a/src/gui/URIEntry.cpp b/src/gui/URIEntry.cpp index 3c236572..0b81afd7 100644 --- a/src/gui/URIEntry.cpp +++ b/src/gui/URIEntry.cpp @@ -23,14 +23,12 @@ namespace Ingen { namespace GUI { -URIEntry::URIEntry(App* app, - std::set<Raul::URI> types, - const std::string& value) - : Gtk::HBox(false, 4) - , _app(app) - , _types(std::move(types)) - , _menu_button(Gtk::manage(new Gtk::Button("≡"))) - , _entry(Gtk::manage(new Gtk::Entry())) +URIEntry::URIEntry(App* app, std::set<URI> types, const std::string& value) + : Gtk::HBox(false, 4) + , _app(app) + , _types(std::move(types)) + , _menu_button(Gtk::manage(new Gtk::Button("≡"))) + , _entry(Gtk::manage(new Gtk::Entry())) { pack_start(*_entry, true, true); pack_start(*_menu_button, false, true); diff --git a/src/gui/URIEntry.hpp b/src/gui/URIEntry.hpp index 90df2160..2f55a3d9 100644 --- a/src/gui/URIEntry.hpp +++ b/src/gui/URIEntry.hpp @@ -36,9 +36,7 @@ public: * If `types` is given, then a menu button will be shown which pops up a * enu for easily choosing known values with valid types. */ - URIEntry(App* app, - std::set<Raul::URI> types, - const std::string& value); + URIEntry(App* app, std::set<URI> types, const std::string& value); std::string get_text() { return _entry->get_text(); } Glib::SignalProxy0<void> signal_changed() { return _entry->signal_changed(); } @@ -58,10 +56,10 @@ private: void uri_chosen(const std::string& uri); bool menu_button_event(GdkEvent* ev); - App* _app; - const std::set<Raul::URI> _types; - Gtk::Button* _menu_button; - Gtk::Entry* _entry; + App* _app; + const std::set<URI> _types; + Gtk::Button* _menu_button; + Gtk::Entry* _entry; }; } // namespace GUI diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp index b775d415..5630e56b 100644 --- a/src/ingen/ingen.cpp +++ b/src/ingen/ingen.cpp @@ -134,10 +134,10 @@ main(int argc, char** argv) Client::SocketClient::register_factories(world.get()); #endif const char* const uri = conf.option("connect").ptr<char>(); - ingen_try(Raul::URI::is_valid(uri), + ingen_try(URI::is_valid(uri), (fmt("Invalid URI <%1%>") % uri).str().c_str()); SPtr<Interface> client(new Client::ThreadedSigClientInterface()); - engine_interface = world->new_interface(Raul::URI(uri), client); + engine_interface = world->new_interface(URI(uri), client); if (!engine_interface && !conf.option("gui").get<int32_t>()) { cerr << (fmt("ingen: error: Failed to connect to `%1%'\n") % uri); @@ -188,7 +188,7 @@ main(int argc, char** argv) const string graph = conf.option("load").ptr<char>(); - engine_interface->get(Raul::URI("ingen:/plugins")); + engine_interface->get(URI("ingen:/plugins")); engine_interface->get(main_uri()); std::lock_guard<std::mutex> lock(world->rdf_mutex()); @@ -198,14 +198,13 @@ main(int argc, char** argv) const char* path = conf.option("server-load").ptr<char>(); if (serd_uri_string_has_scheme((const uint8_t*)path)) { std::cout << "Loading " << path << " (server side)" << std::endl; - engine_interface->copy(Raul::URI(path), main_uri()); + engine_interface->copy(URI(path), main_uri()); } else { SerdNode uri = serd_node_new_file_uri( (const uint8_t*)path, nullptr, nullptr, true); std::cout << "Loading " << (const char*)uri.buf << " (server side)" << std::endl; - engine_interface->copy(Raul::URI((const char*)uri.buf), - main_uri()); + engine_interface->copy(URI((const char*)uri.buf), main_uri()); serd_node_free(&uri); } } @@ -215,13 +214,12 @@ main(int argc, char** argv) const char* path = conf.option("save").ptr<char>(); if (serd_uri_string_has_scheme((const uint8_t*)path)) { std::cout << "Saving to " << path << std::endl; - engine_interface->copy(main_uri(), Raul::URI(path)); + engine_interface->copy(main_uri(), URI(path)); } else { SerdNode uri = serd_node_new_file_uri( (const uint8_t*)path, nullptr, nullptr, true); std::cout << "Saving to " << (const char*)uri.buf << std::endl; - engine_interface->copy(main_uri(), - Raul::URI((const char*)uri.buf)); + engine_interface->copy(main_uri(), URI((const char*)uri.buf)); serd_node_free(&uri); } } diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp index a1367e12..65108483 100644 --- a/src/server/BlockFactory.cpp +++ b/src/server/BlockFactory.cpp @@ -99,7 +99,7 @@ BlockFactory::refresh() } PluginImpl* -BlockFactory::plugin(const Raul::URI& uri) +BlockFactory::plugin(const URI& uri) { load_plugin(uri); const Plugins::const_iterator i = _plugins.find(uri); @@ -127,7 +127,7 @@ BlockFactory::load_internal_plugins() } void -BlockFactory::load_plugin(const Raul::URI& uri) +BlockFactory::load_plugin(const URI& uri) { if (_has_loaded || _plugins.find(uri) != _plugins.end()) { return; @@ -152,7 +152,7 @@ BlockFactory::load_lv2_plugins() typedef std::vector< SPtr<LilvNode> > Types; Types types; for (unsigned t = PortType::ID::AUDIO; t <= PortType::ID::ATOM; ++t) { - const Raul::URI& uri(PortType((PortType::ID)t).uri()); + const URI& uri(PortType((PortType::ID)t).uri()); types.push_back( SPtr<LilvNode>(lilv_new_uri(_world->lilv_world(), uri.c_str()), lilv_node_free)); @@ -161,7 +161,7 @@ BlockFactory::load_lv2_plugins() const LilvPlugins* plugins = lilv_world_get_all_plugins(_world->lilv_world()); LILV_FOREACH(plugins, i, plugins) { const LilvPlugin* lv2_plug = lilv_plugins_get(plugins, i); - const Raul::URI uri(lilv_node_as_uri(lilv_plugin_get_uri(lv2_plug))); + const URI uri(lilv_node_as_uri(lilv_plugin_get_uri(lv2_plug))); // Ignore plugins that require features Ingen doesn't support LilvNodes* features = lilv_plugin_get_required_features(lv2_plug); diff --git a/src/server/BlockFactory.hpp b/src/server/BlockFactory.hpp index 71e72bbc..25885f75 100644 --- a/src/server/BlockFactory.hpp +++ b/src/server/BlockFactory.hpp @@ -23,7 +23,6 @@ #include "ingen/World.hpp" #include "ingen/types.hpp" #include "raul/Noncopyable.hpp" -#include "raul/URI.hpp" namespace Ingen { namespace Server { @@ -46,12 +45,12 @@ public: */ std::set<PluginImpl*> refresh(); - void load_plugin(const Raul::URI& uri); + void load_plugin(const URI& uri); - typedef std::map<Raul::URI, PluginImpl*> Plugins; + typedef std::map<URI, PluginImpl*> Plugins; const Plugins& plugins(); - PluginImpl* plugin(const Raul::URI& uri); + PluginImpl* plugin(const URI& uri); private: void load_lv2_plugins(); diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp index 7907b0d8..d663e319 100644 --- a/src/server/BlockImpl.hpp +++ b/src/server/BlockImpl.hpp @@ -102,14 +102,14 @@ public: void set_enabled(bool e) { _enabled = e; } /** Load a preset from the world for this block. */ - virtual LilvState* load_preset(const Raul::URI& uri) { return nullptr; } + virtual LilvState* load_preset(const URI& uri) { return nullptr; } /** Restore `state`. */ virtual void apply_state(const UPtr<Worker>& worker, const LilvState* state) {} /** Save current state as preset. */ virtual boost::optional<Resource> - save_preset(const Raul::URI& bundle, + save_preset(const URI& bundle, const Properties& props) { return boost::optional<Resource>(); } /** Learn the next incoming MIDI event (for internals) */ diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp index b51c744c..3981b265 100644 --- a/src/server/Broadcaster.hpp +++ b/src/server/Broadcaster.hpp @@ -97,7 +97,7 @@ public: } } - Raul::URI uri() const override { return Raul::URI("ingen:/broadcaster"); } + URI uri() const override { return URI("ingen:/broadcaster"); } private: friend class Transfer; diff --git a/src/server/ClientUpdate.cpp b/src/server/ClientUpdate.cpp index b65fac12..60dd02e3 100644 --- a/src/server/ClientUpdate.cpp +++ b/src/server/ClientUpdate.cpp @@ -27,7 +27,7 @@ namespace Ingen { namespace Server { void -ClientUpdate::put(const Raul::URI& uri, +ClientUpdate::put(const URI& uri, const Properties& props, Resource::Graph ctx) { @@ -106,8 +106,8 @@ ClientUpdate::put_plugin(PluginImpl* plugin) void ClientUpdate::put_preset(const URIs& uris, - const Raul::URI& plugin, - const Raul::URI& preset, + const URI& plugin, + const URI& preset, const std::string& label) { const Properties props{ @@ -118,7 +118,7 @@ ClientUpdate::put_preset(const URIs& uris, } void -ClientUpdate::del(const Raul::URI& subject) +ClientUpdate::del(const URI& subject) { dels.push_back(subject); } @@ -135,7 +135,7 @@ void ClientUpdate::send(Interface& dest) { // Send deletions - for (const Raul::URI& subject : dels) { + for (const URI& subject : dels) { dest.del(subject); } diff --git a/src/server/ClientUpdate.hpp b/src/server/ClientUpdate.hpp index 008bf2da..f1a361f7 100644 --- a/src/server/ClientUpdate.hpp +++ b/src/server/ClientUpdate.hpp @@ -22,7 +22,6 @@ #include "ingen/Resource.hpp" #include "raul/Path.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -42,7 +41,7 @@ class PluginImpl; * post_process() to avoid the need to lock. */ struct ClientUpdate { - void put(const Raul::URI& uri, + void put(const URI& uri, const Properties& props, Resource::Graph ctx = Resource::Graph::DEFAULT); @@ -51,16 +50,16 @@ struct ClientUpdate { void put_graph(const GraphImpl* graph); void put_plugin(PluginImpl* plugin); void put_preset(const URIs& uris, - const Raul::URI& plugin, - const Raul::URI& preset, + const URI& plugin, + const URI& preset, const std::string& label); - void del(const Raul::URI& subject); + void del(const URI& subject); void send(Interface& dest); struct Put { - Raul::URI uri; + URI uri; Properties properties; Resource::Graph ctx; }; @@ -70,9 +69,9 @@ struct ClientUpdate { Raul::Path head; }; - std::vector<Raul::URI> dels; - std::vector<Put> puts; - std::vector<Connect> connects; + std::vector<URI> dels; + std::vector<Put> puts; + std::vector<Connect> connects; }; } // namespace Server diff --git a/src/server/DirectDriver.hpp b/src/server/DirectDriver.hpp index 219d0cb1..58b4f898 100644 --- a/src/server/DirectDriver.hpp +++ b/src/server/DirectDriver.hpp @@ -72,7 +72,7 @@ public: const Raul::Path& new_path) {} virtual void port_property(const Raul::Path& path, - const Raul::URI& uri, + const URI& uri, const Atom& value) {} virtual void register_port(EnginePort& port) {} diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp index 3014429e..9ae4b836 100644 --- a/src/server/Driver.hpp +++ b/src/server/Driver.hpp @@ -81,7 +81,7 @@ public: /** Apply a system visible port property. */ virtual void port_property(const Raul::Path& path, - const Raul::URI& uri, + const URI& uri, const Atom& value) = 0; /** Return the audio buffer size in frames */ diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp index 7e32e236..1b62ff38 100644 --- a/src/server/DuplexPort.cpp +++ b/src/server/DuplexPort.cpp @@ -121,7 +121,7 @@ DuplexPort::inherit_neighbour(const PortImpl* port, } void -DuplexPort::on_property(const Raul::URI& uri, const Atom& value) +DuplexPort::on_property(const URI& uri, const Atom& value) { _bufs.engine().driver()->port_property(_path, uri, value); } diff --git a/src/server/DuplexPort.hpp b/src/server/DuplexPort.hpp index e12841dd..b0066164 100644 --- a/src/server/DuplexPort.hpp +++ b/src/server/DuplexPort.hpp @@ -61,7 +61,7 @@ public: Properties& remove, Properties& add); - void on_property(const Raul::URI& uri, const Atom& value); + void on_property(const URI& uri, const Atom& value); uint32_t max_tail_poly(RunContext& context) const; diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index e8d4770e..a7476845 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -122,7 +122,7 @@ Engine::Engine(Ingen::World* world) _event_writer, std::make_shared<StreamWriter>(world->uri_map(), world->uris(), - Raul::URI("ingen:/engine"), + URI("ingen:/engine"), stderr, ColorContext::Color::MAGENTA)}); } @@ -327,7 +327,7 @@ Engine::main_iteration() _maid->cleanup(); if (_run_load.changed) { - _broadcaster->put(Raul::URI("ingen:/engine"), load_properties()); + _broadcaster->put(URI("ingen:/engine"), load_properties()); _run_load.changed = false; } diff --git a/src/server/Event.hpp b/src/server/Event.hpp index 48c9580d..d9095def 100644 --- a/src/server/Event.hpp +++ b/src/server/Event.hpp @@ -130,7 +130,7 @@ protected: return st == Status::SUCCESS; } - inline bool pre_process_done(Status st, const Raul::URI& subject) { + inline bool pre_process_done(Status st, const URI& subject) { _err_subject = subject; return pre_process_done(st); } diff --git a/src/server/EventWriter.hpp b/src/server/EventWriter.hpp index 2c7e5666..023761d6 100644 --- a/src/server/EventWriter.hpp +++ b/src/server/EventWriter.hpp @@ -40,9 +40,7 @@ class EventWriter : public Interface public: explicit EventWriter(Engine& engine); - Raul::URI uri() const override { - return Raul::URI("ingen:/clients/event_writer"); - } + URI uri() const override { return URI("ingen:/clients/event_writer"); } SPtr<Interface> respondee() const override { return _respondee; diff --git a/src/server/GraphPlugin.hpp b/src/server/GraphPlugin.hpp index 0314f9d6..308ed91a 100644 --- a/src/server/GraphPlugin.hpp +++ b/src/server/GraphPlugin.hpp @@ -33,7 +33,7 @@ class GraphPlugin : public PluginImpl { public: GraphPlugin(URIs& uris, - const Raul::URI& uri, + const URI& uri, const Raul::Symbol& symbol, const std::string& name) : PluginImpl(uris, uris.ingen_Graph.urid, uri) diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp index 17f6fc70..6529b9c0 100644 --- a/src/server/InternalPlugin.cpp +++ b/src/server/InternalPlugin.cpp @@ -30,7 +30,7 @@ namespace Server { using namespace Internals; InternalPlugin::InternalPlugin(URIs& uris, - const Raul::URI& uri, + const URI& uri, const Raul::Symbol& symbol) : PluginImpl(uris, uris.ingen_Internal.urid, uri) , _symbol(symbol) diff --git a/src/server/InternalPlugin.hpp b/src/server/InternalPlugin.hpp index d95afa1a..79309beb 100644 --- a/src/server/InternalPlugin.hpp +++ b/src/server/InternalPlugin.hpp @@ -18,7 +18,6 @@ #define INGEN_ENGINE_INTERNALPLUGIN_HPP #include "raul/Symbol.hpp" -#include "raul/URI.hpp" #include "PluginImpl.hpp" @@ -36,7 +35,7 @@ class InternalPlugin : public PluginImpl { public: InternalPlugin(URIs& uris, - const Raul::URI& uri, + const URI& uri, const Raul::Symbol& symbol); BlockImpl* instantiate(BufferFactory& bufs, diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 433ca758..d022077a 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -33,6 +33,7 @@ #include "ingen/Configuration.hpp" #include "ingen/LV2Features.hpp" #include "ingen/Log.hpp" +#include "ingen/URI.hpp" #include "ingen/URIMap.hpp" #include "ingen/World.hpp" #include "lv2/lv2plug.in/ns/ext/atom/util.h" @@ -278,7 +279,7 @@ JackDriver::rename_port(const Raul::Path& old_path, void JackDriver::port_property(const Raul::Path& path, - const Raul::URI& uri, + const URI& uri, const Atom& value) { #ifdef HAVE_JACK_METADATA @@ -292,7 +293,7 @@ JackDriver::port_property(const Raul::Path& path, void JackDriver::port_property_internal(const jack_port_t* jport, - const Raul::URI& uri, + const URI& uri, const Atom& value) { #ifdef HAVE_JACK_METADATA @@ -548,7 +549,7 @@ JackDriver::_session_cb(jack_session_event_t* event) SPtr<Node> root(_engine.root_graph(), NullDeleter<Node>); serialiser->write_bundle(root, - std::string("file://") + event->session_dir); + URI(std::string("file://") + event->session_dir)); } event->command_line = (char*)malloc(cmd.size() + 1); diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp index ce9af82e..678ce483 100644 --- a/src/server/JackDriver.hpp +++ b/src/server/JackDriver.hpp @@ -74,7 +74,7 @@ public: EnginePort* get_port(const Raul::Path& path); void rename_port(const Raul::Path& old_path, const Raul::Path& new_path); - void port_property(const Raul::Path& path, const Raul::URI& uri, const Atom& value); + void port_property(const Raul::Path& path, const URI& uri, const Atom& value); void add_port(RunContext& context, EnginePort* port); void remove_port(RunContext& context, EnginePort* port); void register_port(EnginePort& port); @@ -125,7 +125,7 @@ private: void post_process_port(RunContext& context, EnginePort* port); void port_property_internal(const jack_port_t* jport, - const Raul::URI& uri, + const URI& uri, const Atom& value); // Non static callbacks (methods) diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 440fb3c5..054d55ae 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -399,8 +399,8 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) LILV_FOREACH(nodes, v, values) { const LilvNode* val = lilv_nodes_get(values, v); if (lilv_node_is_uri(val)) { - port->add_property(Raul::URI(lilv_node_as_uri(preds[p])), - forge.make_urid(Raul::URI(lilv_node_as_uri(val)))); + port->add_property(URI(lilv_node_as_uri(preds[p])), + forge.make_urid(URI(lilv_node_as_uri(val)))); } } lilv_nodes_free(values); @@ -606,7 +606,7 @@ LV2Block::post_process(RunContext& context) } LilvState* -LV2Block::load_preset(const Raul::URI& uri) +LV2Block::load_preset(const URI& uri) { World* world = _lv2_plugin->world(); LilvWorld* lworld = world->lilv_world(); @@ -678,7 +678,7 @@ get_port_value(const char* port_symbol, } boost::optional<Resource> -LV2Block::save_preset(const Raul::URI& uri, +LV2Block::save_preset(const URI& uri, const Properties& props) { World* world = parent_graph()->engine().world(); @@ -686,7 +686,7 @@ LV2Block::save_preset(const Raul::URI& uri, LV2_URID_Map* lmap = &world->uri_map().urid_map_feature()->urid_map; LV2_URID_Unmap* lunmap = &world->uri_map().urid_unmap_feature()->urid_unmap; - const std::string path = Glib::filename_from_uri(uri); + const std::string path = Glib::filename_from_uri(uri.string()); const std::string dirname = Glib::path_get_dirname(path); const std::string basename = Glib::path_get_basename(path); @@ -704,7 +704,7 @@ LV2Block::save_preset(const Raul::URI& uri, lilv_state_save(lworld, lmap, lunmap, state, nullptr, dirname.c_str(), basename.c_str()); - const Raul::URI uri(lilv_node_as_uri(lilv_state_get_uri(state))); + const URI uri(lilv_node_as_uri(lilv_state_get_uri(state))); const std::string label(lilv_state_get_label(state) ? lilv_state_get_label(state) : basename); diff --git a/src/server/LV2Block.hpp b/src/server/LV2Block.hpp index d04d2048..eec852a2 100644 --- a/src/server/LV2Block.hpp +++ b/src/server/LV2Block.hpp @@ -68,11 +68,11 @@ public: void run(RunContext& context); void post_process(RunContext& context); - LilvState* load_preset(const Raul::URI& uri); + LilvState* load_preset(const URI& uri); void apply_state(const UPtr<Worker>& worker, const LilvState* state); - boost::optional<Resource> save_preset(const Raul::URI& uri, + boost::optional<Resource> save_preset(const URI& uri, const Properties& props); void set_port_buffer(uint32_t voice, diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp index d51aeda3..f56fd4d7 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, - Raul::URI(lilv_node_as_uri(lilv_plugin_get_uri(lplugin)))) + URI(lilv_node_as_uri(lilv_plugin_get_uri(lplugin)))) , _world(world) , _lilv_plugin(lplugin) { @@ -122,7 +122,7 @@ LV2Plugin::load_presets() if (labels) { const LilvNode* label = lilv_nodes_get_first(labels); - _presets.emplace(Raul::URI(lilv_node_as_uri(preset)), + _presets.emplace(URI(lilv_node_as_uri(preset)), lilv_node_as_string(label)); lilv_nodes_free(labels); diff --git a/src/server/LV2Plugin.hpp b/src/server/LV2Plugin.hpp index f490bbfd..43d0fba9 100644 --- a/src/server/LV2Plugin.hpp +++ b/src/server/LV2Plugin.hpp @@ -21,7 +21,6 @@ #include "ingen/types.hpp" #include "lilv/lilv.h" -#include "raul/URI.hpp" #include "PluginImpl.hpp" @@ -57,9 +56,9 @@ public: void load_presets(); - Raul::URI bundle_uri() const { + URI bundle_uri() const { const LilvNode* bundle = lilv_plugin_get_bundle_uri(_lilv_plugin); - return Raul::URI(lilv_node_as_uri(bundle)); + return URI(lilv_node_as_uri(bundle)); } private: diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp index d26fa51f..778ba15a 100644 --- a/src/server/NodeImpl.cpp +++ b/src/server/NodeImpl.cpp @@ -32,7 +32,7 @@ NodeImpl::NodeImpl(const Ingen::URIs& uris, } const Atom& -NodeImpl::get_property(const Raul::URI& key) const +NodeImpl::get_property(const URI& key) const { ThreadManager::assert_not_thread(THREAD_PROCESS); static const Atom null_atom; diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp index 81abb3ef..614801eb 100644 --- a/src/server/NodeImpl.hpp +++ b/src/server/NodeImpl.hpp @@ -64,7 +64,7 @@ public: set_uri(path_to_uri(new_path)); } - const Atom& get_property(const Raul::URI& key) const; + const Atom& get_property(const URI& key) const; /** The Graph this object is a child of. */ virtual GraphImpl* parent_graph() const; diff --git a/src/server/PluginImpl.hpp b/src/server/PluginImpl.hpp index 869c6520..ebd4b3e5 100644 --- a/src/server/PluginImpl.hpp +++ b/src/server/PluginImpl.hpp @@ -21,7 +21,6 @@ #include "ingen/Resource.hpp" #include "raul/Symbol.hpp" -#include "raul/URI.hpp" namespace Ingen { @@ -41,14 +40,13 @@ class GraphImpl; class PluginImpl : public Resource { public: - PluginImpl(Ingen::URIs& uris, - const Atom& type, - const Raul::URI& uri) - : Resource(uris, uri) - , _type(type) - , _presets_loaded(false) - , _is_zombie(false) - {} + PluginImpl(Ingen::URIs& uris, const Atom& type, const URI& uri) + : Resource(uris, uri) + , _type(type) + , _presets_loaded(false) + , _is_zombie(false) + { + } virtual BlockImpl* instantiate(BufferFactory& bufs, const Raul::Symbol& symbol, @@ -64,8 +62,8 @@ public: bool is_zombie() const { return _is_zombie; } void set_is_zombie(bool t) { _is_zombie = t; } - typedef std::pair<Raul::URI, std::string> Preset; - typedef std::map<Raul::URI, std::string> Presets; + typedef std::pair<URI, std::string> Preset; + typedef std::map<URI, std::string> Presets; const Presets& presets(bool force_reload=false) { if (!_presets_loaded || force_reload) { @@ -79,7 +77,7 @@ public: virtual void load_presets() { _presets_loaded = true; } - virtual Raul::URI bundle_uri() const { return Raul::URI("ingen:/"); } + virtual URI bundle_uri() const { return URI("ingen:/"); } protected: Atom _type; diff --git a/src/server/PortAudioDriver.cpp b/src/server/PortAudioDriver.cpp index 17b5c8cf..f892c99f 100644 --- a/src/server/PortAudioDriver.cpp +++ b/src/server/PortAudioDriver.cpp @@ -204,7 +204,7 @@ PortAudioDriver::rename_port(const Raul::Path& old_path, void PortAudioDriver::port_property(const Raul::Path& path, - const Raul::URI& uri, + const URI& uri, const Atom& value) { } diff --git a/src/server/PortAudioDriver.hpp b/src/server/PortAudioDriver.hpp index 3659b4ff..11772a88 100644 --- a/src/server/PortAudioDriver.hpp +++ b/src/server/PortAudioDriver.hpp @@ -58,7 +58,7 @@ public: EnginePort* get_port(const Raul::Path& path); void rename_port(const Raul::Path& old_path, const Raul::Path& new_path); - void port_property(const Raul::Path& path, const Raul::URI& uri, const Atom& value); + void port_property(const Raul::Path& path, const URI& uri, const Atom& value); void add_port(RunContext& context, EnginePort* port); void remove_port(RunContext& context, EnginePort* port); void register_port(EnginePort& port); diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp index be0426b0..0b62c5ab 100644 --- a/src/server/PortType.hpp +++ b/src/server/PortType.hpp @@ -19,8 +19,6 @@ #include <cassert> -#include "raul/URI.hpp" - #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/lv2core/lv2.h" @@ -42,7 +40,7 @@ public: ATOM = 4 }; - explicit PortType(const Raul::URI& uri) + explicit PortType(const URI& uri) : _id(UNKNOWN) { if (uri == type_uri(AUDIO)) { @@ -58,8 +56,8 @@ public: PortType(ID id) : _id(id) {} - inline const Raul::URI& uri() const { return type_uri(_id); } - inline ID id() const { return _id; } + inline const URI& uri() const { return type_uri(_id); } + inline ID id() const { return _id; } inline bool operator==(const ID& id) const { return (_id == id); } inline bool operator!=(const ID& id) const { return (_id != id); } @@ -73,14 +71,14 @@ public: inline bool is_atom() { return _id == ATOM; } private: - static inline const Raul::URI& type_uri(unsigned id_num) { + static inline const URI& type_uri(unsigned id_num) { assert(id_num <= ATOM); - static const Raul::URI uris[] = { - Raul::URI("http://www.w3.org/2002/07/owl#Nothing"), - Raul::URI(LV2_CORE__AudioPort), - Raul::URI(LV2_CORE__ControlPort), - Raul::URI(LV2_CORE__CVPort), - Raul::URI(LV2_ATOM__AtomPort) + static const URI uris[] = { + URI("http://www.w3.org/2002/07/owl#Nothing"), + URI(LV2_CORE__AudioPort), + URI(LV2_CORE__ControlPort), + URI(LV2_CORE__CVPort), + URI(LV2_ATOM__AtomPort) }; return uris[id_num]; } diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp index d065c41f..3ab9d15c 100644 --- a/src/server/RunContext.cpp +++ b/src/server/RunContext.cpp @@ -121,12 +121,12 @@ RunContext::emit_notifications(FrameTime end) const char* key = _engine.world()->uri_map().unmap_uri(note.key); if (key) { _engine.broadcaster()->set_property( - note.port->uri(), Raul::URI(key), value); + note.port->uri(), URI(key), value); if (note.port->is_input() && (note.key == uris.ingen_value || note.key == uris.midi_binding)) { // FIXME: not thread safe - note.port->set_property(Raul::URI(key), value); + note.port->set_property(URI(key), value); } } else { _engine.log().rt_error("Error unmapping notification key URI\n"); diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp index e62b822e..eecc28d1 100644 --- a/src/server/SocketListener.cpp +++ b/src/server/SocketListener.cpp @@ -88,8 +88,8 @@ ingen_listen(Engine* engine, Raul::Socket* unix_sock, Raul::Socket* net_sock) const std::string unix_path(link_path + "." + std::to_string(getpid())); // Bind UNIX socket and create PID-less symbolic link - const Raul::URI unix_uri(unix_scheme + unix_path); - bool make_link = true; + const URI unix_uri(unix_scheme + unix_path); + bool make_link = true; if (!unix_sock->bind(unix_uri) || !unix_sock->listen()) { world->log().error("Failed to create UNIX socket\n"); unix_sock->close(); @@ -127,7 +127,7 @@ ingen_listen(Engine* engine, Raul::Socket* unix_sock, Raul::Socket* net_sock) const int port = world->conf().option("engine-port").get<int32_t>(); std::ostringstream ss; ss << "tcp://*:" << port; - if (!net_sock->bind(Raul::URI(ss.str())) || !net_sock->listen()) { + if (!net_sock->bind(URI(ss.str())) || !net_sock->listen()) { world->log().error("Failed to create TCP socket\n"); net_sock->close(); } else { diff --git a/src/server/SocketServer.hpp b/src/server/SocketServer.hpp index 6420020e..dbeb76ea 100644 --- a/src/server/SocketServer.hpp +++ b/src/server/SocketServer.hpp @@ -41,14 +41,14 @@ public: new Tee({SPtr<Interface>(new EventWriter(engine)), SPtr<Interface>(new StreamWriter(world.uri_map(), world.uris(), - Raul::URI("ingen:/engine"), + URI("ingen:/engine"), stderr, ColorContext::Color::CYAN))})) : SPtr<Interface>(new EventWriter(engine))) , _reader(new SocketReader(world, *_sink.get(), sock)) , _writer(new SocketWriter(world.uri_map(), world.uris(), - sock->uri(), + URI(sock->uri()), sock)) { _sink->set_respondee(_writer); diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp index b1cea1db..fc9d40f7 100644 --- a/src/server/events/Copy.cpp +++ b/src/server/events/Copy.cpp @@ -150,7 +150,7 @@ Copy::engine_to_filesystem(PreProcessContext& ctx) std::lock_guard<std::mutex> lock(_engine.world()->rdf_mutex()); if (ends_with(_msg.new_uri, ".ingen") || ends_with(_msg.new_uri, ".ingen/")) { - _engine.world()->serialiser()->write_bundle(graph, _msg.new_uri); + _engine.world()->serialiser()->write_bundle(graph, URI(_msg.new_uri)); } else { _engine.world()->serialiser()->start_to_file(graph->path(), _msg.new_uri); _engine.world()->serialiser()->serialise(graph); @@ -170,7 +170,7 @@ Copy::filesystem_to_engine(PreProcessContext& ctx) std::lock_guard<std::mutex> lock(_engine.world()->rdf_mutex()); // Old URI is a filesystem path and new URI is a path within the engine - const std::string src_path = _msg.old_uri.substr(strlen("file://")); + const std::string src_path(_msg.old_uri.path()); const Raul::Path dst_path = uri_to_path(_msg.new_uri); boost::optional<Raul::Path> dst_parent; boost::optional<Raul::Symbol> dst_symbol; diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index 2c7978b1..fc0c0f5e 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -82,7 +82,7 @@ CreateBlock::pre_process(PreProcessContext& ctx) return Event::pre_process_done(Status::BAD_REQUEST); } - const Raul::URI prototype(uris.forge.str(t->second, false)); + const URI prototype(uris.forge.str(t->second, false)); // Find polyphony const iterator p = _properties.find(uris.ingen_polyphonic); diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index 43b3bb97..390fdd9a 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -140,11 +140,11 @@ CreateGraph::pre_process(PreProcessContext& ctx) if (t != _properties.end() && uris.forge.is_uri(t->second) && - Raul::URI::is_valid(uris.forge.str(t->second, false)) && - uri_is_path(Raul::URI(uris.forge.str(t->second, false)))) { + URI::is_valid(uris.forge.str(t->second, false)) && + uri_is_path(URI(uris.forge.str(t->second, false)))) { // Create a duplicate of an existing graph - const Raul::URI prototype(uris.forge.str(t->second, false)); - GraphImpl* ancestor = dynamic_cast<GraphImpl*>( + const URI prototype(uris.forge.str(t->second, false)); + GraphImpl* ancestor = dynamic_cast<GraphImpl*>( _engine.store()->get(uri_to_path(prototype))); if (!ancestor) { return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype); diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index 310579aa..e8f9582c 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -202,7 +202,7 @@ Delete::undo(Interface& target) // Adjust port indices for (const auto& c : _port_index_changes) { - if (c.first != _msg.uri) { + if (c.first != _msg.uri.path()) { target.set_property(path_to_uri(c.first), uris.lv2_index, forge.make(int32_t(c.second.first))); diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index b7cb9475..56cc22aa 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -178,7 +178,7 @@ Delta::pre_process(PreProcessContext& ctx) const bool is_graph_object = uri_is_path(_subject); const bool is_client = (_subject == "ingen:/clients/this"); const bool is_engine = (_subject == "ingen:/"); - const bool is_file = (_subject.substr(0, 5) == "file:"); + const bool is_file = (_subject.scheme() == "file"); if (_type == Type::PUT && is_file) { // Ensure type is Preset, the only supported file put @@ -195,7 +195,7 @@ Delta::pre_process(PreProcessContext& ctx) return Event::pre_process_done(Status::BAD_REQUEST, _subject); } - const Raul::URI prot(_engine.world()->forge().str(p->second, false)); + const URI prot(_engine.world()->forge().str(p->second, false)); if (!uri_is_path(prot)) { return Event::pre_process_done(Status::BAD_URI, _subject); } @@ -261,8 +261,8 @@ Delta::pre_process(PreProcessContext& ctx) // Remove any properties removed in delta for (const auto& r : _remove) { - const Raul::URI& key = r.first; - const Atom& value = r.second; + const URI& key = r.first; + const Atom& value = r.second; if (key == uris.midi_binding && value == uris.patch_wildcard) { PortImpl* port = dynamic_cast<PortImpl*>(_object); if (port) { @@ -314,9 +314,9 @@ Delta::pre_process(PreProcessContext& ctx) } for (const auto& p : _properties) { - const Raul::URI& key = p.first; - const Property& value = p.second; - SpecialType op = SpecialType::NONE; + const URI& key = p.first; + const Property& value = p.second; + SpecialType op = SpecialType::NONE; if (obj) { Resource& resource = *obj; if (value != uris.patch_wildcard) { @@ -373,8 +373,8 @@ Delta::pre_process(PreProcessContext& ctx) uri_str = Glib::filename_to_uri(value.ptr<char>()); } - if (Raul::URI::is_valid(uri_str)) { - const Raul::URI uri(uri_str); + if (URI::is_valid(uri_str)) { + const URI uri(uri_str); op = SpecialType::PRESET; if ((_state = block->load_preset(uri))) { lilv_state_emit_port_values( @@ -503,8 +503,8 @@ Delta::execute(RunContext& context) std::vector<SpecialType>::const_iterator t = _types.begin(); for (const auto& p : _properties) { - const Raul::URI& key = p.first; - const Atom& value = p.second; + const URI& key = p.first; + const Atom& value = p.second; switch (*t++) { case SpecialType::ENABLE_BROADCAST: if (port) { @@ -621,7 +621,7 @@ Delta::post_process() } break; case Type::PUT: - if (_type == Type::PUT && _subject.substr(0, 5) == "file:") { + if (_type == Type::PUT && _subject.scheme() == "file") { // Preset save ClientUpdate response; response.put(_preset->uri(), _preset->properties()); diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp index 47c4ab22..af337b57 100644 --- a/src/server/events/Delta.hpp +++ b/src/server/events/Delta.hpp @@ -23,8 +23,6 @@ #include "lilv/lilv.h" -#include "raul/URI.hpp" - #include "CompiledGraph.hpp" #include "ControlBindings.hpp" #include "Event.hpp" @@ -106,7 +104,7 @@ private: SetEvents _set_events; std::vector<SpecialType> _types; std::vector<SpecialType> _remove_types; - Raul::URI _subject; + URI _subject; Properties _properties; Properties _remove; ClientUpdate _update; diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 84f6f251..e53e8c41 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -99,7 +99,7 @@ Get::post_process() const Properties load_props = _engine.load_properties(); props.insert(load_props.begin(), load_props.end()); - _request_client->put(Raul::URI("ingen:/engine"), props); + _request_client->put(URI("ingen:/engine"), props); } else { _response.send(*_request_client); } diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 1b6652ae..b2806ab6 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -14,8 +14,7 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdlib.h> - +#include <cstdlib> #include <string> #include <thread> #include <vector> @@ -37,6 +36,7 @@ #include "ingen/Parser.hpp" #include "ingen/Serialiser.hpp" #include "ingen/Store.hpp" +#include "ingen/URI.hpp" #include "ingen/World.hpp" #include "ingen/ingen.h" #include "ingen/runtime_paths.hpp" @@ -232,7 +232,7 @@ public: /** Unused since LV2 has no dynamic ports. */ virtual void port_property(const Raul::Path& path, - const Raul::URI& uri, + const URI& uri, const Atom& value) {} virtual EnginePort* create_port(DuplexPort* graph_port) { @@ -439,7 +439,7 @@ struct IngenPlugin { }; static Lib::Graphs -find_graphs(const std::string& manifest_uri) +find_graphs(const URI& manifest_uri) { Sord::World world; Parser parser; @@ -447,7 +447,7 @@ find_graphs(const std::string& manifest_uri) const std::set<Parser::ResourceRecord> resources = parser.find_resources( world, manifest_uri, - Raul::URI(INGEN__Graph)); + URI(INGEN__Graph)); Lib::Graphs graphs; for (const auto& r : resources) { @@ -496,7 +496,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor, SerdNode manifest_node = serd_node_new_file_uri( (const uint8_t*)manifest_path.c_str(), nullptr, nullptr, true); - Lib::Graphs graphs = find_graphs((const char*)manifest_node.buf); + Lib::Graphs graphs = find_graphs(URI((const char*)manifest_node.buf)); serd_node_free(&manifest_node); const LV2Graph* graph = nullptr; @@ -809,7 +809,7 @@ Lib::Lib(const char* bundle_path) SerdNode manifest_node = serd_node_new_file_uri( (const uint8_t*)manifest_path.c_str(), nullptr, nullptr, true); - graphs = find_graphs((const char*)manifest_node.buf); + graphs = find_graphs(URI((const char*)manifest_node.buf)); serd_node_free(&manifest_node); } diff --git a/src/server/internals/BlockDelay.cpp b/src/server/internals/BlockDelay.cpp index c0e8dded..e9667cc5 100644 --- a/src/server/internals/BlockDelay.cpp +++ b/src/server/internals/BlockDelay.cpp @@ -35,7 +35,7 @@ namespace Internals { InternalPlugin* BlockDelayNode::internal_plugin(URIs& uris) { return new InternalPlugin( - uris, Raul::URI(NS_INTERNALS "BlockDelay"), Raul::Symbol("blockDelay")); + uris, URI(NS_INTERNALS "BlockDelay"), Raul::Symbol("blockDelay")); } BlockDelayNode::BlockDelayNode(InternalPlugin* plugin, diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index ec701767..a0b2320b 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -36,7 +36,7 @@ namespace Internals { InternalPlugin* ControllerNode::internal_plugin(URIs& uris) { return new InternalPlugin( - uris, Raul::URI(NS_INTERNALS "Controller"), Raul::Symbol("controller")); + uris, URI(NS_INTERNALS "Controller"), Raul::Symbol("controller")); } ControllerNode::ControllerNode(InternalPlugin* plugin, @@ -53,7 +53,7 @@ ControllerNode::ControllerNode(InternalPlugin* plugin, const Atom zero = bufs.forge().make(0.0f); const Atom one = bufs.forge().make(1.0f); - const Atom atom_Float = bufs.forge().make_urid(Raul::URI(LV2_ATOM__Float)); + const Atom atom_Float = bufs.forge().make_urid(URI(LV2_ATOM__Float)); _midi_in_port = new InputPort(bufs, this, Raul::Symbol("input"), 0, 1, PortType::ATOM, uris.atom_Sequence, Atom()); diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index b3688dfd..665ee472 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -40,7 +40,7 @@ namespace Internals { InternalPlugin* NoteNode::internal_plugin(URIs& uris) { return new InternalPlugin( - uris, Raul::URI(NS_INTERNALS "Note"), Raul::Symbol("note")); + uris, URI(NS_INTERNALS "Note"), Raul::Symbol("note")); } NoteNode::NoteNode(InternalPlugin* plugin, diff --git a/src/server/internals/Time.cpp b/src/server/internals/Time.cpp index 2da2a2ae..5474bf21 100644 --- a/src/server/internals/Time.cpp +++ b/src/server/internals/Time.cpp @@ -33,7 +33,7 @@ namespace Internals { InternalPlugin* TimeNode::internal_plugin(URIs& uris) { return new InternalPlugin( - uris, Raul::URI(NS_INTERNALS "Time"), Raul::Symbol("time")); + uris, URI(NS_INTERNALS "Time"), Raul::Symbol("time")); } TimeNode::TimeNode(InternalPlugin* plugin, diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp index 8adf211c..69967877 100644 --- a/src/server/internals/Trigger.cpp +++ b/src/server/internals/Trigger.cpp @@ -36,7 +36,7 @@ namespace Internals { InternalPlugin* TriggerNode::internal_plugin(URIs& uris) { return new InternalPlugin( - uris, Raul::URI(NS_INTERNALS "Trigger"), Raul::Symbol("trigger")); + uris, URI(NS_INTERNALS "Trigger"), Raul::Symbol("trigger")); } TriggerNode::TriggerNode(InternalPlugin* plugin, diff --git a/src/wscript b/src/wscript index 5b308386..5429ba26 100644 --- a/src/wscript +++ b/src/wscript @@ -17,6 +17,7 @@ def build(bld): 'Store.cpp', 'StreamWriter.cpp', 'TurtleWriter.cpp', + 'URI.cpp', 'URIMap.cpp', 'URIs.cpp', 'World.cpp', diff --git a/tests/TestClient.hpp b/tests/TestClient.hpp index 6af0235a..8d99db86 100644 --- a/tests/TestClient.hpp +++ b/tests/TestClient.hpp @@ -30,7 +30,7 @@ public: explicit TestClient(Log& log) : _log(log) {} ~TestClient() {} - Raul::URI uri() const override { return Raul::URI("ingen:testClient"); } + URI uri() const override { return URI("ingen:testClient"); } void message(const Message& msg) override { if (const Response* const response = boost::get<Response>(&msg)) { diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index 5f0f6772..ccd39d9c 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -191,7 +191,7 @@ main(int argc, char** argv) const std::string base = Glib::path_get_basename(cmds_file_path); const std::string out_name = base.substr(0, base.find('.')) + ".out.ingen"; const std::string out_path = Glib::build_filename(Glib::get_current_dir(), out_name); - world->serialiser()->write_bundle(r->second, Glib::filename_to_uri(out_path)); + world->serialiser()->write_bundle(r->second, URI(Glib::filename_to_uri(out_path))); // Undo every event (should result in a graph identical to the original) for (int i = 0; i < n_events; ++i) { @@ -203,7 +203,7 @@ main(int argc, char** argv) r = world->store()->find(Raul::Path("/")); const std::string undo_name = base.substr(0, base.find('.')) + ".undo.ingen"; const std::string undo_path = Glib::build_filename(Glib::get_current_dir(), undo_name); - world->serialiser()->write_bundle(r->second, Glib::filename_to_uri(undo_path)); + world->serialiser()->write_bundle(r->second, URI(Glib::filename_to_uri(undo_path))); // Redo every event (should result in a graph identical to the pre-undo output) for (int i = 0; i < n_events; ++i) { @@ -215,7 +215,7 @@ main(int argc, char** argv) r = world->store()->find(Raul::Path("/")); const std::string redo_name = base.substr(0, base.find('.')) + ".redo.ingen"; const std::string redo_path = Glib::build_filename(Glib::get_current_dir(), redo_name); - world->serialiser()->write_bundle(r->second, Glib::filename_to_uri(redo_path)); + world->serialiser()->write_bundle(r->second, URI(Glib::filename_to_uri(redo_path))); serd_env_free(env); sratom_free(sratom); @@ -88,7 +88,7 @@ def configure(conf): autowaf.check_pkg(conf, 'sratom-0', uselib_store='SRATOM', atleast_version='0.4.6', mandatory=True) autowaf.check_pkg(conf, 'raul', uselib_store='RAUL', - atleast_version='0.8.9', mandatory=True) + atleast_version='0.8.10', mandatory=True) autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD', atleast_version='0.18.0', mandatory=False) autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD', |