From 10e9a3a800a35916872abf9e354be4c554338e4e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 Jan 2013 04:47:21 +0000 Subject: Use type safe enumerations. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4918 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/AtomWriter.hpp | 2 +- ingen/ClashAvoider.hpp | 2 +- ingen/Interface.hpp | 2 +- ingen/Node.hpp | 2 +- ingen/Resource.hpp | 29 +++++++------- ingen/Status.hpp | 52 ++++++++++++------------ ingen/client/BlockModel.hpp | 2 +- ingen/client/ClientStore.hpp | 2 +- ingen/client/GraphModel.hpp | 2 +- ingen/client/PortModel.hpp | 8 ++-- ingen/client/SigClientInterface.hpp | 2 +- ingen/client/ThreadedSigClientInterface.hpp | 2 +- src/AtomWriter.cpp | 2 +- src/Builder.cpp | 2 +- src/Resource.cpp | 4 +- src/client/ClientStore.cpp | 4 +- src/gui/App.cpp | 2 +- src/gui/ConnectWindow.cpp | 20 +++++----- src/gui/ConnectWindow.hpp | 2 +- src/gui/GraphBox.cpp | 2 +- src/gui/GraphCanvas.cpp | 4 +- src/gui/GraphCanvas.hpp | 4 +- src/gui/GraphPortModule.cpp | 4 +- src/gui/LoadPluginWindow.cpp | 28 ++++++------- src/gui/LoadPluginWindow.hpp | 2 +- src/gui/NewSubgraphWindow.cpp | 6 ++- src/gui/SubgraphModule.cpp | 4 +- src/serialisation/Serialiser.cpp | 32 +++++++-------- src/server/ArcImpl.cpp | 20 +++++----- src/server/BlockFactory.cpp | 4 +- src/server/BlockImpl.cpp | 2 +- src/server/BlockImpl.hpp | 2 +- src/server/Broadcaster.hpp | 2 +- src/server/Buffer.cpp | 8 ++-- src/server/Context.hpp | 2 +- src/server/ControlBindings.cpp | 56 +++++++++++++------------- src/server/ControlBindings.hpp | 6 +-- src/server/Engine.cpp | 16 +++++--- src/server/Event.hpp | 10 ++--- src/server/EventWriter.cpp | 4 +- src/server/EventWriter.hpp | 2 +- src/server/GraphImpl.hpp | 2 +- src/server/InputPort.cpp | 2 +- src/server/LV2ResizeFeature.hpp | 2 +- src/server/OutputPort.cpp | 2 +- src/server/PortImpl.cpp | 31 ++++++++------- src/server/PortImpl.hpp | 6 +-- src/server/PortType.hpp | 46 +++++++++++----------- src/server/ProcessContext.hpp | 2 +- src/server/events/Connect.cpp | 20 +++++----- src/server/events/CreateBlock.cpp | 17 ++++---- src/server/events/CreateGraph.cpp | 13 +++--- src/server/events/CreatePort.cpp | 20 +++++----- src/server/events/Delete.cpp | 12 +++--- src/server/events/Delta.cpp | 61 +++++++++++++++-------------- src/server/events/Delta.hpp | 2 +- src/server/events/Disconnect.cpp | 20 +++++----- src/server/events/DisconnectAll.cpp | 16 ++++---- src/server/events/Get.cpp | 20 +++++----- src/server/events/Move.cpp | 10 ++--- src/server/events/SetPortValue.cpp | 16 ++++---- src/server/internals/Note.cpp | 44 ++++++++++----------- src/server/internals/Note.hpp | 8 ++-- src/socket/Socket.cpp | 10 ++--- src/socket/Socket.hpp | 4 +- src/socket/SocketListener.cpp | 4 +- 66 files changed, 384 insertions(+), 369 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 > 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 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, diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index 2e24e8cc..b0cb2f27 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -284,7 +284,7 @@ AtomWriter::response(int32_t id, Status status, const std::string& subject) lv2_atom_forge_uri(&_forge, subject.c_str(), subject.length()); } lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); - lv2_atom_forge_int(&_forge, status); + lv2_atom_forge_int(&_forge, static_cast(status)); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); } diff --git a/src/Builder.cpp b/src/Builder.cpp index fc7d855d..b4bd2b3a 100644 --- a/src/Builder.cpp +++ b/src/Builder.cpp @@ -41,7 +41,7 @@ Builder::build(SharedPtr object) void Builder::connect(SharedPtr object) { - if (object->graph_type() == Node::GRAPH) { + if (object->graph_type() == Node::GraphType::GRAPH) { for (Node::Arcs::const_iterator i = object->arcs().begin(); i != object->arcs().end(); ++i) { _interface.connect(i->second->tail_path(), i->second->head_path()); diff --git a/src/Resource.cpp b/src/Resource.cpp index 7db46a81..38c00248 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -186,7 +186,7 @@ Resource::remove_properties(const Properties& p) Resource::Properties Resource::properties(Resource::Graph ctx) const { - if (ctx == Resource::DEFAULT) { + if (ctx == Resource::Graph::DEFAULT) { return properties(); } @@ -194,7 +194,7 @@ Resource::properties(Resource::Graph ctx) const Properties props; for (iterator i = _properties.begin(); i != _properties.end(); ++i) { - if (i->second.context() == Resource::DEFAULT + if (i->second.context() == Resource::Graph::DEFAULT || i->second.context() == ctx) { props.insert(make_pair(i->first, i->second)); } diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 6b2c1540..a6b011a4 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -287,8 +287,8 @@ ClientStore::put(const Raul::URI& uri, } } else if (is_port) { PortModel::Direction pdir = (is_output) - ? PortModel::OUTPUT - : PortModel::INPUT; + ? PortModel::Direction::OUTPUT + : PortModel::Direction::INPUT; const Iterator i = properties.find(_uris.lv2_index); if (i != properties.end() && i->second.type() == _uris.forge.Int) { const uint32_t index = i->second.get_int32(); diff --git a/src/gui/App.cpp b/src/gui/App.cpp index d23cdc38..11da12f0 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -214,7 +214,7 @@ App::serialiser() void App::response(int32_t id, Status status, const std::string& subject) { - if (status) { + if (status != Status::SUCCESS) { std::string msg = ingen_status_string(status); if (!subject.empty()) { msg += ": " + subject; diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index 36827489..ab889461 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -59,7 +59,7 @@ ConnectWindow::ConnectWindow(BaseObjectType* cobject, , _disconnect_button(NULL) , _connect_button(NULL) , _quit_button(NULL) - , _mode(CONNECT_REMOTE) + , _mode(Mode::CONNECT_REMOTE) , _ping_id(-1) , _attached(false) , _finished_connecting(false) @@ -75,7 +75,7 @@ ConnectWindow::start(App& app, Ingen::World* world) _app = &app; if (world->engine()) { - _mode = INTERNAL; + _mode = Mode::INTERNAL; if (_widgets_loaded) { _internal_radio->set_active(true); } @@ -118,9 +118,9 @@ ConnectWindow::set_connected_to(SharedPtr engine) _server_radio->set_sensitive(true); _launch_radio->set_sensitive(true); - if (_mode == CONNECT_REMOTE ) + if (_mode == Mode::CONNECT_REMOTE) _url_entry->set_sensitive(true); - else if (_mode == LAUNCH_REMOTE ) + else if (_mode == Mode::LAUNCH_REMOTE) _port_spinbutton->set_sensitive(true); _progress_label->set_text(string("Disconnected")); @@ -161,7 +161,7 @@ ConnectWindow::connect(bool existing) Ingen::World* world = _app->world(); #ifdef HAVE_SOCKET - if (_mode == CONNECT_REMOTE) { + if (_mode == Mode::CONNECT_REMOTE) { Raul::URI uri("unix:///tmp/ingen.sock"); if (_widgets_loaded) { const std::string& user_uri = _url_entry->get_text(); @@ -190,7 +190,7 @@ ConnectWindow::connect(bool existing) Glib::signal_timeout().connect( sigc::mem_fun(this, &ConnectWindow::gtk_callback), 40); return; - } else if (_mode == LAUNCH_REMOTE) { + } else if (_mode == Mode::LAUNCH_REMOTE) { int port = _port_spinbutton->get_value_as_int(); std::stringstream ss; ss << port; @@ -214,7 +214,7 @@ ConnectWindow::connect(bool existing) return; } #endif - if (_mode == INTERNAL) { + if (_mode == Mode::INTERNAL) { if (!world->engine()) { world->load_module("server"); world->load_module("jack"); @@ -340,7 +340,7 @@ ConnectWindow::server_toggled() { _url_entry->set_sensitive(true); _port_spinbutton->set_sensitive(false); - _mode = CONNECT_REMOTE; + _mode = Mode::CONNECT_REMOTE; } void @@ -348,7 +348,7 @@ ConnectWindow::launch_toggled() { _url_entry->set_sensitive(false); _port_spinbutton->set_sensitive(true); - _mode = LAUNCH_REMOTE; + _mode = Mode::LAUNCH_REMOTE; } void @@ -356,7 +356,7 @@ ConnectWindow::internal_toggled() { _url_entry->set_sensitive(false); _port_spinbutton->set_sensitive(false); - _mode = INTERNAL; + _mode = Mode::INTERNAL; } bool diff --git a/src/gui/ConnectWindow.hpp b/src/gui/ConnectWindow.hpp index 2f7a43e7..ade0f3b1 100644 --- a/src/gui/ConnectWindow.hpp +++ b/src/gui/ConnectWindow.hpp @@ -59,7 +59,7 @@ public: bool quit_flag() const { return _quit_flag; } private: - enum Mode { CONNECT_REMOTE, LAUNCH_REMOTE, INTERNAL }; + enum class Mode { CONNECT_REMOTE, LAUNCH_REMOTE, INTERNAL }; void server_toggled(); void launch_toggled(); diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index ef3b3c8c..1440bc1a 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -535,7 +535,7 @@ GraphBox::event_save_as() const_cast(_graph.get())->set_property( uris.ingen_document, _app->forge().alloc_uri(uri.c_str()), - Resource::EXTERNAL); + Resource::Graph::EXTERNAL); _status_bar->push( (boost::format("Saved %1% to %2%") % _graph->path().c_str() % filename).str(), diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 216d0cab..d8ba7b2e 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -909,14 +909,14 @@ void GraphCanvas::menu_load_graph() { _app.window_factory()->present_load_subgraph( - _graph, get_initial_data(Resource::EXTERNAL)); + _graph, get_initial_data(Resource::Graph::EXTERNAL)); } void GraphCanvas::menu_new_graph() { _app.window_factory()->present_new_subgraph( - _graph, get_initial_data(Resource::EXTERNAL)); + _graph, get_initial_data(Resource::Graph::EXTERNAL)); } void diff --git a/src/gui/GraphCanvas.hpp b/src/gui/GraphCanvas.hpp index 1d04e582..6d4bbc87 100644 --- a/src/gui/GraphCanvas.hpp +++ b/src/gui/GraphCanvas.hpp @@ -83,7 +83,7 @@ public: bool on_event(GdkEvent* event); private: - enum ControlType { NUMBER, BUTTON }; + enum class ControlType { NUMBER, BUTTON }; void generate_port_name( const std::string& sym_base, std::string& sym, const std::string& name_base, std::string& name); @@ -114,7 +114,7 @@ private: const LV2Children& children, std::set& ancestors); - Node::Properties get_initial_data(Resource::Graph ctx=Resource::DEFAULT); + Node::Properties get_initial_data(Resource::Graph ctx=Resource::Graph::DEFAULT); Ganv::Port* get_port_view(SharedPtr port); diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp index 6c5f91b4..6d8ac465 100644 --- a/src/gui/GraphPortModule.cpp +++ b/src/gui/GraphPortModule.cpp @@ -112,9 +112,9 @@ GraphPortModule::store_location(double ax, double ay) Resource::Property(uris.wildcard))); Resource::Properties add; add.insert(make_pair(uris.ingen_canvasX, - Resource::Property(x, Resource::INTERNAL))); + Resource::Property(x, Resource::Graph::INTERNAL))); add.insert(make_pair(uris.ingen_canvasY, - Resource::Property(y, Resource::INTERNAL))); + Resource::Property(y, Resource::Graph::INTERNAL))); app().interface()->delta(_model->uri(), remove, add); } } diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index b21a33fc..b7e12281 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -82,24 +82,24 @@ LoadPluginWindow::LoadPluginWindow(BaseObjectType* cobject, Gtk::TreeModel::iterator iter = _criteria_liststore->append(); Gtk::TreeModel::Row row = *iter; row[_criteria_columns._col_label] = "Name contains"; - row[_criteria_columns._col_criteria] = CriteriaColumns::NAME; + row[_criteria_columns._col_criteria] = CriteriaColumns::Criteria::NAME; _filter_combo->set_active(iter); row = *(iter = _criteria_liststore->append()); row[_criteria_columns._col_label] = "Type contains"; - row[_criteria_columns._col_criteria] = CriteriaColumns::TYPE; + row[_criteria_columns._col_criteria] = CriteriaColumns::Criteria::TYPE; row = *(iter = _criteria_liststore->append()); row[_criteria_columns._col_label] = "Project contains"; - row[_criteria_columns._col_criteria] = CriteriaColumns::PROJECT; + row[_criteria_columns._col_criteria] = CriteriaColumns::Criteria::PROJECT; row = *(iter = _criteria_liststore->append()); row[_criteria_columns._col_label] = "Author contains"; - row[_criteria_columns._col_criteria] = CriteriaColumns::AUTHOR; + row[_criteria_columns._col_criteria] = CriteriaColumns::Criteria::AUTHOR; row = *(iter = _criteria_liststore->append()); row[_criteria_columns._col_label] = "URI contains"; - row[_criteria_columns._col_criteria] = CriteriaColumns::URI; + row[_criteria_columns._col_criteria] = CriteriaColumns::Criteria::URI; _filter_combo->pack_start(_criteria_columns._col_label); _add_button->signal_clicked().connect( @@ -277,6 +277,9 @@ LoadPluginWindow::set_row(Gtk::TreeModel::Row& row, row[_plugins_columns._col_name] = name.get_string(); switch (plugin->type()) { + case Plugin::NIL: + row[_plugins_columns._col_type] = ""; + break; case Plugin::LV2: row[_plugins_columns._col_type] = lilv_node_as_string( lilv_plugin_class_get_label( @@ -293,9 +296,6 @@ LoadPluginWindow::set_row(Gtk::TreeModel::Row& row, case Plugin::Graph: row[_plugins_columns._col_type] = "Graph"; break; - default: - row[_plugins_columns._col_type] = ""; - break; } row[_plugins_columns._col_uri] = plugin->uri(); @@ -452,24 +452,22 @@ LoadPluginWindow::filter_changed() const Raul::Atom& name = plugin->get_property(uris.doap_name); switch (criteria) { - case CriteriaColumns::NAME: + case CriteriaColumns::Criteria::NAME: if (name.is_valid() && name.type() == uris.forge.String) field = name.get_string(); break; - case CriteriaColumns::TYPE: + case CriteriaColumns::Criteria::TYPE: field = plugin->type_uri(); break; - case CriteriaColumns::PROJECT: + case CriteriaColumns::Criteria::PROJECT: field = get_project_name(plugin); break; - case CriteriaColumns::AUTHOR: + case CriteriaColumns::Criteria::AUTHOR: field = get_author_name(plugin); break; - case CriteriaColumns::URI: + case CriteriaColumns::Criteria::URI: field = plugin->uri(); break; - default: - throw; } transform(field.begin(), field.end(), field.begin(), ::toupper); diff --git a/src/gui/LoadPluginWindow.hpp b/src/gui/LoadPluginWindow.hpp index 0cf8bc55..ed2e979c 100644 --- a/src/gui/LoadPluginWindow.hpp +++ b/src/gui/LoadPluginWindow.hpp @@ -93,7 +93,7 @@ private: /** Column for the filter criteria combo box. */ class CriteriaColumns : public Gtk::TreeModel::ColumnRecord { public: - enum Criteria { NAME, TYPE, PROJECT, AUTHOR, URI, }; + enum class Criteria { NAME, TYPE, PROJECT, AUTHOR, URI, }; CriteriaColumns() { add(_col_label); diff --git a/src/gui/NewSubgraphWindow.cpp b/src/gui/NewSubgraphWindow.cpp index a748de8d..f2457843 100644 --- a/src/gui/NewSubgraphWindow.cpp +++ b/src/gui/NewSubgraphWindow.cpp @@ -98,13 +98,15 @@ NewSubgraphWindow::ok_clicked() props.insert(make_pair(_app->uris().rdf_type, Resource::Property(_app->uris().ingen_Graph))); props.insert(make_pair(_app->uris().ingen_polyphony, _app->forge().make(int32_t(poly)))); props.insert(make_pair(_app->uris().ingen_enabled, _app->forge().make(bool(true)))); - _app->interface()->put(Node::path_to_uri(path), props, Resource::INTERNAL); + _app->interface()->put( + Node::path_to_uri(path), props, Resource::Graph::INTERNAL); // Set external (block perspective) properties props = _initial_data; props.insert(make_pair(_app->uris().rdf_type, Resource::Property(_app->uris().ingen_Graph))); - _app->interface()->put(Node::path_to_uri(path), _initial_data, Resource::EXTERNAL); + _app->interface()->put( + Node::path_to_uri(path), _initial_data, Resource::Graph::EXTERNAL); hide(); } diff --git a/src/gui/SubgraphModule.cpp b/src/gui/SubgraphModule.cpp index 215521da..88dbc81b 100644 --- a/src/gui/SubgraphModule.cpp +++ b/src/gui/SubgraphModule.cpp @@ -77,9 +77,9 @@ SubgraphModule::store_location(double ax, double ay) Resource::Property(uris.wildcard))); Resource::Properties add; add.insert(make_pair(uris.ingen_canvasX, - Resource::Property(x, Resource::EXTERNAL))); + Resource::Property(x, Resource::Graph::EXTERNAL))); add.insert(make_pair(uris.ingen_canvasY, - Resource::Property(y, Resource::EXTERNAL))); + Resource::Property(y, Resource::Graph::EXTERNAL))); app().interface()->delta(_block->uri(), remove, add); } } diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index 85ecbfb4..e371151a 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -62,7 +62,7 @@ struct Serialiser::Impl { sratom_free(_sratom); } - enum Mode { TO_FILE, TO_STRING }; + enum class Mode { TO_FILE, TO_STRING }; void start_to_filename(const std::string& filename); @@ -218,7 +218,7 @@ Serialiser::Impl::start_to_filename(const string& filename) } _model = new Sord::Model(*_world.rdf_world(), _base_uri); - _mode = TO_FILE; + _mode = Mode::TO_FILE; } /** Begin a serialization to a string. @@ -237,7 +237,7 @@ Serialiser::start_to_string(const Raul::Path& root, const string& base_uri) me->_root_path = root; me->_base_uri = base_uri; me->_model = new Sord::Model(*me->_world.rdf_world(), base_uri); - me->_mode = Impl::TO_STRING; + me->_mode = Impl::Mode::TO_STRING; } std::string @@ -250,7 +250,7 @@ std::string Serialiser::Impl::finish() { string ret = ""; - if (_mode == TO_FILE) { + if (_mode == Mode::TO_FILE) { SerdStatus st = _model->write_to_file(_base_uri, SERD_TURTLE); if (st) { _world.log().error(Raul::fmt("Error writing file %1% (%2%)\n") @@ -284,14 +284,14 @@ Serialiser::serialise(SharedPtr object) throw (std::logic_error) if (!me->_model) throw std::logic_error("serialise called without serialisation in progress"); - if (object->graph_type() == Node::GRAPH) { + if (object->graph_type() == Node::GraphType::GRAPH) { me->serialise_graph(object, me->path_rdf_node(object->path())); - } else if (object->graph_type() == Node::BLOCK) { + } else if (object->graph_type() == Node::GraphType::BLOCK) { const Sord::URI plugin_id(me->_model->world(), object->plugin()->uri()); me->serialise_block(object, plugin_id, me->path_rdf_node(object->path())); - } else if (object->graph_type() == Node::PORT) { + } else if (object->graph_type() == Node::GraphType::PORT) { me->serialise_port(object.get(), - Resource::DEFAULT, + Resource::Graph::DEFAULT, me->path_rdf_node(object->path())); } else { me->serialise_properties(me->path_rdf_node(object->path()), @@ -345,7 +345,7 @@ Serialiser::Impl::serialise_graph(SharedPtr graph, Sord::URI(world, uris.doap_name), Sord::Literal(world, symbol.c_str())); - const Node::Properties props = graph->properties(Resource::INTERNAL); + const Node::Properties props = graph->properties(Resource::Graph::INTERNAL); serialise_properties(graph_id, props); const Store::const_range kids = _world.store()->children_range(graph); @@ -353,7 +353,7 @@ Serialiser::Impl::serialise_graph(SharedPtr graph, if (n->first.parent() != graph->path()) continue; - if (n->second->graph_type() == Node::GRAPH) { + if (n->second->graph_type() == Node::GraphType::GRAPH) { SharedPtr subgraph = n->second; SerdURI base_uri; @@ -386,7 +386,7 @@ Serialiser::Impl::serialise_graph(SharedPtr graph, Sord::URI(world, uris.ingen_block), block_id); serialise_block(subgraph, subgraph_id, block_id); - } else if (n->second->graph_type() == Node::BLOCK) { + } else if (n->second->graph_type() == Node::GraphType::BLOCK) { SharedPtr block = n->second; const Sord::URI class_id(world, block->plugin()->uri()); @@ -410,7 +410,7 @@ Serialiser::Impl::serialise_graph(SharedPtr graph, _model->add_statement(graph_id, Sord::URI(world, LV2_CORE__port), port_id); - serialise_port(p, Resource::INTERNAL, port_id); + serialise_port(p, Resource::Graph::INTERNAL, port_id); } for (Node::Arcs::const_iterator a = graph->arcs().begin(); @@ -436,13 +436,13 @@ Serialiser::Impl::serialise_block(SharedPtr block, Sord::URI(_model->world(), uris.lv2_symbol), Sord::Literal(_model->world(), block->path().symbol())); - const Node::Properties props = block->properties(Resource::EXTERNAL); + const Node::Properties props = block->properties(Resource::Graph::EXTERNAL); serialise_properties(block_id, props); for (uint32_t i = 0; i < block->num_ports(); ++i) { Node* const p = block->port(i); const Sord::Node port_id = path_rdf_node(p->path()); - serialise_port(p, Resource::EXTERNAL, port_id); + serialise_port(p, Resource::Graph::EXTERNAL, port_id); _model->add_statement(block_id, Sord::URI(_model->world(), uris.lv2_port), port_id); @@ -462,7 +462,7 @@ Serialiser::Impl::serialise_port(const Node* port, Sord::Literal(world, port->path().symbol())); Node::Properties props = port->properties(context); - if (context == Resource::INTERNAL && + if (context == Resource::Graph::INTERNAL && port->has_property(uris.rdf_type, uris.lv2_ControlPort) && port->has_property(uris.rdf_type, uris.lv2_InputPort)) { @@ -472,7 +472,7 @@ Serialiser::Impl::serialise_port(const Node* port, } else { _world.log().warn("Control input has no value, lv2:default omitted.\n"); } - } else if (context != Resource::INTERNAL && + } else if (context != Resource::Graph::INTERNAL && !port->has_property(uris.rdf_type, uris.lv2_InputPort)) { props.erase(uris.ingen_value); } diff --git a/src/server/ArcImpl.cpp b/src/server/ArcImpl.cpp index debd2c1e..eea8ddcb 100644 --- a/src/server/ArcImpl.cpp +++ b/src/server/ArcImpl.cpp @@ -78,28 +78,28 @@ ArcImpl::can_connect(const OutputPort* src, const InputPort* dst) const Ingen::URIs& uris = src->bufs().uris(); return ( // (Audio | Control | CV) => (Audio | Control | CV) - ( (src->is_a(PortType::CONTROL) || - src->is_a(PortType::AUDIO) || - src->is_a(PortType::CV)) - && (dst->is_a(PortType::CONTROL) - || dst->is_a(PortType::AUDIO) - || dst->is_a(PortType::CV))) + ( (src->is_a(PortType::ID::CONTROL) || + src->is_a(PortType::ID::AUDIO) || + src->is_a(PortType::ID::CV)) + && (dst->is_a(PortType::ID::CONTROL) + || dst->is_a(PortType::ID::AUDIO) + || dst->is_a(PortType::ID::CV))) // Equal types || (src->type() == dst->type() && src->buffer_type() == dst->buffer_type()) // Control => atom:Float Value - || (src->is_a(PortType::CONTROL) && dst->supports(uris.atom_Float)) + || (src->is_a(PortType::ID::CONTROL) && dst->supports(uris.atom_Float)) // Audio => atom:Sound Value - || (src->is_a(PortType::AUDIO) && dst->supports(uris.atom_Sound)) + || (src->is_a(PortType::ID::AUDIO) && dst->supports(uris.atom_Sound)) // atom:Float Value => Control - || (src->supports(uris.atom_Float) && dst->is_a(PortType::CONTROL)) + || (src->supports(uris.atom_Float) && dst->is_a(PortType::ID::CONTROL)) // atom:Sound Value => Audio - || (src->supports(uris.atom_Sound) && dst->is_a(PortType::AUDIO))); + || (src->supports(uris.atom_Sound) && dst->is_a(PortType::ID::AUDIO))); } } // namespace Server diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp index 101c97e8..9f5b93d8 100644 --- a/src/server/BlockFactory.cpp +++ b/src/server/BlockFactory.cpp @@ -122,8 +122,8 @@ BlockFactory::load_lv2_plugins() // Build an array of port type nodes for checking compatibility typedef std::vector< SharedPtr > Types; Types types; - for (unsigned t = PortType::AUDIO; t <= PortType::ATOM; ++t) { - const Raul::URI& uri(PortType((PortType::Symbol)t).uri()); + for (unsigned t = PortType::ID::AUDIO; t <= PortType::ID::ATOM; ++t) { + const Raul::URI& uri(PortType((PortType::ID)t).uri()); types.push_back(SharedPtr( lilv_new_uri(_world->lilv_world(), uri.c_str()), lilv_node_free)); diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp index 6c09e9b7..072b4049 100644 --- a/src/server/BlockImpl.cpp +++ b/src/server/BlockImpl.cpp @@ -41,7 +41,7 @@ BlockImpl::BlockImpl(PluginImpl* plugin, : NodeImpl(plugin->uris(), parent, symbol) , _plugin(plugin) , _ports(NULL) - , _context(Context::AUDIO) + , _context(Context::ID::AUDIO) , _polyphony((polyphonic && parent) ? parent->internal_poly() : 1) , _polyphonic(polyphonic) , _activated(false) diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp index a94278b5..15d5a46e 100644 --- a/src/server/BlockImpl.hpp +++ b/src/server/BlockImpl.hpp @@ -66,7 +66,7 @@ public: virtual ~BlockImpl(); - virtual GraphType graph_type() const { return BLOCK; } + virtual GraphType graph_type() const { return GraphType::BLOCK; } /** Activate this Block. * diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp index 157b07ea..78419991 100644 --- a/src/server/Broadcaster.hpp +++ b/src/server/Broadcaster.hpp @@ -83,7 +83,7 @@ public: void put(const Raul::URI& uri, const Resource::Properties& properties, - Resource::Graph ctx=Resource::DEFAULT) { + Resource::Graph ctx=Resource::Graph::DEFAULT) { BROADCAST(put, uri, properties); } diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index 38a27fa8..270d95aa 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -123,10 +123,10 @@ Buffer::resize(uint32_t capacity) void* Buffer::port_data(PortType port_type) { - switch (port_type.symbol()) { - case PortType::CONTROL: - case PortType::CV: - case PortType::AUDIO: + switch (port_type.id()) { + case PortType::ID::CONTROL: + case PortType::ID::CV: + case PortType::ID::AUDIO: if (_atom->type == _factory.uris().atom_Float) { return (float*)LV2_ATOM_BODY(_atom); } else if (_atom->type == _factory.uris().atom_Sound) { diff --git a/src/server/Context.hpp b/src/server/Context.hpp index 5343b817..028ee126 100644 --- a/src/server/Context.hpp +++ b/src/server/Context.hpp @@ -44,7 +44,7 @@ class PortImpl; class Context { public: - enum ID { + enum class ID { AUDIO, MESSAGE }; diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index e8f595fa..25d49265 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -72,9 +72,9 @@ ControlBindings::binding_key(const Raul::Atom& binding) const const LV2_Atom_Object_Body* obj = (const LV2_Atom_Object_Body*) binding.get_body(); if (obj->otype == uris.midi_Bender) { - key = Key(MIDI_BENDER); + key = Key(Type::MIDI_BENDER); } else if (obj->otype == uris.midi_ChannelPressure) { - key = Key(MIDI_CHANNEL_PRESSURE); + key = Key(Type::MIDI_CHANNEL_PRESSURE); } else if (obj->otype == uris.midi_Controller) { lv2_atom_object_body_get( binding.size(), obj, (LV2_URID)uris.midi_controllerNumber, &num, NULL); @@ -83,7 +83,7 @@ ControlBindings::binding_key(const Raul::Atom& binding) const } else if (num->type != uris.atom_Int) { _engine.log().error("Controller number not an integer\n"); } else { - key = Key(MIDI_CC, ((LV2_Atom_Int*)num)->body); + key = Key(Type::MIDI_CC, ((LV2_Atom_Int*)num)->body); } } else if (obj->otype == uris.midi_NoteOn) { lv2_atom_object_body_get( @@ -93,7 +93,7 @@ ControlBindings::binding_key(const Raul::Atom& binding) const } else if (num->type != uris.atom_Int) { _engine.log().error("Note number not an integer\n"); } else { - key = Key(MIDI_NOTE, ((LV2_Atom_Int*)num)->body); + key = Key(Type::MIDI_NOTE, ((LV2_Atom_Int*)num)->body); } } } else if (binding.type()) { @@ -108,16 +108,16 @@ ControlBindings::midi_event_key(uint16_t size, const uint8_t* buf, uint16_t& val switch (lv2_midi_message_type(buf)) { case LV2_MIDI_MSG_CONTROLLER: value = static_cast(buf[2]); - return Key(MIDI_CC, static_cast(buf[1])); + return Key(Type::MIDI_CC, static_cast(buf[1])); case LV2_MIDI_MSG_BENDER: value = (static_cast(buf[2]) << 7) + static_cast(buf[1]); - return Key(MIDI_BENDER); + return Key(Type::MIDI_BENDER); case LV2_MIDI_MSG_CHANNEL_PRESSURE: value = static_cast(buf[1]); - return Key(MIDI_CHANNEL_PRESSURE); + return Key(Type::MIDI_CHANNEL_PRESSURE); case LV2_MIDI_MSG_NOTE_ON: value = 1.0f; - return Key(MIDI_NOTE, static_cast(buf[1])); + return Key(Type::MIDI_NOTE, static_cast(buf[1])); default: return Key(); } @@ -148,24 +148,24 @@ ControlBindings::port_value_changed(ProcessContext& context, uint16_t size = 0; uint8_t buf[4]; switch (key.type) { - case MIDI_CC: + case Type::MIDI_CC: size = 3; buf[0] = LV2_MIDI_MSG_CONTROLLER; buf[1] = key.num; buf[2] = static_cast(value); break; - case MIDI_CHANNEL_PRESSURE: + case Type::MIDI_CHANNEL_PRESSURE: size = 2; buf[0] = LV2_MIDI_MSG_CHANNEL_PRESSURE; buf[1] = static_cast(value); break; - case MIDI_BENDER: + case Type::MIDI_BENDER: size = 3; buf[0] = LV2_MIDI_MSG_BENDER; buf[1] = (value & 0x007F); buf[2] = (value & 0x7F00) >> 7; break; - case MIDI_NOTE: + case Type::MIDI_NOTE: size = 3; if (value == 1) { buf[0] = LV2_MIDI_MSG_NOTE_ON; @@ -210,14 +210,14 @@ ControlBindings::control_to_port_value(ProcessContext& context, { float normal = 0.0f; switch (type) { - case MIDI_CC: - case MIDI_CHANNEL_PRESSURE: + case Type::MIDI_CC: + case Type::MIDI_CHANNEL_PRESSURE: normal = (float)value / 127.0f; break; - case MIDI_BENDER: + case Type::MIDI_BENDER: normal = (float)value / 16383.0f; break; - case MIDI_NOTE: + case Type::MIDI_NOTE: normal = (value == 0.0f) ? 0.0f : 1.0f; break; default: @@ -262,12 +262,12 @@ ControlBindings::port_value_to_control(ProcessContext& context, } switch (type) { - case MIDI_CC: - case MIDI_CHANNEL_PRESSURE: + case Type::MIDI_CC: + case Type::MIDI_CHANNEL_PRESSURE: return lrintf(normal * 127.0f); - case MIDI_BENDER: + case Type::MIDI_BENDER: return lrintf(normal * 16383.0f); - case MIDI_NOTE: + case Type::MIDI_NOTE: return (value > 0.0f) ? 1 : 0; default: return 0; @@ -282,25 +282,25 @@ forge_binding(const URIs& uris, { LV2_Atom_Forge_Frame frame; switch (binding_type) { - case ControlBindings::MIDI_CC: + case ControlBindings::Type::MIDI_CC: lv2_atom_forge_blank(forge, &frame, 0, uris.midi_Controller); lv2_atom_forge_property_head(forge, uris.midi_controllerNumber, 0); lv2_atom_forge_int(forge, value); break; - case ControlBindings::MIDI_BENDER: + case ControlBindings::Type::MIDI_BENDER: lv2_atom_forge_blank(forge, &frame, 0, uris.midi_Bender); break; - case ControlBindings::MIDI_CHANNEL_PRESSURE: + case ControlBindings::Type::MIDI_CHANNEL_PRESSURE: lv2_atom_forge_blank(forge, &frame, 0, uris.midi_ChannelPressure); break; - case ControlBindings::MIDI_NOTE: + case ControlBindings::Type::MIDI_NOTE: lv2_atom_forge_blank(forge, &frame, 0, uris.midi_NoteOn); lv2_atom_forge_property_head(forge, uris.midi_noteNumber, 0); lv2_atom_forge_int(forge, value); break; - case ControlBindings::MIDI_RPN: // TODO - case ControlBindings::MIDI_NRPN: // TODO - case ControlBindings::NULL_CONTROL: + case ControlBindings::Type::MIDI_RPN: // TODO + case ControlBindings::Type::MIDI_NRPN: // TODO + case ControlBindings::Type::NULL_CONTROL: break; } } @@ -330,7 +330,7 @@ ControlBindings::bind(ProcessContext& context, Key key) { const Ingen::URIs& uris = context.engine().world()->uris(); assert(_learn_port); - if (key.type == MIDI_NOTE) { + if (key.type == Type::MIDI_NOTE) { if (!_learn_port->is_toggled()) return false; } diff --git a/src/server/ControlBindings.hpp b/src/server/ControlBindings.hpp index 286dde15..630ec18a 100644 --- a/src/server/ControlBindings.hpp +++ b/src/server/ControlBindings.hpp @@ -36,7 +36,7 @@ class PortImpl; class ControlBindings { public: - enum Type { + enum class Type { NULL_CONTROL, MIDI_BENDER, MIDI_CC, @@ -47,11 +47,11 @@ public: }; struct Key { - Key(Type t=NULL_CONTROL, int16_t n=0) : type(t), num(n) {} + Key(Type t=Type::NULL_CONTROL, int16_t n=0) : type(t), num(n) {} inline bool operator<(const Key& other) const { return (type == other.type) ? (num < other.num) : (type < other.type); } - inline operator bool() const { return type != NULL_CONTROL; } + inline operator bool() const { return type != Type::NULL_CONTROL; } Type type; int16_t num; }; diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index faac9514..ce84de4d 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -201,11 +201,11 @@ Engine::activate() *this, Raul::Symbol("root"), 1, NULL, _driver->sample_rate(), 1); _root_graph->set_property( uris.rdf_type, - Resource::Property(uris.ingen_Graph, Resource::INTERNAL)); + Resource::Property(uris.ingen_Graph, Resource::Graph::INTERNAL)); _root_graph->set_property( uris.ingen_polyphony, Resource::Property(_world->forge().make(int32_t(1)), - Resource::INTERNAL)); + Resource::Graph::INTERNAL)); _root_graph->activate(*_buffer_factory); _world->store()->add(_root_graph); _root_graph->set_compiled_graph(_root_graph->compile()); @@ -233,10 +233,12 @@ Engine::activate() Resource::Property(uris.lv2_connectionOptional))); in_properties.insert( make_pair(uris.ingen_canvasX, - Resource::Property(forge.make(32.0f), Resource::EXTERNAL))); + Resource::Property(forge.make(32.0f), + Resource::Graph::EXTERNAL))); in_properties.insert( make_pair(uris.ingen_canvasY, - Resource::Property(forge.make(32.0f), Resource::EXTERNAL))); + Resource::Property(forge.make(32.0f), + Resource::Graph::EXTERNAL))); SharedPtr respondee; execute_and_delete_event( @@ -255,10 +257,12 @@ Engine::activate() Resource::Property(uris.lv2_connectionOptional))); out_properties.insert( make_pair(uris.ingen_canvasX, - Resource::Property(forge.make(128.0f), Resource::EXTERNAL))); + Resource::Property(forge.make(128.0f), + Resource::Graph::EXTERNAL))); out_properties.insert( make_pair(uris.ingen_canvasY, - Resource::Property(forge.make(32.0f), Resource::EXTERNAL))); + Resource::Property(forge.make(32.0f), + Resource::Graph::EXTERNAL))); execute_and_delete_event( context, new Events::CreatePort( diff --git a/src/server/Event.hpp b/src/server/Event.hpp index 171e7cc9..e2000d09 100644 --- a/src/server/Event.hpp +++ b/src/server/Event.hpp @@ -63,7 +63,7 @@ public: virtual void post_process() = 0; /** Return true iff this event has been pre-processed. */ - inline bool is_prepared() const { return _status != NOT_PREPARED; } + inline bool is_prepared() const { return _status != Status::NOT_PREPARED; } /** Return the time stamp of this event. */ inline SampleCount time() const { return _time; } @@ -87,7 +87,7 @@ protected: , _request_client(client) , _request_id(id) , _time(time) - , _status(NOT_PREPARED) + , _status(Status::NOT_PREPARED) {} /** Constructor for internal events only */ @@ -96,18 +96,18 @@ protected: , _next(NULL) , _request_id(-1) , _time(0) - , _status(NOT_PREPARED) + , _status(Status::NOT_PREPARED) {} inline bool pre_process_done(Status st) { _status = st; - return !st; + return st == Status::SUCCESS; } inline bool pre_process_done(Status st, const Raul::URI& subject) { _status = st; _err_subject = subject; - return !st; + return st == Status::SUCCESS; } inline bool pre_process_done(Status st, const Raul::Path& subject) { diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp index a169e389..0c27bc5f 100644 --- a/src/server/EventWriter.cpp +++ b/src/server/EventWriter.cpp @@ -64,7 +64,7 @@ EventWriter::delta(const Raul::URI& uri, { _engine.enqueue_event( new Events::Delta(_engine, _respondee, _request_id, now(), - false, Resource::DEFAULT, uri, add, remove)); + false, Resource::Graph::DEFAULT, uri, add, remove)); } void @@ -124,7 +124,7 @@ EventWriter::set_property(const Raul::URI& uri, add.insert(make_pair(predicate, value)); _engine.enqueue_event( new Events::Delta(_engine, _respondee, _request_id, now(), - false, Resource::DEFAULT, uri, add, remove)); + false, Resource::Graph::DEFAULT, uri, add, remove)); } void diff --git a/src/server/EventWriter.hpp b/src/server/EventWriter.hpp index c2fc0b81..68f93cbd 100644 --- a/src/server/EventWriter.hpp +++ b/src/server/EventWriter.hpp @@ -58,7 +58,7 @@ public: virtual void put(const Raul::URI& path, const Resource::Properties& properties, - const Resource::Graph g=Resource::DEFAULT); + const Resource::Graph g=Resource::Graph::DEFAULT); virtual void delta(const Raul::URI& path, const Resource::Properties& remove, diff --git a/src/server/GraphImpl.hpp b/src/server/GraphImpl.hpp index 2e534ca7..450318ba 100644 --- a/src/server/GraphImpl.hpp +++ b/src/server/GraphImpl.hpp @@ -58,7 +58,7 @@ public: virtual ~GraphImpl(); - virtual GraphType graph_type() const { return GRAPH; } + virtual GraphType graph_type() const { return GraphType::GRAPH; } void activate(BufferFactory& bufs); void deactivate(); diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 9ab3cbfe..fe534eb0 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -50,7 +50,7 @@ InputPort::InputPort(BufferFactory& bufs, { const Ingen::URIs& uris = bufs.uris(); - if (parent->graph_type() != Node::GRAPH) { + if (parent->graph_type() != Node::GraphType::GRAPH) { add_property(uris.rdf_type, uris.lv2_InputPort); } diff --git a/src/server/LV2ResizeFeature.hpp b/src/server/LV2ResizeFeature.hpp index 8edd7868..aeabe47a 100644 --- a/src/server/LV2ResizeFeature.hpp +++ b/src/server/LV2ResizeFeature.hpp @@ -34,7 +34,7 @@ struct ResizeFeature : public Ingen::LV2Features::Feature { size_t size) { BlockImpl* block = (BlockImpl*)data; PortImpl* port = block->port_impl(index); - if (block->context() == Context::MESSAGE) { + if (block->context() == Context::ID::MESSAGE) { port->buffer(0)->resize(size); port->connect_buffers(); return LV2_RESIZE_PORT_SUCCESS; diff --git a/src/server/OutputPort.cpp b/src/server/OutputPort.cpp index 4596c68f..94e166bd 100644 --- a/src/server/OutputPort.cpp +++ b/src/server/OutputPort.cpp @@ -38,7 +38,7 @@ OutputPort::OutputPort(BufferFactory& bufs, size_t buffer_size) : PortImpl(bufs, parent, symbol, index, poly, type, buffer_type, value, buffer_size) { - if (parent->graph_type() != Node::GRAPH) { + if (parent->graph_type() != Node::GraphType::GRAPH) { add_property(bufs.uris().rdf_type, bufs.uris().lv2_OutputPort); } diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 61fd7be9..ed7a7084 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -79,7 +79,7 @@ PortImpl::PortImpl(BufferFactory& bufs, if (type == PortType::ATOM) { add_property(uris.atom_bufferType, bufs.forge().make_urid(buffer_type)); - if (block->graph_type() == Ingen::Node::GRAPH) { + if (block->graph_type() == Ingen::Node::GraphType::GRAPH) { add_property(uris.atom_supports, bufs.forge().make_urid(uris.midi_MidiEvent)); add_property(uris.atom_supports, @@ -100,7 +100,7 @@ PortImpl::set_type(PortType port_type, LV2_URID buffer_type) _type = port_type; _buffer_type = buffer_type; if (!_buffer_type) { - switch (_type.symbol()) { + switch (_type.id()) { case PortType::CONTROL: _buffer_type = _bufs.uris().atom_Float; break; @@ -163,10 +163,10 @@ PortImpl::set_voice_value(const Context& context, FrameTime time, Sample value) { - switch (_type.symbol()) { + switch (_type.id()) { case PortType::CONTROL: buffer(voice)->samples()[0] = value; - _set_states->at(voice).state = SetState::SET; + _set_states->at(voice).state = SetState::State::SET; break; case PortType::AUDIO: case PortType::CV: { @@ -183,7 +183,9 @@ PortImpl::set_voice_value(const Context& context, frame of a block (set nframes-1 to 1, then nframes to 0). */ SetState& state = _set_states->at(voice); - state.state = (offset == 0) ? SetState::SET : SetState::HALF_SET_CYCLE_1; + state.state = (offset == 0) + ? SetState::State::SET + : SetState::State::HALF_SET_CYCLE_1; state.time = time; state.value = value; } @@ -197,15 +199,14 @@ PortImpl::update_set_state(Context& context, uint32_t voice) { SetState& state = _set_states->at(voice); switch (state.state) { - case SetState::HALF_SET_CYCLE_1: - state.state = SetState::HALF_SET_CYCLE_2; + case SetState::State::SET: break; - case SetState::HALF_SET_CYCLE_2: { - buffer(voice)->set_block(state.value, 0, context.nframes()); - state.state = SetState::SET; + case SetState::State::HALF_SET_CYCLE_1: + state.state = SetState::State::HALF_SET_CYCLE_2; break; - } - default: + case SetState::State::HALF_SET_CYCLE_2: + buffer(voice)->set_block(state.value, 0, context.nframes()); + state.state = SetState::State::SET; break; } } @@ -316,7 +317,7 @@ PortImpl::recycle_buffers() void PortImpl::clear_buffers() { - switch (_type.symbol()) { + switch (_type.id()) { case PortType::AUDIO: case PortType::CONTROL: case PortType::CV: @@ -324,7 +325,7 @@ PortImpl::clear_buffers() Buffer* buf = buffer(v).get(); buf->set_block(_value.get_float(), 0, buf->nframes()); SetState& state = _set_states->at(v); - state.state = SetState::SET; + state.state = SetState::State::SET; state.value = _value.get_float(); state.time = 0; } @@ -343,7 +344,7 @@ PortImpl::broadcast_value(Context& context, bool force) URIs& uris = context.engine().world()->uris(); LV2_URID key = 0; Raul::Atom val; - switch (_type.symbol()) { + switch (_type.id()) { case PortType::UNKNOWN: break; case PortType::AUDIO: diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index 428a628b..4aed4458 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -45,7 +45,7 @@ class PortImpl : public NodeImpl public: ~PortImpl(); - virtual GraphType graph_type() const { return PORT; } + virtual GraphType graph_type() const { return GraphType::PORT; } /** A port's parent is always a block, so static cast should be safe */ BlockImpl* parent_block() const { return (BlockImpl*)_parent; } @@ -181,9 +181,9 @@ protected: size_t buffer_size); struct SetState { - enum State { SET, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 }; + enum class State { SET, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 }; - SetState() : state(SET), value(0), time(0) {} + SetState() : state(State::SET), value(0), time(0) {} State state; ///< State of buffer for setting control value Sample value; ///< Value currently being set diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp index 883b352f..5445d907 100644 --- a/src/server/PortType.hpp +++ b/src/server/PortType.hpp @@ -34,7 +34,7 @@ namespace Ingen { */ class PortType { public: - enum Symbol { + enum ID { UNKNOWN = 0, AUDIO = 1, CONTROL = 2, @@ -43,40 +43,40 @@ public: }; explicit PortType(const Raul::URI& uri) - : _symbol(UNKNOWN) + : _id(UNKNOWN) { if (uri == type_uri(AUDIO)) { - _symbol = AUDIO; + _id = AUDIO; } else if (uri == type_uri(CONTROL)) { - _symbol = CONTROL; + _id = CONTROL; } else if (uri == type_uri(CV)) { - _symbol = CV; + _id = CV; } else if (uri == type_uri(ATOM)) { - _symbol = ATOM; + _id = ATOM; } } - PortType(Symbol symbol) - : _symbol(symbol) + PortType(ID id) + : _id(id) {} - inline const Raul::URI& uri() const { return type_uri(_symbol); } - inline Symbol symbol() const { return _symbol; } + inline const Raul::URI& uri() const { return type_uri(_id); } + inline ID id() const { return _id; } - inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); } - inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); } - inline bool operator==(const PortType& type) const { return (_symbol == type._symbol); } - inline bool operator!=(const PortType& type) const { return (_symbol != type._symbol); } - inline bool operator<(const PortType& type) const { return (_symbol < type._symbol); } + inline bool operator==(const ID& id) const { return (_id == id); } + inline bool operator!=(const ID& id) const { return (_id != id); } + inline bool operator==(const PortType& type) const { return (_id == type._id); } + inline bool operator!=(const PortType& type) const { return (_id != type._id); } + inline bool operator<(const PortType& type) const { return (_id < type._id); } - inline bool is_audio() { return _symbol == AUDIO; } - inline bool is_control() { return _symbol == CONTROL; } - inline bool is_cv() { return _symbol == CV; } - inline bool is_atom() { return _symbol == ATOM; } + inline bool is_audio() { return _id == AUDIO; } + inline bool is_control() { return _id == CONTROL; } + inline bool is_cv() { return _id == CV; } + inline bool is_atom() { return _id == ATOM; } private: - static inline const Raul::URI& type_uri(unsigned symbol_num) { - assert(symbol_num <= ATOM); + static inline const Raul::URI& type_uri(unsigned id_num) { + assert(id_num <= ATOM); static const Raul::URI uris[] = { Raul::URI("http://drobilla.net/ns/ingen#nil"), Raul::URI(LV2_CORE__AudioPort), @@ -84,10 +84,10 @@ private: Raul::URI(LV2_CORE__CVPort), Raul::URI(LV2_ATOM__AtomPort) }; - return uris[symbol_num]; + return uris[id_num]; } - Symbol _symbol; + ID _id; }; } // namespace Ingen diff --git a/src/server/ProcessContext.hpp b/src/server/ProcessContext.hpp index 75fdcb83..ca98babf 100644 --- a/src/server/ProcessContext.hpp +++ b/src/server/ProcessContext.hpp @@ -33,7 +33,7 @@ class ProcessContext : public Context { public: ProcessContext(Engine& engine) - : Context(engine, AUDIO) + : Context(engine, ID::AUDIO) {} }; diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 0559ec39..16792a11 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -56,34 +56,34 @@ Connect::pre_process() Node* tail = _engine.store()->get(_tail_path); if (!tail) { - return Event::pre_process_done(NOT_FOUND, _tail_path); + return Event::pre_process_done(Status::NOT_FOUND, _tail_path); } Node* head = _engine.store()->get(_head_path); if (!head) { - return Event::pre_process_done(NOT_FOUND, _head_path); + return Event::pre_process_done(Status::NOT_FOUND, _head_path); } OutputPort* tail_output = dynamic_cast(tail); _head = dynamic_cast(head); if (!tail_output || !_head) { - return Event::pre_process_done(BAD_REQUEST, _head_path); + return Event::pre_process_done(Status::BAD_REQUEST, _head_path); } BlockImpl* const tail_block = tail_output->parent_block(); BlockImpl* const head_block = _head->parent_block(); if (!tail_block || !head_block) { - return Event::pre_process_done(PARENT_NOT_FOUND, _head_path); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, _head_path); } if (tail_block->parent() != head_block->parent() && tail_block != head_block->parent() && tail_block->parent() != head_block) { - return Event::pre_process_done(PARENT_DIFFERS, _head_path); + return Event::pre_process_done(Status::PARENT_DIFFERS, _head_path); } if (!ArcImpl::can_connect(tail_output, _head)) { - return Event::pre_process_done(TYPE_MISMATCH, _head_path); + return Event::pre_process_done(Status::TYPE_MISMATCH, _head_path); } if (tail_block->parent_graph() != head_block->parent_graph()) { @@ -103,7 +103,7 @@ Connect::pre_process() } if (_graph->has_arc(tail_output, _head)) { - return Event::pre_process_done(EXISTS, _head_path); + return Event::pre_process_done(Status::EXISTS, _head_path); } _arc = SharedPtr(new ArcImpl(tail_output, _head)); @@ -136,13 +136,13 @@ Connect::pre_process() _compiled_graph = _graph->compile(); } - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void Connect::execute(ProcessContext& context) { - if (!_status) { + if (_status != Status::SUCCESS) { _head->add_arc(context, _arc.get()); _engine.maid()->dispose(_head->set_buffers(context, _buffers)); _head->connect_buffers(); @@ -154,7 +154,7 @@ void Connect::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->connect(_tail_path, _head_path); } } diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index b75dbf1e..65e24bfd 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -59,7 +59,7 @@ CreateBlock::pre_process() typedef Resource::Properties::const_iterator iterator; if (_path.is_root()) { - return Event::pre_process_done(BAD_URI, _path); + return Event::pre_process_done(Status::BAD_URI, _path); } std::string plugin_uri_str; @@ -67,22 +67,23 @@ CreateBlock::pre_process() if (t != _properties.end() && t->second.type() == uris.forge.URI) { plugin_uri_str = t->second.get_uri(); } else { - return Event::pre_process_done(BAD_REQUEST); + return Event::pre_process_done(Status::BAD_REQUEST); } if (_engine.store()->get(_path)) { - return Event::pre_process_done(EXISTS, _path); + return Event::pre_process_done(Status::EXISTS, _path); } _graph = dynamic_cast(_engine.store()->get(_path.parent())); if (!_graph) { - return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent()); } const Raul::URI plugin_uri(plugin_uri_str); PluginImpl* plugin = _engine.block_factory()->plugin(plugin_uri); if (!plugin) { - return Event::pre_process_done(PLUGIN_NOT_FOUND, Raul::URI(plugin_uri)); + return Event::pre_process_done(Status::PLUGIN_NOT_FOUND, + Raul::URI(plugin_uri)); } const iterator p = _properties.find(uris.ingen_polyphonic); @@ -96,7 +97,7 @@ CreateBlock::pre_process() polyphonic, _graph, _engine))) { - return Event::pre_process_done(CREATION_FAILED, _path); + return Event::pre_process_done(Status::CREATION_FAILED, _path); } _block->properties().insert(_properties.begin(), _properties.end()); @@ -122,7 +123,7 @@ CreateBlock::pre_process() _update.push_back(std::make_pair(port->uri(), pprops)); } - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -138,7 +139,7 @@ void CreateBlock::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { for (Update::const_iterator i = _update.begin(); i != _update.end(); ++i) { _engine.broadcaster()->put(i->first, i->second); } diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index 23c6ef14..f2131246 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -48,12 +48,12 @@ bool CreateGraph::pre_process() { if (_path.is_root() || _engine.store()->get(_path)) { - return Event::pre_process_done(EXISTS, _path); + return Event::pre_process_done(Status::EXISTS, _path); } _parent = dynamic_cast(_engine.store()->get(_path.parent())); if (!_parent) { - return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent()); } const Ingen::URIs& uris = _engine.world()->uris(); @@ -68,7 +68,7 @@ CreateGraph::pre_process() } if (int_poly < 1 || int_poly > 128) { - return Event::pre_process_done(INVALID_POLY, _path); + return Event::pre_process_done(Status::INVALID_POLY, _path); } if (int_poly == _parent->internal_poly()) { @@ -81,7 +81,8 @@ CreateGraph::pre_process() _graph->properties().insert(_properties.begin(), _properties.end()); _graph->add_property(uris.rdf_type, uris.ingen_Graph); _graph->add_property(uris.rdf_type, - Resource::Property(uris.ingen_Block, Resource::EXTERNAL)); + Resource::Property(uris.ingen_Block, + Resource::Graph::EXTERNAL)); _parent->add_block(*_graph); if (_parent->enabled()) { @@ -96,7 +97,7 @@ CreateGraph::pre_process() _update = _graph->properties(); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -111,7 +112,7 @@ void CreateGraph::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->put(Node::path_to_uri(_path), _update); } } diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 03cc2bd8..818b0438 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -86,11 +86,11 @@ bool CreatePort::pre_process() { if (_port_type == PortType::UNKNOWN) { - return Event::pre_process_done(UNKNOWN_TYPE, _path); + return Event::pre_process_done(Status::UNKNOWN_TYPE, _path); } if (_path.is_root()) { - return Event::pre_process_done(BAD_URI, _path); + return Event::pre_process_done(Status::BAD_URI, _path); } if (_engine.store()->get(_path)) { @@ -99,11 +99,13 @@ CreatePort::pre_process() Node* parent = _engine.store()->get(_path.parent()); if (!parent) { - return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, + _path.parent()); } if (!(_graph = dynamic_cast(parent))) { - return Event::pre_process_done(INVALID_PARENT_PATH, _path.parent()); + return Event::pre_process_done(Status::INVALID_PARENT_PATH, + _path.parent()); } const URIs& uris = _engine.world()->uris(); @@ -122,7 +124,7 @@ CreatePort::pre_process() _engine.world()->forge().make(old_n_ports))); } else if (index_i->second.type() != uris.forge.Int || index_i->second.get_int32() != old_n_ports) { - return Event::pre_process_done(BAD_INDEX, _path); + return Event::pre_process_done(Status::BAD_INDEX, _path); } const PropIter poly_i = _properties.find(uris.ingen_polyphonic); @@ -133,7 +135,7 @@ CreatePort::pre_process() if (!(_graph_port = _graph->create_port( *_engine.buffer_factory(), Raul::Symbol(_path.symbol()), _port_type, _buf_type, buf_size, _is_output, polyphonic))) { - return Event::pre_process_done(CREATION_FAILED, _path); + return Event::pre_process_done(Status::CREATION_FAILED, _path); } _graph_port->properties().insert(_properties.begin(), _properties.end()); @@ -158,13 +160,13 @@ CreatePort::pre_process() assert(_graph_port->index() == (uint32_t)old_n_ports); assert(_ports_array->size() == _graph->num_ports_non_rt()); assert(_graph_port->index() < _ports_array->size()); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void CreatePort::execute(ProcessContext& context) { - if (!_status) { + if (_status == Status::SUCCESS) { _old_ports_array = _graph->external_ports(); if (_old_ports_array) { for (uint32_t i = 0; i < _old_ports_array->size(); ++i) { @@ -185,7 +187,7 @@ void CreatePort::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->put(Node::path_to_uri(_path), _update); } diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index 77dd9003..bcfb209a 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -61,7 +61,7 @@ bool Delete::pre_process() { if (_path.is_root() || _path == "/control_in" || _path == "/control_out") { - return Event::pre_process_done(NOT_DELETABLE, _path); + return Event::pre_process_done(Status::NOT_DELETABLE, _path); } _lock.acquire(); @@ -70,7 +70,7 @@ Delete::pre_process() Store::iterator iter = _engine.store()->find(_path); if (iter == _engine.store()->end()) { - return Event::pre_process_done(NOT_FOUND, _path); + return Event::pre_process_done(Status::NOT_FOUND, _path); } if (!(_block = PtrCast(iter->second))) { @@ -78,12 +78,12 @@ Delete::pre_process() } if (!_block && !_port) { - return Event::pre_process_done(NOT_DELETABLE, _path); + return Event::pre_process_done(Status::NOT_DELETABLE, _path); } GraphImpl* parent = _block ? _block->parent_graph() : _port->parent_graph(); if (!parent) { - return Event::pre_process_done(INTERNAL_ERROR, _path); + return Event::pre_process_done(Status::INTERNAL_ERROR, _path); } _engine.store()->remove(iter, _removed_objects); @@ -112,7 +112,7 @@ Delete::pre_process() } } - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -145,7 +145,7 @@ Delete::post_process() _removed_bindings.reset(); Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond() && (_block || _port)) { + if (respond() == Status::SUCCESS && (_block || _port)) { if (_block) { _block->deactivate(); } diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index c7a2fb10..0f854096 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -64,7 +64,7 @@ Delta::Delta(Engine& engine, , _context(context) , _create(create) { - if (context != Resource::DEFAULT) { + if (context != Resource::Graph::DEFAULT) { for (Properties::iterator i = _properties.begin(); i != _properties.end(); ++i) { @@ -115,7 +115,7 @@ Delta::pre_process() : static_cast(_engine.block_factory()->plugin(_subject)); if (!_object && (!is_graph_object || !_create)) { - return Event::pre_process_done(NOT_FOUND, _subject); + return Event::pre_process_done(Status::NOT_FOUND, _subject); } const Ingen::URIs& uris = _engine.world()->uris(); @@ -141,7 +141,7 @@ Delta::pre_process() // Grab the object for applying properties, if the create-event succeeded _object = _engine.store()->get(path); } else { - return Event::pre_process_done(BAD_OBJECT_TYPE, _subject); + return Event::pre_process_done(Status::BAD_OBJECT_TYPE, _subject); } } @@ -163,7 +163,7 @@ Delta::pre_process() for (Properties::const_iterator p = _properties.begin(); p != _properties.end(); ++p) { const Raul::URI& key = p->first; const Resource::Property& value = p->second; - SpecialType op = NONE; + SpecialType op = SpecialType::NONE; if (obj) { Resource& resource = *obj; if (value != uris.wildcard) { @@ -175,9 +175,9 @@ Delta::pre_process() if (port) { if (key == uris.ingen_broadcast) { if (value.type() == uris.forge.Bool) { - op = ENABLE_BROADCAST; + op = SpecialType::ENABLE_BROADCAST; } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } else if (key == uris.ingen_value) { SetPortValue* ev = new SetPortValue( @@ -189,46 +189,46 @@ Delta::pre_process() if (value == uris.wildcard) { _engine.control_bindings()->learn(port); } else if (value.type() == uris.atom_Blank) { - op = CONTROL_BINDING; + op = SpecialType::CONTROL_BINDING; } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } else { - _status = BAD_OBJECT_TYPE; + _status = Status::BAD_OBJECT_TYPE; } } } else if ((block = dynamic_cast(_object))) { if (key == uris.ingen_controlBinding && value == uris.wildcard) { - op = CONTROL_BINDING; // Internal block learn + op = SpecialType::CONTROL_BINDING; // Internal block learn } } else if ((_graph = dynamic_cast(_object))) { if (key == uris.ingen_enabled) { if (value.type() == uris.forge.Bool) { - op = ENABLE; + op = SpecialType::ENABLE; // FIXME: defer this until all other metadata has been processed if (value.get_bool() && !_graph->enabled()) _compiled_graph = _graph->compile(); } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } else if (key == uris.ingen_polyphony) { if (value.type() == uris.forge.Int) { if (value.get_int32() < 1 || value.get_int32() > 128) { - _status = INVALID_POLY; + _status = Status::INVALID_POLY; } else { - op = POLYPHONY; + op = SpecialType::POLYPHONY; _graph->prepare_internal_poly( *_engine.buffer_factory(), value.get_int32()); } } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } } else if (key == uris.ingen_polyphonic) { GraphImpl* parent = dynamic_cast(obj->parent()); if (parent) { if (value.type() == uris.forge.Bool) { - op = POLYPHONIC; + op = SpecialType::POLYPHONIC; obj->set_property(key, value, value.context()); BlockImpl* block = dynamic_cast(obj); if (block) @@ -239,29 +239,30 @@ Delta::pre_process() obj->prepare_poly(*_engine.buffer_factory(), 1); } } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } else { - _status = BAD_OBJECT_TYPE; + _status = Status::BAD_OBJECT_TYPE; } } } - if (_status != NOT_PREPARED) { + if (_status != Status::NOT_PREPARED) { break; } _types.push_back(op); } - return Event::pre_process_done(_status == NOT_PREPARED ? SUCCESS : _status, - _subject); + return Event::pre_process_done( + _status == Status::NOT_PREPARED ? Status::SUCCESS : _status, + _subject); } void Delta::execute(ProcessContext& context) { - if (_status) { + if (_status != Status::SUCCESS) { return; } @@ -286,12 +287,12 @@ Delta::execute(ProcessContext& context) const Raul::URI& key = p->first; const Raul::Atom& value = p->second; switch (*t) { - case ENABLE_BROADCAST: + case SpecialType::ENABLE_BROADCAST: if (port) { port->broadcast(value.get_bool()); } break; - case ENABLE: + case SpecialType::ENABLE: if (value.get_bool()) { if (_compiled_graph) { _graph->set_compiled_graph(_compiled_graph); @@ -301,7 +302,7 @@ Delta::execute(ProcessContext& context) _graph->disable(context); } break; - case POLYPHONIC: { + case SpecialType::POLYPHONIC: { GraphImpl* parent = reinterpret_cast(object->parent()); if (value.get_bool()) { object->apply_poly( @@ -310,15 +311,15 @@ Delta::execute(ProcessContext& context) object->apply_poly(context, *_engine.maid(), 1); } } break; - case POLYPHONY: + case SpecialType::POLYPHONY: if (!_graph->apply_internal_poly(context, *_engine.buffer_factory(), *_engine.maid(), value.get_int32())) { - _status = INTERNAL_ERROR; + _status = Status::INTERNAL_ERROR; } break; - case CONTROL_BINDING: + case SpecialType::CONTROL_BINDING: if (port) { _engine.control_bindings()->port_binding_changed(context, port, value); } else if (block) { @@ -327,7 +328,7 @@ Delta::execute(ProcessContext& context) } } break; - case NONE: + case SpecialType::NONE: if (port) { if (key == uris.lv2_minimum) { port->set_minimum(value); @@ -348,7 +349,7 @@ Delta::post_process() for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i) (*i)->post_process(); - if (!_status) { + if (_status == Status::SUCCESS) { if (_create_event) { _create_event->post_process(); } else { diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp index c3a28fbb..34319591 100644 --- a/src/server/events/Delta.hpp +++ b/src/server/events/Delta.hpp @@ -86,7 +86,7 @@ public: void post_process(); private: - enum SpecialType { + enum class SpecialType { NONE, ENABLE, ENABLE_BROADCAST, diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 829500f5..4a961d9e 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -117,17 +117,17 @@ Disconnect::pre_process() if (_tail_path.parent().parent() != _head_path.parent().parent() && _tail_path.parent() != _head_path.parent().parent() && _tail_path.parent().parent() != _head_path.parent()) { - return Event::pre_process_done(PARENT_DIFFERS, _head_path); + return Event::pre_process_done(Status::PARENT_DIFFERS, _head_path); } PortImpl* tail = dynamic_cast(_engine.store()->get(_tail_path)); if (!tail) { - return Event::pre_process_done(PORT_NOT_FOUND, _tail_path); + return Event::pre_process_done(Status::PORT_NOT_FOUND, _tail_path); } PortImpl* head = dynamic_cast(_engine.store()->get(_head_path)); if (!head) { - return Event::pre_process_done(PORT_NOT_FOUND, _head_path); + return Event::pre_process_done(Status::PORT_NOT_FOUND, _head_path); } BlockImpl* const src_block = tail->parent_block(); @@ -150,13 +150,13 @@ Disconnect::pre_process() } if (!_graph) { - return Event::pre_process_done(INTERNAL_ERROR, _head_path); + return Event::pre_process_done(Status::INTERNAL_ERROR, _head_path); } else if (!_graph->has_arc(tail, head)) { - return Event::pre_process_done(NOT_FOUND, _head_path); + return Event::pre_process_done(Status::NOT_FOUND, _head_path); } if (src_block == NULL || dst_block == NULL) { - return Event::pre_process_done(PARENT_NOT_FOUND, _head_path); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, _head_path); } _impl = new Impl(_engine, @@ -167,7 +167,7 @@ Disconnect::pre_process() if (_graph->enabled()) _compiled_graph = _graph->compile(); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } bool @@ -198,9 +198,9 @@ Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers) void Disconnect::execute(ProcessContext& context) { - if (_status == SUCCESS) { + if (_status == Status::SUCCESS) { if (!_impl->execute(context, true)) { - _status = NOT_FOUND; + _status = Status::NOT_FOUND; return; } @@ -212,7 +212,7 @@ void Disconnect::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->disconnect(_tail_path, _head_path); } diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index c2475b45..a6022410 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -89,18 +89,20 @@ DisconnectAll::pre_process() _parent = dynamic_cast(_engine.store()->get(_parent_path)); if (!_parent) { - return Event::pre_process_done(PARENT_NOT_FOUND, _parent_path); + return Event::pre_process_done(Status::PARENT_NOT_FOUND, + _parent_path); } NodeImpl* const object = dynamic_cast( _engine.store()->get(_path)); if (!object) { - return Event::pre_process_done(NOT_FOUND, _path); + return Event::pre_process_done(Status::NOT_FOUND, _path); } if (object->parent_graph() != _parent && object->parent()->parent_graph() != _parent) { - return Event::pre_process_done(INVALID_PARENT_PATH, _parent_path); + return Event::pre_process_done(Status::INVALID_PARENT_PATH, + _parent_path); } // Only one of these will succeed @@ -108,7 +110,7 @@ DisconnectAll::pre_process() _port = dynamic_cast(object); if (!_block && !_port) { - return Event::pre_process_done(INTERNAL_ERROR, _path); + return Event::pre_process_done(Status::INTERNAL_ERROR, _path); } } @@ -141,13 +143,13 @@ DisconnectAll::pre_process() if (!_deleting && _parent->enabled()) _compiled_graph = _parent->compile(); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void DisconnectAll::execute(ProcessContext& context) { - if (_status == SUCCESS) { + if (_status == Status::SUCCESS) { for (Impls::iterator i = _impls.begin(); i != _impls.end(); ++i) { (*i)->execute(context, !_deleting || ((*i)->head()->parent_block() != _block)); @@ -161,7 +163,7 @@ void DisconnectAll::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->disconnect_all(_parent_path, _path); } } diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 93af8bf2..67b68de9 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -57,15 +57,17 @@ Get::pre_process() if (_uri == "ingen:/plugins") { _plugins = _engine.block_factory()->plugins(); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } else if (_uri == "ingen:/engine") { - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } else if (Node::uri_is_path(_uri)) { _object = _engine.store()->get(Node::uri_to_path(_uri)); - return Event::pre_process_done(_object ? SUCCESS : NOT_FOUND, _uri); + return Event::pre_process_done( + _object ? Status::SUCCESS : Status::NOT_FOUND, _uri); } else { _plugin = _engine.block_factory()->plugin(_uri); - return Event::pre_process_done(_plugin ? SUCCESS : NOT_FOUND, _uri); + return Event::pre_process_done( + _plugin ? Status::SUCCESS : Status::NOT_FOUND, _uri); } } @@ -101,12 +103,12 @@ static void send_graph(Interface* client, const GraphImpl* graph) { client->put(graph->uri(), - graph->properties(Resource::INTERNAL), - Resource::INTERNAL); + graph->properties(Resource::Graph::INTERNAL), + Resource::Graph::INTERNAL); client->put(graph->uri(), - graph->properties(Resource::EXTERNAL), - Resource::EXTERNAL); + graph->properties(Resource::Graph::EXTERNAL), + Resource::Graph::EXTERNAL); // Send blocks for (GraphImpl::Blocks::const_iterator j = graph->blocks().begin(); @@ -130,7 +132,7 @@ void Get::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond() && _request_client) { + if (respond() == Status::SUCCESS && _request_client) { if (_uri == "ingen:/plugins") { _engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins); } else if (_uri == "ingen:/engine") { diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index 08eea56a..700d5814 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -53,16 +53,16 @@ Move::pre_process() Glib::RWLock::WriterLock lock(_engine.store()->lock()); if (!_old_path.parent().is_parent_of(_new_path)) { - return Event::pre_process_done(PARENT_DIFFERS, _new_path); + return Event::pre_process_done(Status::PARENT_DIFFERS, _new_path); } const Store::iterator i = _engine.store()->find(_old_path); if (i == _engine.store()->end()) { - return Event::pre_process_done(NOT_FOUND, _old_path); + return Event::pre_process_done(Status::NOT_FOUND, _old_path); } if (_engine.store()->find(_new_path) != _engine.store()->end()) { - return Event::pre_process_done(EXISTS, _new_path); + return Event::pre_process_done(Status::EXISTS, _new_path); } EnginePort* eport = _engine.driver()->get_port(_old_path); @@ -72,7 +72,7 @@ Move::pre_process() _engine.store()->rename(i, _new_path); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -84,7 +84,7 @@ void Move::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->move(_old_path, _new_path); } } diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index b3481861..f2399d8e 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -54,7 +54,7 @@ bool SetPortValue::pre_process() { if (_port->is_output()) { - return Event::pre_process_done(DIRECTION_MISMATCH, _port->path()); + return Event::pre_process_done(Status::DIRECTION_MISMATCH, _port->path()); } // Set value metadata (does not affect buffers) @@ -63,7 +63,7 @@ SetPortValue::pre_process() _binding = _engine.control_bindings()->port_binding(_port); - return Event::pre_process_done(SUCCESS); + return Event::pre_process_done(Status::SUCCESS); } void @@ -71,7 +71,7 @@ SetPortValue::execute(ProcessContext& context) { assert(_time >= context.start() && _time <= context.end()); - if (_port->parent_block()->context() == Context::MESSAGE) + if (_port->parent_block()->context() == Context::ID::MESSAGE) return; apply(context); @@ -81,7 +81,7 @@ SetPortValue::execute(ProcessContext& context) void SetPortValue::apply(Context& context) { - if (_status) { + if (_status != Status::SUCCESS) { return; } @@ -92,7 +92,7 @@ SetPortValue::apply(Context& context) if (_value.type() == uris.forge.Float) { _port->set_control_value(context, _time, _value.get_float()); } else { - _status = TYPE_MISMATCH; + _status = Status::TYPE_MISMATCH; } } else if (buf->type() == uris.atom_Sequence) { buf->prepare_write(context); // FIXME: incorrect @@ -102,12 +102,12 @@ SetPortValue::apply(Context& context) (const uint8_t*)_value.get_body())) { _port->raise_set_by_user_flag(); } else { - _status = NO_SPACE; + _status = Status::NO_SPACE; } } else if (buf->type() == uris.atom_URID) { ((LV2_Atom_URID*)buf->atom())->body = _value.get_int32(); } else { - _status = BAD_VALUE_TYPE; + _status = Status::BAD_VALUE_TYPE; } } @@ -115,7 +115,7 @@ void SetPortValue::post_process() { Broadcaster::Transfer t(*_engine.broadcaster()); - if (!respond()) { + if (respond() == Status::SUCCESS) { _engine.broadcaster()->set_property( _port->uri(), _engine.world()->uris().ingen_value, diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index 19d2126b..37cebd7e 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -201,13 +201,13 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F Voice* voice = NULL; uint32_t voice_num = 0; - if (key->state != Key::OFF) { + if (key->state != Key::State::OFF) { return; } // Look for free voices for (uint32_t i=0; i < _polyphony; ++i) { - if ((*_voices)[i].state == Voice::Voice::FREE) { + if ((*_voices)[i].state == Voice::State::FREE) { voice = &(*_voices)[i]; voice_num = i; break; @@ -231,23 +231,23 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F assert(voice == &(*_voices)[voice_num]); // Update stolen key, if applicable - if (voice->state == Voice::Voice::ACTIVE) { - assert(_keys[voice->note].state == Key::ON_ASSIGNED); + if (voice->state == Voice::State::ACTIVE) { + assert(_keys[voice->note].state == Key::State::ON_ASSIGNED); assert(_keys[voice->note].voice == voice_num); - _keys[voice->note].state = Key::Key::ON_UNASSIGNED; + _keys[voice->note].state = Key::State::ON_UNASSIGNED; } // Store key information for later reallocation on note off - key->state = Key::Key::ON_ASSIGNED; + key->state = Key::State::ON_ASSIGNED; key->voice = voice_num; key->time = time; // Trigger voice - voice->state = Voice::Voice::ACTIVE; + voice->state = Voice::State::ACTIVE; voice->note = note_num; voice->time = time; - assert(_keys[voice->note].state == Key::Key::ON_ASSIGNED); + assert(_keys[voice->note].state == Key::State::ON_ASSIGNED); assert(_keys[voice->note].voice == voice_num); _freq_port->set_voice_value(context, voice_num, time, note_to_freq(note_num)); @@ -257,8 +257,8 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F _trig_port->set_voice_value(context, voice_num, time, 1.0f); _trig_port->set_voice_value(context, voice_num, time + 1, 0.0f); - assert(key->state == Key::Key::ON_ASSIGNED); - assert(voice->state == Voice::Voice::ACTIVE); + assert(key->state == Key::State::ON_ASSIGNED); + assert(voice->state == Voice::State::ACTIVE); assert(key->voice == voice_num); assert((*_voices)[key->voice].note == note_num); } @@ -270,19 +270,19 @@ NoteNode::note_off(ProcessContext& context, uint8_t note_num, FrameTime time) Key* key = &_keys[note_num]; - if (key->state == Key::ON_ASSIGNED) { + if (key->state == Key::State::ON_ASSIGNED) { // Assigned key, turn off voice and key - if ((*_voices)[key->voice].state == Voice::ACTIVE) { + if ((*_voices)[key->voice].state == Voice::State::ACTIVE) { assert((*_voices)[key->voice].note == note_num); if ( ! _sustain) { free_voice(context, key->voice, time); } else { - (*_voices)[key->voice].state = Voice::HOLDING; + (*_voices)[key->voice].state = Voice::State::HOLDING; } } } - key->state = Key::OFF; + key->state = Key::State::OFF; } void @@ -295,7 +295,7 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time) uint8_t replace_key_num = 0; for (uint8_t i = 0; i <= 127; ++i) { - if (_keys[i].state == Key::ON_UNASSIGNED) { + if (_keys[i].state == Key::State::ON_UNASSIGNED) { if (replace_key == NULL || _keys[i].time > replace_key->time) { replace_key = &_keys[i]; replace_key_num = i; @@ -305,21 +305,21 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time) if (replace_key != NULL) { // Found a key to assign to freed voice assert(&_keys[replace_key_num] == replace_key); - assert(replace_key->state == Key::ON_UNASSIGNED); + assert(replace_key->state == Key::State::ON_UNASSIGNED); // Change the freq but leave the gate high and don't retrigger _freq_port->set_voice_value(context, voice, time, note_to_freq(replace_key_num)); _num_port->set_voice_value(context, voice, time, replace_key_num); - replace_key->state = Key::ON_ASSIGNED; + replace_key->state = Key::State::ON_ASSIGNED; replace_key->voice = voice; - _keys[(*_voices)[voice].note].state = Key::ON_UNASSIGNED; + _keys[(*_voices)[voice].note].state = Key::State::ON_UNASSIGNED; (*_voices)[voice].note = replace_key_num; - (*_voices)[voice].state = Voice::ACTIVE; + (*_voices)[voice].state = Voice::State::ACTIVE; } else { // No new note for voice, deactivate (set gate low) _gate_port->set_voice_value(context, voice, time, 0.0f); - (*_voices)[voice].state = Voice::FREE; + (*_voices)[voice].state = Voice::State::FREE; } } @@ -332,7 +332,7 @@ NoteNode::all_notes_off(ProcessContext& context, FrameTime time) for (uint32_t i = 0; i < _polyphony; ++i) { _gate_port->set_voice_value(context, i, time, 0.0f); - (*_voices)[i].state = Voice::FREE; + (*_voices)[i].state = Voice::State::FREE; } } @@ -350,7 +350,7 @@ NoteNode::sustain_off(ProcessContext& context, FrameTime time) _sustain = false; for (uint32_t i=0; i < _polyphony; ++i) - if ((*_voices)[i].state == Voice::HOLDING) + if ((*_voices)[i].state == Voice::State::HOLDING) free_voice(context, i, time); } diff --git a/src/server/internals/Note.hpp b/src/server/internals/Note.hpp index e8964c31..027912b6 100644 --- a/src/server/internals/Note.hpp +++ b/src/server/internals/Note.hpp @@ -64,8 +64,8 @@ public: private: /** Key, one for each key on the keyboard */ struct Key { - enum State { OFF, ON_ASSIGNED, ON_UNASSIGNED }; - Key() : state(OFF), voice(0), time(0) {} + enum class State { OFF, ON_ASSIGNED, ON_UNASSIGNED }; + Key() : state(State::OFF), voice(0), time(0) {} State state; uint32_t voice; SampleCount time; @@ -73,8 +73,8 @@ private: /** Voice, one of these always exists for each voice */ struct Voice { - enum State { FREE, ACTIVE, HOLDING }; - Voice() : state(FREE), note(0), time(0) {} + enum class State { FREE, ACTIVE, HOLDING }; + Voice() : state(State::FREE), note(0), time(0) {} State state; uint8_t note; SampleCount time; diff --git a/src/socket/Socket.cpp b/src/socket/Socket.cpp index 4f3592cd..2de88226 100644 --- a/src/socket/Socket.cpp +++ b/src/socket/Socket.cpp @@ -38,16 +38,16 @@ namespace Socket { Socket::Socket(Type t) : _type(t) - , _uri(t == UNIX ? "unix:" : "tcp:") + , _uri(t == Type::UNIX ? "unix:" : "tcp:") , _addr(NULL) , _addr_len(0) , _sock(-1) { switch (t) { - case UNIX: + case Type::UNIX: _sock = socket(AF_UNIX, SOCK_STREAM, 0); break; - case TCP: + case Type::TCP: _sock = socket(AF_INET, SOCK_STREAM, 0); break; } @@ -76,7 +76,7 @@ bool Socket::set_addr(const Raul::URI& uri) { free(_addr); - if (_type == UNIX && uri.substr(0, strlen("unix://")) == "unix://") { + if (_type == Type::UNIX && uri.substr(0, strlen("unix://")) == "unix://") { const std::string path = uri.substr(strlen("unix://")); struct sockaddr_un* uaddr = (struct sockaddr_un*)calloc( 1, sizeof(struct sockaddr_un)); @@ -86,7 +86,7 @@ Socket::set_addr(const Raul::URI& uri) _addr = (sockaddr*)uaddr; _addr_len = sizeof(struct sockaddr_un); return true; - } else if (_type == TCP && uri.find("://") != std::string::npos) { + } else if (_type == Type::TCP && uri.find("://") != std::string::npos) { const std::string authority = uri.substr(uri.find("://") + 3); const size_t port_sep = authority.find(':'); if (port_sep == std::string::npos) { diff --git a/src/socket/Socket.hpp b/src/socket/Socket.hpp index 1406d87e..ed2ddb74 100644 --- a/src/socket/Socket.hpp +++ b/src/socket/Socket.hpp @@ -30,13 +30,13 @@ namespace Socket { /** A safe and simple interface for UNIX or TCP sockets. */ class Socket : public Raul::Noncopyable { public: - enum Type { + enum class Type { UNIX, TCP }; static Type type_from_uri(const Raul::URI uri) { - return (uri.scheme() == "unix") ? UNIX : TCP; + return (uri.scheme() == "unix") ? Type::UNIX : Type::TCP; } /** Create a new unbound/unconnected socket of a given type. */ diff --git a/src/socket/SocketListener.cpp b/src/socket/SocketListener.cpp index 13049a24..0628b7a5 100644 --- a/src/socket/SocketListener.cpp +++ b/src/socket/SocketListener.cpp @@ -38,8 +38,8 @@ namespace Socket { SocketListener::SocketListener(Ingen::World& world) : Raul::Thread() , _world(world) - , _unix_sock(Socket::UNIX) - , _net_sock(Socket::TCP) + , _unix_sock(Socket::Type::UNIX) + , _net_sock(Socket::Type::TCP) { // Create UNIX socket _unix_path = world.conf().option("socket").get_string(); -- cgit v1.2.1