diff options
author | David Robillard <d@drobilla.net> | 2013-01-11 04:47:21 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-11 04:47:21 +0000 |
commit | 10e9a3a800a35916872abf9e354be4c554338e4e (patch) | |
tree | d6be3ce7993f5d8efd525629fd321b32a6341633 /ingen | |
parent | 684eaf6b58e41f6758b160b882a6313faf0cff18 (diff) | |
download | ingen-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')
-rw-r--r-- | ingen/AtomWriter.hpp | 2 | ||||
-rw-r--r-- | ingen/ClashAvoider.hpp | 2 | ||||
-rw-r--r-- | ingen/Interface.hpp | 2 | ||||
-rw-r--r-- | ingen/Node.hpp | 2 | ||||
-rw-r--r-- | ingen/Resource.hpp | 29 | ||||
-rw-r--r-- | ingen/Status.hpp | 52 | ||||
-rw-r--r-- | ingen/client/BlockModel.hpp | 2 | ||||
-rw-r--r-- | ingen/client/ClientStore.hpp | 2 | ||||
-rw-r--r-- | ingen/client/GraphModel.hpp | 2 | ||||
-rw-r--r-- | ingen/client/PortModel.hpp | 8 | ||||
-rw-r--r-- | ingen/client/SigClientInterface.hpp | 2 | ||||
-rw-r--r-- | ingen/client/ThreadedSigClientInterface.hpp | 2 |
12 files changed, 54 insertions, 53 deletions
diff --git a/ingen/AtomWriter.hpp b/ingen/AtomWriter.hpp index 4e3e489a..3dab20ec 100644 --- a/ingen/AtomWriter.hpp +++ b/ingen/AtomWriter.hpp @@ -46,7 +46,7 @@ public: void put(const Raul::URI& uri, const Resource::Properties& properties, - Resource::Graph ctx = Resource::DEFAULT); + Resource::Graph ctx = Resource::Graph::DEFAULT); void delta(const Raul::URI& uri, const Resource::Properties& remove, diff --git a/ingen/ClashAvoider.hpp b/ingen/ClashAvoider.hpp index e3ff519b..ac3f7e07 100644 --- a/ingen/ClashAvoider.hpp +++ b/ingen/ClashAvoider.hpp @@ -56,7 +56,7 @@ public: virtual void put(const Raul::URI& path, const Resource::Properties& properties, - Resource::Graph ctx=Resource::DEFAULT); + Resource::Graph ctx=Resource::Graph::DEFAULT); virtual void delta(const Raul::URI& path, const Resource::Properties& remove, diff --git a/ingen/Interface.hpp b/ingen/Interface.hpp index 59749dec..7f1fe9b7 100644 --- a/ingen/Interface.hpp +++ b/ingen/Interface.hpp @@ -61,7 +61,7 @@ public: virtual void put(const Raul::URI& uri, const Resource::Properties& properties, - Resource::Graph ctx=Resource::DEFAULT) = 0; + Resource::Graph ctx=Resource::Graph::DEFAULT) = 0; virtual void delta(const Raul::URI& uri, const Resource::Properties& remove, diff --git a/ingen/Node.hpp b/ingen/Node.hpp index 42e21ee3..d61732ff 100644 --- a/ingen/Node.hpp +++ b/ingen/Node.hpp @@ -48,7 +48,7 @@ class Store; class Node : public Resource { public: - enum GraphType { + enum class GraphType { GRAPH, BLOCK, PORT 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. * diff --git a/ingen/Status.hpp b/ingen/Status.hpp index 13df53b3..b754702a 100644 --- a/ingen/Status.hpp +++ b/ingen/Status.hpp @@ -19,7 +19,7 @@ namespace Ingen { -enum Status { +enum class Status { SUCCESS, FAILURE, @@ -52,32 +52,32 @@ static inline const char* ingen_status_string(Status st) { switch (st) { - case SUCCESS: return "Success"; - case FAILURE: return "Failure"; + case Status::SUCCESS: return "Success"; + case Status::FAILURE: return "Failure"; - case BAD_INDEX: return "Invalid index"; - case BAD_OBJECT_TYPE: return "Invalid object type"; - case BAD_REQUEST: return "Invalid request"; - case BAD_URI: return "Invalid URI"; - case BAD_VALUE_TYPE: return "Invalid value type"; - case CLIENT_NOT_FOUND: return "Client not found"; - case CREATION_FAILED: return "Creation failed"; - case DIRECTION_MISMATCH: return "Direction mismatch"; - case EXISTS: return "Object exists"; - case INTERNAL_ERROR: return "Internal error"; - case INVALID_PARENT_PATH: return "Invalid parent path"; - case INVALID_POLY: return "Invalid polyphony"; - case NOT_DELETABLE: return "Object not deletable"; - case NOT_FOUND: return "Object not found"; - case NOT_MOVABLE: return "Object not movable"; - case NOT_PREPARED: return "Not prepared"; - case NO_SPACE: return "Insufficient space"; - case PARENT_DIFFERS: return "Parent differs"; - case PARENT_NOT_FOUND: return "Parent not found"; - case PLUGIN_NOT_FOUND: return "Plugin not found"; - case PORT_NOT_FOUND: return "Port not found"; - case TYPE_MISMATCH: return "Type mismatch"; - case UNKNOWN_TYPE: return "Unknown type"; + case Status::BAD_INDEX: return "Invalid index"; + case Status::BAD_OBJECT_TYPE: return "Invalid object type"; + case Status::BAD_REQUEST: return "Invalid request"; + case Status::BAD_URI: return "Invalid URI"; + case Status::BAD_VALUE_TYPE: return "Invalid value type"; + case Status::CLIENT_NOT_FOUND: return "Client not found"; + case Status::CREATION_FAILED: return "Creation failed"; + case Status::DIRECTION_MISMATCH: return "Direction mismatch"; + case Status::EXISTS: return "Object exists"; + case Status::INTERNAL_ERROR: return "Internal error"; + case Status::INVALID_PARENT_PATH: return "Invalid parent path"; + case Status::INVALID_POLY: return "Invalid polyphony"; + case Status::NOT_DELETABLE: return "Object not deletable"; + case Status::NOT_FOUND: return "Object not found"; + case Status::NOT_MOVABLE: return "Object not movable"; + case Status::NOT_PREPARED: return "Not prepared"; + case Status::NO_SPACE: return "Insufficient space"; + case Status::PARENT_DIFFERS: return "Parent differs"; + case Status::PARENT_NOT_FOUND: return "Parent not found"; + case Status::PLUGIN_NOT_FOUND: return "Plugin not found"; + case Status::PORT_NOT_FOUND: return "Port not found"; + case Status::TYPE_MISMATCH: return "Type mismatch"; + case Status::UNKNOWN_TYPE: return "Unknown type"; } return "Unknown error"; diff --git a/ingen/client/BlockModel.hpp b/ingen/client/BlockModel.hpp index 547894b4..3262b230 100644 --- a/ingen/client/BlockModel.hpp +++ b/ingen/client/BlockModel.hpp @@ -48,7 +48,7 @@ public: BlockModel(const BlockModel& copy); virtual ~BlockModel(); - GraphType graph_type() const { return Node::BLOCK; } + GraphType graph_type() const { return Node::GraphType::BLOCK; } typedef std::vector< SharedPtr<const PortModel> > Ports; diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp index fa5b2f5a..3d7d724a 100644 --- a/ingen/client/ClientStore.hpp +++ b/ingen/client/ClientStore.hpp @@ -75,7 +75,7 @@ public: void put(const Raul::URI& uri, const Resource::Properties& properties, - Resource::Graph ctx=Resource::DEFAULT); + Resource::Graph ctx=Resource::Graph::DEFAULT); void delta(const Raul::URI& uri, const Resource::Properties& remove, diff --git a/ingen/client/GraphModel.hpp b/ingen/client/GraphModel.hpp index a721dc37..996e9129 100644 --- a/ingen/client/GraphModel.hpp +++ b/ingen/client/GraphModel.hpp @@ -35,7 +35,7 @@ class GraphModel : public BlockModel public: /* WARNING: Copy constructor creates a shallow copy WRT connections */ - GraphType graph_type() const { return Node::GRAPH; } + GraphType graph_type() const { return Node::GraphType::GRAPH; } SharedPtr<ArcModel> get_arc(const Ingen::Node* tail, const Ingen::Node* head); diff --git a/ingen/client/PortModel.hpp b/ingen/client/PortModel.hpp index 41b871ab..92379e6e 100644 --- a/ingen/client/PortModel.hpp +++ b/ingen/client/PortModel.hpp @@ -39,17 +39,17 @@ namespace Client { class PortModel : public ObjectModel { public: - enum Direction { INPUT, OUTPUT }; + enum class Direction { INPUT, OUTPUT }; - GraphType graph_type() const { return Node::PORT; } + GraphType graph_type() const { return Node::GraphType::PORT; } bool supports(const Raul::URI& value_type) const; inline uint32_t index() const { return _index; } inline const Raul::Atom& value() const { return get_property(_uris.ingen_value); } inline bool connected() const { return (_connections > 0); } - inline bool is_input() const { return (_direction == INPUT); } - inline bool is_output() const { return (_direction == OUTPUT); } + inline bool is_input() const { return (_direction == Direction::INPUT); } + inline bool is_output() const { return (_direction == Direction::OUTPUT); } bool port_property(const Raul::URI& uri) const; diff --git a/ingen/client/SigClientInterface.hpp b/ingen/client/SigClientInterface.hpp index 2453440f..900a9923 100644 --- a/ingen/client/SigClientInterface.hpp +++ b/ingen/client/SigClientInterface.hpp @@ -83,7 +83,7 @@ protected: void put(const Raul::URI& uri, const Resource::Properties& properties, - Resource::Graph ctx=Resource::DEFAULT) + Resource::Graph ctx=Resource::Graph::DEFAULT) { EMIT(put, uri, properties, ctx); } void delta(const Raul::URI& uri, diff --git a/ingen/client/ThreadedSigClientInterface.hpp b/ingen/client/ThreadedSigClientInterface.hpp index 0b53a15a..d4e5f6d6 100644 --- a/ingen/client/ThreadedSigClientInterface.hpp +++ b/ingen/client/ThreadedSigClientInterface.hpp @@ -81,7 +81,7 @@ public: void put(const Raul::URI& path, const Resource::Properties& properties, - Resource::Graph ctx=Resource::DEFAULT) + Resource::Graph ctx=Resource::Graph::DEFAULT) { push_sig(sigc::bind(put_slot, path, properties, ctx)); } void delta(const Raul::URI& path, |