diff options
Diffstat (limited to 'ingen')
-rw-r--r-- | ingen/AtomReader.hpp | 6 | ||||
-rw-r--r-- | ingen/AtomWriter.hpp | 2 | ||||
-rw-r--r-- | ingen/GraphObject.hpp | 16 |
3 files changed, 21 insertions, 3 deletions
diff --git a/ingen/AtomReader.hpp b/ingen/AtomReader.hpp index f14ebefd..579dc0ea 100644 --- a/ingen/AtomReader.hpp +++ b/ingen/AtomReader.hpp @@ -17,6 +17,8 @@ #ifndef INGEN_ATOMREADER_HPP #define INGEN_ATOMREADER_HPP +#include <boost/optional.hpp> + #include "ingen/Interface.hpp" #include "ingen/AtomSink.hpp" #include "ingen/URIs.hpp" @@ -43,7 +45,9 @@ public: private: void get_atom(const LV2_Atom* in, Raul::Atom& out); - const char* atom_to_uri(const LV2_Atom* atom); + + const char* atom_to_uri(const LV2_Atom* atom); + boost::optional<Raul::Path> atom_to_path(const LV2_Atom* atom); void get_props(const LV2_Atom_Object* obj, Ingen::Resource::Properties& props); diff --git a/ingen/AtomWriter.hpp b/ingen/AtomWriter.hpp index 31a3c099..ebfece4c 100644 --- a/ingen/AtomWriter.hpp +++ b/ingen/AtomWriter.hpp @@ -79,7 +79,7 @@ public: private: void forge_uri(const Raul::URI& uri); void forge_properties(const Resource::Properties& properties); - void forge_edge(const Raul::URI& tail, const Raul::URI& head); + void forge_edge(const Raul::Path& tail, const Raul::Path& head); void finish_msg(); int32_t next_id(); diff --git a/ingen/GraphObject.hpp b/ingen/GraphObject.hpp index 80da116e..fef73c6e 100644 --- a/ingen/GraphObject.hpp +++ b/ingen/GraphObject.hpp @@ -63,9 +63,23 @@ public: virtual const Raul::Symbol& symbol() const = 0; virtual GraphObject* graph_parent() const = 0; + static Raul::URI root_uri() { return Raul::URI("ingen:root"); } + + static bool uri_is_path(const Raul::URI& uri) { + return uri.substr(0, root_uri().length()) == root_uri().str(); + } + + static Raul::Path uri_to_path(const Raul::URI& uri) { + return (uri == root_uri()) ? "/" : uri.substr(root_uri().length()); + } + + static Raul::URI path_to_uri(const Raul::Path& path) { + return Raul::URI(root_uri().str() + path.c_str()); + } + protected: GraphObject(URIs& uris, const Raul::Path& path) - : Resource(uris, path) + : Resource(uris, path_to_uri(path)) {} Edges _edges; ///< Patches only |