From ddaaa0e19ce196eba68e88165a483cf62478895b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 19 May 2011 22:36:30 +0000 Subject: Convey put context parameter via OSC. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3287 a436a847-0d15-0410-975c-d299462d15a1 --- include/ingen/Resource.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include') diff --git a/include/ingen/Resource.hpp b/include/ingen/Resource.hpp index 09879501..136c2df8 100644 --- a/include/ingen/Resource.hpp +++ b/include/ingen/Resource.hpp @@ -23,6 +23,9 @@ #include "raul/Atom.hpp" #include "raul/URI.hpp" +#include "raul/log.hpp" + +#define NS_INGEN "http://drobilla.net/software/ingen#" namespace Ingen { @@ -35,6 +38,37 @@ public: INTERNAL }; + static Raul::URI graph_to_uri(Graph g) { + switch (g) { + default: + case DEFAULT: + return "http://drobilla.net/software/ingen#defaultContext"; + case EXTERNAL: + return "http://drobilla.net/software/ingen#externalContext"; + case INTERNAL: + return "http://drobilla.net/software/ingen#internalContext"; + } + } + + static Graph uri_to_graph(const char* uri) { + const size_t prefix_len = strlen("http://drobilla.net/software/ingen#"); + if (strncmp(uri, NS_INGEN, sizeof(NS_INGEN) - 1)) { + return DEFAULT; + } + + const char* suffix = uri + prefix_len; + if (!strcmp(suffix, "defaultContext")) { + return DEFAULT; + } else if (!strcmp(suffix, "externalContext")) { + return EXTERNAL; + } else if (!strcmp(suffix, "internalContext")) { + return INTERNAL; + } + + Raul::error << "Unknown context URI " << uri << std::endl; + return DEFAULT; + } + class Property : public Raul::Atom { public: Property(const Raul::Atom& atom, Graph ctx=DEFAULT) -- cgit v1.2.1