diff options
author | David Robillard <d@drobilla.net> | 2020-11-28 16:45:38 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-28 17:39:10 +0100 |
commit | e2982b5f760a862e091992dc0424b2f78c6b724b (patch) | |
tree | a18732fb244aab23317d311622f80902ae38a2da /src | |
parent | 8889e2c2d03a414c9e917a598ebfb213c5a28503 (diff) | |
download | patchage-e2982b5f760a862e091992dc0424b2f78c6b724b.tar.gz patchage-e2982b5f760a862e091992dc0424b2f78c6b724b.tar.bz2 patchage-e2982b5f760a862e091992dc0424b2f78c6b724b.zip |
Rename ModuleType to SignalDirection
Diffstat (limited to 'src')
-rw-r--r-- | src/AlsaDriver.cpp | 17 | ||||
-rw-r--r-- | src/AlsaDriver.hpp | 4 | ||||
-rw-r--r-- | src/Configuration.cpp | 28 | ||||
-rw-r--r-- | src/Configuration.hpp | 14 | ||||
-rw-r--r-- | src/JackDbusDriver.cpp | 8 | ||||
-rw-r--r-- | src/JackDbusDriver.hpp | 2 | ||||
-rw-r--r-- | src/JackDriver.cpp | 25 | ||||
-rw-r--r-- | src/PatchageCanvas.cpp | 12 | ||||
-rw-r--r-- | src/PatchageCanvas.hpp | 2 | ||||
-rw-r--r-- | src/PatchageModule.cpp | 10 | ||||
-rw-r--r-- | src/PatchageModule.hpp | 14 |
11 files changed, 70 insertions, 66 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index ec5b24d..aa2357e 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -200,7 +200,7 @@ AlsaDriver::create_port_view(Patchage*, const PortID& id) } PatchageModule* -AlsaDriver::find_module(uint8_t client_id, ModuleType type) +AlsaDriver::find_module(uint8_t client_id, SignalDirection type) { const Modules::const_iterator i = _modules.find(client_id); if (i == _modules.end()) { @@ -215,7 +215,7 @@ AlsaDriver::find_module(uint8_t client_id, ModuleType type) return j->second; } - if (j->second->type() == ModuleType::input_output) { + if (j->second->type() == SignalDirection::duplex) { io_module = j->second; } } @@ -228,7 +228,7 @@ PatchageModule* AlsaDriver::find_or_create_module(Patchage* patchage, uint8_t client_id, const std::string& client_name, - ModuleType type) + SignalDirection type) { PatchageModule* m = find_module(client_id, type); if (!m) { @@ -297,7 +297,7 @@ AlsaDriver::create_port_view_internal(snd_seq_addr_t addr, if (!split) { parent = find_or_create_module( - _app, addr.client, client_name, ModuleType::input_output); + _app, addr.client, client_name, SignalDirection::duplex); if (!parent->get_port(port_id)) { port = create_port(*parent, port_name, is_input, addr); port->show(); @@ -305,8 +305,8 @@ AlsaDriver::create_port_view_internal(snd_seq_addr_t addr, } else { // split { - const ModuleType module_type = - ((is_input) ? ModuleType::input : ModuleType::output); + const SignalDirection module_type = + ((is_input) ? SignalDirection::input : SignalDirection::output); parent = find_or_create_module( _app, addr.client, client_name, module_type); @@ -317,8 +317,9 @@ AlsaDriver::create_port_view_internal(snd_seq_addr_t addr, } if (is_duplex) { - const ModuleType flipped_module_type = - ((!is_input) ? ModuleType::input : ModuleType::output); + const SignalDirection flipped_module_type = + ((!is_input) ? SignalDirection::input + : SignalDirection::output); parent = find_or_create_module( _app, addr.client, client_name, flipped_module_type); if (!parent->get_port(port_id)) { diff --git a/src/AlsaDriver.hpp b/src/AlsaDriver.hpp index 33d8542..caaaf39 100644 --- a/src/AlsaDriver.hpp +++ b/src/AlsaDriver.hpp @@ -70,12 +70,12 @@ private: static void* refresh_main(void* me); void _refresh_main(); - PatchageModule* find_module(uint8_t client_id, ModuleType type); + PatchageModule* find_module(uint8_t client_id, SignalDirection type); PatchageModule* find_or_create_module(Patchage* patchage, uint8_t client_id, const std::string& client_name, - ModuleType type); + SignalDirection type); void create_port_view_internal(snd_seq_addr_t addr, PatchageModule*& parent, diff --git a/src/Configuration.cpp b/src/Configuration.cpp index f7bfc46..dc89120 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -79,7 +79,7 @@ Configuration::Configuration() bool Configuration::get_module_location(const std::string& name, - ModuleType type, + SignalDirection type, Coord& loc) { std::map<std::string, ModuleSettings>::const_iterator i = @@ -89,11 +89,11 @@ Configuration::get_module_location(const std::string& name, } const ModuleSettings& settings = (*i).second; - if (type == ModuleType::input && settings.input_location) { + if (type == SignalDirection::input && settings.input_location) { loc = *settings.input_location; - } else if (type == ModuleType::output && settings.output_location) { + } else if (type == SignalDirection::output && settings.output_location) { loc = *settings.output_location; - } else if (type == ModuleType::input_output && settings.inout_location) { + } else if (type == SignalDirection::duplex && settings.inout_location) { loc = *settings.inout_location; } else { return false; @@ -104,26 +104,26 @@ Configuration::get_module_location(const std::string& name, void Configuration::set_module_location(const std::string& name, - ModuleType type, + SignalDirection type, Coord loc) { auto i = _module_settings.find(name); if (i == _module_settings.end()) { i = _module_settings .insert(std::make_pair( - name, ModuleSettings(type != ModuleType::input_output))) + name, ModuleSettings(type != SignalDirection::duplex))) .first; } ModuleSettings& settings = (*i).second; switch (type) { - case ModuleType::input: + case SignalDirection::input: settings.input_location = loc; break; - case ModuleType::output: + case SignalDirection::output: settings.output_location = loc; break; - case ModuleType::input_output: + case SignalDirection::duplex: settings.inout_location = loc; break; } @@ -254,15 +254,15 @@ Configuration::load() file.ignore(1, '\"'); std::getline(file, name, '\"'); - ModuleType type = ModuleType::input; - std::string type_str; + SignalDirection type = SignalDirection::input; + std::string type_str; file >> type_str; if (type_str == "input") { - type = ModuleType::input; + type = SignalDirection::input; } else if (type_str == "output") { - type = ModuleType::output; + type = SignalDirection::output; } else if (type_str == "inputoutput") { - type = ModuleType::input_output; + type = SignalDirection::duplex; } else { std::cerr << "error: bad position type `" << type_str << "' for module `" << name << "'" << std::endl; diff --git a/src/Configuration.hpp b/src/Configuration.hpp index 6d6b54a..71c6d84 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -23,11 +23,11 @@ #include <map> #include <string> -enum class ModuleType +enum class SignalDirection { input, output, - input_output, + duplex, }; enum class PortType @@ -62,11 +62,13 @@ public: void load(); void save(); - bool - get_module_location(const std::string& name, ModuleType type, Coord& loc); + bool get_module_location(const std::string& name, + SignalDirection type, + Coord& loc); - void - set_module_location(const std::string& name, ModuleType type, Coord loc); + void set_module_location(const std::string& name, + SignalDirection type, + Coord loc); void set_module_split(const std::string& name, bool split); bool get_module_split(const std::string& name, bool default_val) const; diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp index 001b582..23ef53d 100644 --- a/src/JackDbusDriver.cpp +++ b/src/JackDbusDriver.cpp @@ -642,13 +642,13 @@ JackDriver::add_port(dbus_uint64_t /*client_id*/, return; } - ModuleType type = ModuleType::input_output; + SignalDirection type = SignalDirection::duplex; if (_app->conf()->get_module_split( client_name, port_flags & JACKDBUS_PORT_FLAG_TERMINAL)) { if (port_flags & JACKDBUS_PORT_FLAG_INPUT) { - type = ModuleType::input; + type = SignalDirection::input; } else { - type = ModuleType::output; + type = SignalDirection::output; } } @@ -693,7 +693,7 @@ JackDriver::remove_port(dbus_uint64_t /*client_id*/, } PatchageModule* -JackDriver::find_or_create_module(ModuleType type, const std::string& name) +JackDriver::find_or_create_module(SignalDirection type, const std::string& name) { const auto id = ClientID::jack(name); PatchageModule* module = _app->canvas()->find_module(id, type); diff --git a/src/JackDbusDriver.hpp b/src/JackDbusDriver.hpp index a92e553..f85f59d 100644 --- a/src/JackDbusDriver.hpp +++ b/src/JackDbusDriver.hpp @@ -77,7 +77,7 @@ private: void info_msg(const std::string& msg) const; PatchageModule* - find_or_create_module(ModuleType type, const std::string& name); + find_or_create_module(SignalDirection type, const std::string& name); void add_port(PatchageModule* module, PortType type, diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 7f2e4cb..a86eadc 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -155,13 +155,13 @@ JackDriver::create_port_view(Patchage* patchage, const PortID& id) std::string port_name; port_names(id, module_name, port_name); - ModuleType type = ModuleType::input_output; + SignalDirection type = SignalDirection::duplex; if (_app->conf()->get_module_split(module_name, (jack_flags & JackPortIsTerminal))) { if (jack_flags & JackPortIsInput) { - type = ModuleType::input; + type = SignalDirection::input; } else { - type = ModuleType::output; + type = SignalDirection::output; } } @@ -309,13 +309,13 @@ JackDriver::refresh() client1_name = ports[i]; client1_name = client1_name.substr(0, client1_name.find(':')); - ModuleType type = ModuleType::input_output; + SignalDirection type = SignalDirection::duplex; if (_app->conf()->get_module_split( client1_name, (jack_port_flags(port) & JackPortIsTerminal))) { if (jack_port_flags(port) & JackPortIsInput) { - type = ModuleType::input; + type = SignalDirection::input; } else { - type = ModuleType::output; + type = SignalDirection::output; } } @@ -346,9 +346,9 @@ JackDriver::refresh() port1_name = client1_name.substr(colon + 1); client1_name = client1_name.substr(0, colon); - const ModuleType port1_type = (jack_port_flags(port) & JackPortIsInput) - ? ModuleType::input - : ModuleType::output; + const SignalDirection port1_type = + (jack_port_flags(port) & JackPortIsInput) ? SignalDirection::input + : SignalDirection::output; const auto port1_id = PortID::jack(ports[i]); const auto client1_id = ClientID::jack(client1_name); @@ -367,9 +367,10 @@ JackDriver::refresh() const auto port2_id = PortID::jack(connected_ports[j]); const auto client2_id = ClientID::jack(client2_name); - const ModuleType port2_type = (port1_type == ModuleType::input) - ? ModuleType::output - : ModuleType::input; + const SignalDirection port2_type = + (port1_type == SignalDirection::input) + ? SignalDirection::output + : SignalDirection::input; PatchageModule* client2_module = _app->canvas()->find_module(client2_id, port2_type); diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index f31c2f9..e236ceb 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -40,7 +40,7 @@ PatchageCanvas::PatchageCanvas(Connector& connector, int width, int height) } PatchageModule* -PatchageCanvas::find_module(const ClientID& id, const ModuleType type) +PatchageCanvas::find_module(const ClientID& id, const SignalDirection type) { auto i = _module_index.find(id); @@ -50,7 +50,7 @@ PatchageCanvas::find_module(const ClientID& id, const ModuleType type) return i->second; } - if (i->second->type() == ModuleType::input_output) { + if (i->second->type() == SignalDirection::duplex) { io_module = i->second; } } @@ -194,11 +194,11 @@ PatchageCanvas::add_module(const ClientID& id, PatchageModule* module) // Join partners, if applicable PatchageModule* in_module = nullptr; PatchageModule* out_module = nullptr; - if (module->type() == ModuleType::input) { + if (module->type() == SignalDirection::input) { in_module = module; - out_module = find_module(id, ModuleType::output); - } else if (module->type() == ModuleType::output) { - in_module = find_module(id, ModuleType::output); + out_module = find_module(id, SignalDirection::output); + } else if (module->type() == SignalDirection::output) { + in_module = find_module(id, SignalDirection::output); out_module = module; } diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index 7f68b9c..0debcf8 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -45,7 +45,7 @@ class PatchageCanvas : public Ganv::Canvas public: PatchageCanvas(Connector& connector, int width, int height); - PatchageModule* find_module(const ClientID& id, ModuleType type); + PatchageModule* find_module(const ClientID& id, SignalDirection type); PatchagePort* find_port(const PortID& id); void remove_module(const ClientID& id); diff --git a/src/PatchageModule.cpp b/src/PatchageModule.cpp index 63a268c..73dd3e8 100644 --- a/src/PatchageModule.cpp +++ b/src/PatchageModule.cpp @@ -22,7 +22,7 @@ PatchageModule::PatchageModule(Patchage* app, const std::string& name, - ModuleType type, + SignalDirection type, ClientID id, double x, double y) @@ -56,7 +56,7 @@ PatchageModule::update_menu() return; } - if (_type == ModuleType::input_output) { + if (_type == SignalDirection::duplex) { bool has_in = false; bool has_out = false; for (const_iterator p = begin(); p != end(); ++p) { @@ -79,7 +79,7 @@ PatchageModule::show_menu(GdkEventButton* ev) { _menu = new Gtk::Menu(); Gtk::Menu::MenuList& items = _menu->items(); - if (_type == ModuleType::input_output) { + if (_type == SignalDirection::duplex) { items.push_back(Gtk::Menu_Helpers::MenuElem( "_Split", sigc::mem_fun(this, &PatchageModule::split))); update_menu(); @@ -125,7 +125,7 @@ PatchageModule::store_location(double x, double y) void PatchageModule::split() { - assert(_type == ModuleType::input_output); + assert(_type == SignalDirection::duplex); _app->conf()->set_module_split(_name, true); _app->refresh(); } @@ -133,7 +133,7 @@ PatchageModule::split() void PatchageModule::join() { - assert(_type != ModuleType::input_output); + assert(_type != SignalDirection::duplex); _app->conf()->set_module_split(_name, false); _app->refresh(); } diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp index 6953124..d55e381 100644 --- a/src/PatchageModule.hpp +++ b/src/PatchageModule.hpp @@ -40,7 +40,7 @@ class PatchageModule : public Ganv::Module public: PatchageModule(Patchage* app, const std::string& name, - ModuleType type, + SignalDirection type, ClientID id, double x = 0, double y = 0); @@ -66,18 +66,18 @@ public: void show_dialog() {} void store_location(double x, double y); - ModuleType type() const { return _type; } + SignalDirection type() const { return _type; } ClientID id() const { return _id; } const std::string& name() const { return _name; } protected: bool on_event(GdkEvent* ev) override; - Patchage* _app; - Gtk::Menu* _menu; - std::string _name; - ModuleType _type; - ClientID _id; + Patchage* _app; + Gtk::Menu* _menu; + std::string _name; + SignalDirection _type; + ClientID _id; }; #endif // PATCHAGE_PATCHAGEMODULE_HPP |