summaryrefslogtreecommitdiffstats
path: root/ingen/Resource.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-11 04:47:21 +0000
committerDavid Robillard <d@drobilla.net>2013-01-11 04:47:21 +0000
commit10e9a3a800a35916872abf9e354be4c554338e4e (patch)
treed6be3ce7993f5d8efd525629fd321b32a6341633 /ingen/Resource.hpp
parent684eaf6b58e41f6758b160b882a6313faf0cff18 (diff)
downloadingen-10e9a3a800a35916872abf9e354be4c554338e4e.tar.gz
ingen-10e9a3a800a35916872abf9e354be4c554338e4e.tar.bz2
ingen-10e9a3a800a35916872abf9e354be4c554338e4e.zip
Use type safe enumerations.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4918 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'ingen/Resource.hpp')
-rw-r--r--ingen/Resource.hpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp
index 025a963f..e741a633 100644
--- a/ingen/Resource.hpp
+++ b/ingen/Resource.hpp
@@ -40,7 +40,7 @@ public:
, _uri(uri)
{}
- enum Graph {
+ enum class Graph {
DEFAULT,
EXTERNAL,
INTERNAL
@@ -48,31 +48,31 @@ public:
static Raul::URI graph_to_uri(Graph g) {
switch (g) {
- case DEFAULT: return Raul::URI(NS_INGEN "defaultContext");
- case EXTERNAL: return Raul::URI(NS_INGEN "externalContext");
- case INTERNAL: return Raul::URI(NS_INGEN "internalContext");
+ case Graph::DEFAULT: return Raul::URI(NS_INGEN "defaultContext");
+ case Graph::EXTERNAL: return Raul::URI(NS_INGEN "externalContext");
+ case Graph::INTERNAL: return Raul::URI(NS_INGEN "internalContext");
}
}
static Graph uri_to_graph(const char* uri) {
const char* suffix = uri + sizeof(NS_INGEN) - 1;
if (strncmp(uri, NS_INGEN, sizeof(NS_INGEN) - 1)) {
- return DEFAULT;
+ return Graph::DEFAULT;
} else if (!strcmp(suffix, "defaultContext")) {
- return DEFAULT;
+ return Graph::DEFAULT;
} else if (!strcmp(suffix, "externalContext")) {
- return EXTERNAL;
+ return Graph::EXTERNAL;
} else if (!strcmp(suffix, "internalContext")) {
- return INTERNAL;
+ return Graph::INTERNAL;
} else {
- return DEFAULT;
+ return Graph::DEFAULT;
}
}
/** A property value (an Atom with a context). */
class Property : public Raul::Atom {
public:
- Property(const Raul::Atom& atom, Graph ctx=DEFAULT)
+ Property(const Raul::Atom& atom, Graph ctx=Graph::DEFAULT)
: Raul::Atom(atom)
, _ctx(ctx)
{}
@@ -100,9 +100,10 @@ public:
* This will first erase any properties with the given @p uri, so after
* this call exactly one property with predicate @p uri will be set.
*/
- virtual const Raul::Atom& set_property(const Raul::URI& uri,
- const Raul::Atom& value,
- Graph ctx=DEFAULT);
+ virtual const Raul::Atom& set_property(
+ const Raul::URI& uri,
+ const Raul::Atom& value,
+ Graph ctx=Graph::DEFAULT);
/** Add a property value.
*
@@ -112,7 +113,7 @@ public:
*/
virtual void add_property(const Raul::URI& uri,
const Raul::Atom& value,
- Graph ctx=DEFAULT);
+ Graph ctx=Graph::DEFAULT);
/** Remove a property.
*