diff options
author | David Robillard <d@drobilla.net> | 2020-11-29 18:24:03 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-29 18:24:03 +0100 |
commit | 178d1cbe1dfc9e7b66c36cbb75590e1cee419174 (patch) | |
tree | 4e33ecbff68fc65d9771c2e654411ad9f1aecd86 /src | |
parent | 4265b9a78dac2b7f26f505c7b90b0d88494e93c2 (diff) | |
download | patchage-178d1cbe1dfc9e7b66c36cbb75590e1cee419174.tar.gz patchage-178d1cbe1dfc9e7b66c36cbb75590e1cee419174.tar.bz2 patchage-178d1cbe1dfc9e7b66c36cbb75590e1cee419174.zip |
Put everything in a namespace
Diffstat (limited to 'src')
43 files changed, 180 insertions, 7 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index bc80d48..c471efe 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -40,6 +40,7 @@ PATCHAGE_RESTORE_WARNINGS #include <string> #include <utility> +namespace patchage { namespace { /// Driver for ALSA Sequencer ports @@ -136,8 +137,6 @@ port_info(const snd_seq_port_info_t* const pinfo) (type & SND_SEQ_PORT_TYPE_APPLICATION) == 0}; } -} // namespace - AlsaDriver::AlsaDriver(ILog& log, EventSink emit_event) : Driver{std::move(emit_event)} , _log(log) @@ -544,8 +543,12 @@ AlsaDriver::_refresh_main() } } +} // namespace + std::unique_ptr<Driver> make_alsa_driver(ILog& log, Driver::EventSink emit_event) { return std::unique_ptr<Driver>{new AlsaDriver{log, std::move(emit_event)}}; } + +} // namespace patchage diff --git a/src/AudioDriver.hpp b/src/AudioDriver.hpp index 7e1e5a7..a1e1a33 100644 --- a/src/AudioDriver.hpp +++ b/src/AudioDriver.hpp @@ -21,6 +21,8 @@ #include <cstdint> +namespace patchage { + /// Base class for drivers that work with an audio system class AudioDriver : public Driver { @@ -45,4 +47,6 @@ public: virtual uint32_t sample_rate() = 0; }; +} // namespace patchage + #endif // PATCHAGE_AUDIODRIVER_HPP diff --git a/src/ClientID.hpp b/src/ClientID.hpp index 639cbbf..c0a2db8 100644 --- a/src/ClientID.hpp +++ b/src/ClientID.hpp @@ -25,6 +25,8 @@ #include <string> #include <utility> +namespace patchage { + /// An ID for some client (program) that has ports struct ClientID { @@ -121,4 +123,6 @@ operator<(const ClientID& lhs, const ClientID& rhs) return false; } +} // namespace patchage + #endif // PATCHAGE_CLIENTID_HPP diff --git a/src/ClientInfo.hpp b/src/ClientInfo.hpp index 9229d16..19c3c85 100644 --- a/src/ClientInfo.hpp +++ b/src/ClientInfo.hpp @@ -19,10 +19,14 @@ #include <string> +namespace patchage { + /// Extra information about a client (program) not expressed in its ID struct ClientInfo { std::string label; ///< Human-friendly label }; +} // namespace patchage + #endif // PATCHAGE_CLIENTINFO_HPP diff --git a/src/ClientType.hpp b/src/ClientType.hpp index 622b3d8..5f96875 100644 --- a/src/ClientType.hpp +++ b/src/ClientType.hpp @@ -17,6 +17,8 @@ #ifndef PATCHAGE_CLIENTTYPE_HPP #define PATCHAGE_CLIENTTYPE_HPP +namespace patchage { + /// A type of client (program) with supported ports enum class ClientType { @@ -24,4 +26,6 @@ enum class ClientType alsa, }; +} // namespace patchage + #endif // PATCHAGE_CLIENTTYPE_HPP diff --git a/src/Configuration.cpp b/src/Configuration.cpp index d35ae7a..6158702 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -27,6 +27,8 @@ #include <limits> #include <vector> +namespace patchage { + static const char* const port_type_names[N_PORT_TYPES] = {"JACK_AUDIO", "JACK_MIDI", "ALSA_MIDI", @@ -358,3 +360,5 @@ Configuration::save() file.close(); } + +} // namespace patchage diff --git a/src/Configuration.hpp b/src/Configuration.hpp index 1a6ac6c..0844de8 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -28,6 +28,8 @@ #define N_PORT_TYPES 5 +namespace patchage { + struct Coord { Coord() = default; @@ -131,4 +133,6 @@ private: bool _sort_ports = true; }; +} // namespace patchage + #endif // PATCHAGE_CONFIGURATION_HPP diff --git a/src/Connector.cpp b/src/Connector.cpp index c26c7a7..84aa6c2 100644 --- a/src/Connector.cpp +++ b/src/Connector.cpp @@ -22,6 +22,8 @@ #include <unordered_map> +namespace patchage { + Connector::Connector(ILog& log) : _log(log) {} @@ -65,3 +67,5 @@ Connector::disconnect(const PortID& tail, const PortID& head) d->second->disconnect(tail, head); } + +} // namespace patchage diff --git a/src/Connector.hpp b/src/Connector.hpp index 084217e..e10e540 100644 --- a/src/Connector.hpp +++ b/src/Connector.hpp @@ -21,6 +21,8 @@ #include <unordered_map> +namespace patchage { + class Driver; class ILog; @@ -40,4 +42,6 @@ private: std::unordered_map<PortID::Type, Driver*> _drivers; }; +} // namespace patchage + #endif // PATCHAGE_CONNECTOR_HPP diff --git a/src/Driver.hpp b/src/Driver.hpp index 21f604e..7873ef3 100644 --- a/src/Driver.hpp +++ b/src/Driver.hpp @@ -22,6 +22,8 @@ #include <functional> #include <utility> +namespace patchage { + /// Base class for drivers that handle system clients and ports class Driver { @@ -62,4 +64,6 @@ protected: EventSink _emit_event; ///< Sink for emitting "live" events }; +} // namespace patchage + #endif // PATCHAGE_DRIVER_HPP diff --git a/src/ILog.hpp b/src/ILog.hpp index e1ee8b4..33b2644 100644 --- a/src/ILog.hpp +++ b/src/ILog.hpp @@ -19,6 +19,8 @@ #include <string> +namespace patchage { + /// Interface for writing log messages class ILog { @@ -38,4 +40,6 @@ public: virtual void error(const std::string& msg) = 0; }; +} // namespace patchage + #endif // PATCHAGE_ILOG_HPP diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp index c656594..9584901 100644 --- a/src/JackDbusDriver.cpp +++ b/src/JackDbusDriver.cpp @@ -54,6 +54,9 @@ PATCHAGE_RESTORE_WARNINGS #define JACKDBUS_PORT_TYPE_AUDIO 0 #define JACKDBUS_PORT_TYPE_MIDI 1 +namespace patchage { +namespace { + /// Driver for JACK audio and midi ports that uses D-Bus class JackDriver : public AudioDriver { @@ -973,9 +976,13 @@ JackDriver::info_msg(const std::string& msg) const _log.info(std::string{"[JACK] "} + msg); } +} // namespace + std::unique_ptr<AudioDriver> make_jack_driver(ILog& log, Driver::EventSink emit_event) { return std::unique_ptr<AudioDriver>{ new JackDriver{log, std::move(emit_event)}}; } + +} // namespace patchage diff --git a/src/JackLibDriver.cpp b/src/JackLibDriver.cpp index 86c1609..63054e5 100644 --- a/src/JackLibDriver.cpp +++ b/src/JackLibDriver.cpp @@ -49,6 +49,9 @@ PATCHAGE_RESTORE_WARNINGS #include <unordered_set> #include <utility> +namespace patchage { +namespace { + /// Driver for JACK audio and midi ports that uses libjack class JackLibDriver : public AudioDriver { @@ -180,7 +183,7 @@ JackLibDriver::is_attached() const return _client != nullptr; } -static std::string +std::string get_property(const jack_uuid_t subject, const char* const key) { std::string result; @@ -493,9 +496,13 @@ JackLibDriver::jack_shutdown_cb(void* const jack_driver) me->_emit_event(DriverDetachmentEvent{ClientType::jack}); } +} // namespace + std::unique_ptr<AudioDriver> make_jack_driver(ILog& log, Driver::EventSink emit_event) { return std::unique_ptr<AudioDriver>{ new JackLibDriver{log, std::move(emit_event)}}; } + +} // namespace patchage diff --git a/src/Legend.cpp b/src/Legend.cpp index 42fb95d..a97d7bd 100644 --- a/src/Legend.cpp +++ b/src/Legend.cpp @@ -26,6 +26,8 @@ #include <string> +namespace patchage { + Legend::Legend(const Configuration& configuration) { add_button(PortType::jack_audio, @@ -84,3 +86,5 @@ Legend::on_color_set(const PortType id, signal_color_changed.emit(id, label, rgba); } + +} // namespace patchage diff --git a/src/Legend.hpp b/src/Legend.hpp index c1563e9..6d5807b 100644 --- a/src/Legend.hpp +++ b/src/Legend.hpp @@ -25,6 +25,8 @@ #include <string> +namespace patchage { + class Legend : public Gtk::HBox { public: @@ -39,4 +41,6 @@ public: sigc::signal<void, PortType, std::string, uint32_t> signal_color_changed; }; +} // namespace patchage + #endif // PATCHAGE_LEGEND_HPP diff --git a/src/Metadata.cpp b/src/Metadata.cpp index d628981..a275f9b 100644 --- a/src/Metadata.cpp +++ b/src/Metadata.cpp @@ -23,6 +23,8 @@ #include <boost/optional.hpp> +namespace patchage { + boost::optional<ClientInfo> Metadata::client(const ClientID& id) { @@ -78,3 +80,5 @@ Metadata::erase_port(const PortID& id) { _port_data.erase(id); } + +} // namespace patchage diff --git a/src/Metadata.hpp b/src/Metadata.hpp index 3fa60c6..2bb8806 100644 --- a/src/Metadata.hpp +++ b/src/Metadata.hpp @@ -26,6 +26,8 @@ #include <map> +namespace patchage { + /// Cache of metadata about clients and ports beyond their IDs class Metadata { @@ -49,4 +51,6 @@ private: PortData _port_data; }; +} // namespace patchage + #endif // PATCHAGE_METADATA_HPP diff --git a/src/Options.hpp b/src/Options.hpp index df9f220..86853e5 100644 --- a/src/Options.hpp +++ b/src/Options.hpp @@ -17,10 +17,14 @@ #ifndef PATCHAGE_OPTIONS_HPP #define PATCHAGE_OPTIONS_HPP +namespace patchage { + struct Options { bool alsa_driver_autoattach = true; bool jack_driver_autoattach = true; }; +} // namespace patchage + #endif // PATCHAGE_OPTIONS_HPP diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 1eaeb6c..a7c5198 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -78,6 +78,8 @@ terminate_cb(GtkosxApplication* app, gpointer data) #endif +namespace patchage { + namespace { bool @@ -893,3 +895,5 @@ Patchage::buffer_size_changed() } } } + +} // namespace patchage diff --git a/src/Patchage.hpp b/src/Patchage.hpp index cba8204..80c3e84 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -53,6 +53,8 @@ #include <queue> #include <string> +namespace patchage { + class AudioDriver; class PatchageCanvas; class Configuration; @@ -207,4 +209,6 @@ protected: bool _attach; }; +} // namespace patchage + #endif // PATCHAGE_PATCHAGE_HPP diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index 27c860a..0fc0ebe 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -37,6 +37,8 @@ PATCHAGE_DISABLE_FMT_WARNINGS #include <fmt/ostream.h> PATCHAGE_RESTORE_WARNINGS +namespace patchage { + PatchageCanvas::PatchageCanvas(Connector& connector, int width, int height) : Ganv::Canvas(width, height) , _connector(connector) @@ -341,3 +343,5 @@ PatchageCanvas::clear() _module_index.clear(); Ganv::Canvas::clear(); } + +} // namespace patchage diff --git a/src/PatchageCanvas.hpp b/src/PatchageCanvas.hpp index 6b981c4..b823727 100644 --- a/src/PatchageCanvas.hpp +++ b/src/PatchageCanvas.hpp @@ -32,6 +32,8 @@ PATCHAGE_RESTORE_WARNINGS #include <string> #include <utility> +namespace patchage { + class Patchage; class PatchageModule; class PatchagePort; @@ -87,4 +89,6 @@ private: ModuleIndex _module_index; }; +} // namespace patchage + #endif // PATCHAGE_PATCHAGECANVAS_HPP diff --git a/src/PatchageEvent.hpp b/src/PatchageEvent.hpp index 0095cde..b98375c 100644 --- a/src/PatchageEvent.hpp +++ b/src/PatchageEvent.hpp @@ -27,6 +27,8 @@ #include <string> +namespace patchage { + struct DriverAttachmentEvent { ClientType type; @@ -81,4 +83,6 @@ using PatchageEvent = boost::variant<DriverAttachmentEvent, ConnectionEvent, DisconnectionEvent>; +} // namespace patchage + #endif // PATCHAGE_PATCHAGEEVENT_HPP diff --git a/src/PatchageModule.cpp b/src/PatchageModule.cpp index d900819..1931b3b 100644 --- a/src/PatchageModule.cpp +++ b/src/PatchageModule.cpp @@ -21,6 +21,8 @@ #include "PatchagePort.hpp" #include "SignalDirection.hpp" +namespace patchage { + PatchageModule::PatchageModule(Patchage* app, const std::string& name, SignalDirection type, @@ -160,3 +162,5 @@ PatchageModule::get_port(const PortID& id) return nullptr; } + +} // namespace patchage diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp index 7c3f191..378f35ed 100644 --- a/src/PatchageModule.hpp +++ b/src/PatchageModule.hpp @@ -30,6 +30,8 @@ PATCHAGE_RESTORE_WARNINGS #include <string> +namespace patchage { + struct PortID; class Patchage; @@ -80,4 +82,6 @@ protected: ClientID _id; }; +} // namespace patchage + #endif // PATCHAGE_PATCHAGEMODULE_HPP diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp index 3a29322..0ef6752 100644 --- a/src/PatchagePort.hpp +++ b/src/PatchagePort.hpp @@ -33,6 +33,8 @@ PATCHAGE_RESTORE_WARNINGS #include <string> +namespace patchage { + /// A port on a PatchageModule class PatchagePort : public Ganv::Port { @@ -118,4 +120,6 @@ private: boost::optional<int> _order; }; +} // namespace patchage + #endif // PATCHAGE_PATCHAGEPORT_HPP diff --git a/src/PortID.hpp b/src/PortID.hpp index d92f08e..51db1b0 100644 --- a/src/PortID.hpp +++ b/src/PortID.hpp @@ -27,6 +27,8 @@ #include <tuple> #include <utility> +namespace patchage { + /// An ID for some port on a client (program) struct PortID { @@ -167,12 +169,14 @@ operator<(const PortID& lhs, const PortID& rhs) return false; } +} // namespace patchage + namespace std { template<> -struct hash<PortID::Type> +struct hash<patchage::PortID::Type> { - size_t operator()(const PortID::Type& v) const noexcept + size_t operator()(const patchage::PortID::Type& v) const noexcept { return hash<unsigned>()(static_cast<unsigned>(v)); } diff --git a/src/PortInfo.hpp b/src/PortInfo.hpp index 9b05c43..8b7eba9 100644 --- a/src/PortInfo.hpp +++ b/src/PortInfo.hpp @@ -23,6 +23,8 @@ #include <boost/optional.hpp> #include <string> +namespace patchage { + /// Extra information about a port not expressed in its ID struct PortInfo { @@ -33,4 +35,6 @@ struct PortInfo bool is_terminal; ///< True if this is a system port }; +} // namespace patchage + #endif // PATCHAGE_PORTINFO_HPP diff --git a/src/PortNames.hpp b/src/PortNames.hpp index b8cb187..9d8baf1 100644 --- a/src/PortNames.hpp +++ b/src/PortNames.hpp @@ -22,6 +22,8 @@ #include <cassert> #include <string> +namespace patchage { + /// Utility class that splits a Jack port ID into client and client names class PortNames { @@ -50,4 +52,6 @@ private: std::string _port_name; }; +} // namespace patchage + #endif // PATCHAGE_PORTNAMES_HPP diff --git a/src/PortType.hpp b/src/PortType.hpp index 498564e..ed5d824 100644 --- a/src/PortType.hpp +++ b/src/PortType.hpp @@ -17,6 +17,8 @@ #ifndef PATCHAGE_PORTTYPE_HPP #define PATCHAGE_PORTTYPE_HPP +namespace patchage { + enum class PortType { jack_audio, @@ -26,4 +28,6 @@ enum class PortType jack_cv, }; +} // namespace patchage + #endif // PATCHAGE_PORTTYPE_HPP diff --git a/src/SignalDirection.hpp b/src/SignalDirection.hpp index 03a13a4..52c767d 100644 --- a/src/SignalDirection.hpp +++ b/src/SignalDirection.hpp @@ -17,6 +17,8 @@ #ifndef PATCHAGE_SIGNALDIRECTION_HPP #define PATCHAGE_SIGNALDIRECTION_HPP +namespace patchage { + enum class SignalDirection { input, @@ -24,4 +26,6 @@ enum class SignalDirection duplex, }; +} // namespace patchage + #endif // PATCHAGE_SIGNALDIRECTION_HPP diff --git a/src/TextViewLog.cpp b/src/TextViewLog.cpp index 0e37420..360cae9 100644 --- a/src/TextViewLog.cpp +++ b/src/TextViewLog.cpp @@ -21,6 +21,8 @@ #include <string> +namespace patchage { + TextViewLog::TextViewLog(Widget<Gtk::TextView>& text_view) : _error_tag{Gtk::TextTag::create()} , _warning_tag{Gtk::TextTag::create()} @@ -81,3 +83,5 @@ TextViewLog::min_height() const return line_height + 2 * _text_view->get_pixels_inside_wrap(); } + +} // namespace patchage diff --git a/src/TextViewLog.hpp b/src/TextViewLog.hpp index 1165cdf..913b527 100644 --- a/src/TextViewLog.hpp +++ b/src/TextViewLog.hpp @@ -24,6 +24,8 @@ #include <gtkmm/texttag.h> #include <gtkmm/textview.h> +namespace patchage { + /// Log that writes colored messages to a Gtk TextView class TextViewLog : public ILog { @@ -53,4 +55,6 @@ private: Widget<Gtk::TextView>& _text_view; }; +} // namespace patchage + #endif // PATCHAGE_TEXTVIEWLOG_HPP diff --git a/src/UIFile.hpp b/src/UIFile.hpp index e87a6d9..760b6ea 100644 --- a/src/UIFile.hpp +++ b/src/UIFile.hpp @@ -30,6 +30,8 @@ #include <sstream> #include <string> +namespace patchage { + class UIFile { public: @@ -67,4 +69,6 @@ public: } }; +} // namespace patchage + #endif // PATCHAGE_UIFILE_HPP diff --git a/src/Widget.hpp b/src/Widget.hpp index 4182d40..14326e3 100644 --- a/src/Widget.hpp +++ b/src/Widget.hpp @@ -21,6 +21,8 @@ #include <string> +namespace patchage { + template<typename W> class Widget { @@ -51,4 +53,6 @@ private: W* _me; }; +} // namespace patchage + #endif // PATCHAGE_WIDGET_HPP diff --git a/src/binary_location.h b/src/binary_location.h index 6a996e9..220c534 100644 --- a/src/binary_location.h +++ b/src/binary_location.h @@ -24,6 +24,8 @@ #include <cstdlib> #include <string> +namespace patchage { + /** Return the absolute path of the binary. */ inline std::string binary_location() @@ -54,3 +56,5 @@ bundle_location() } return binary.substr(0, binary.find_last_of('/')); } + +} // namespace patchage diff --git a/src/event_to_string.cpp b/src/event_to_string.cpp index cdfeee4..58d99ac 100644 --- a/src/event_to_string.cpp +++ b/src/event_to_string.cpp @@ -29,6 +29,8 @@ PATCHAGE_RESTORE_WARNINGS #include <iostream> #include <string> +namespace patchage { + namespace { struct EventPrinter @@ -147,3 +149,5 @@ operator<<(std::ostream& os, const PatchageEvent& event) { return os << event_to_string(event); } + +} // namespace patchage diff --git a/src/event_to_string.hpp b/src/event_to_string.hpp index e77629f..0795bce 100644 --- a/src/event_to_string.hpp +++ b/src/event_to_string.hpp @@ -22,10 +22,14 @@ #include <iosfwd> #include <string> +namespace patchage { + std::string event_to_string(const PatchageEvent& event); std::ostream& operator<<(std::ostream& os, const PatchageEvent& event); +} // namespace patchage + #endif // PATCHAGE_EVENT_TO_STRING_HPP diff --git a/src/handle_event.cpp b/src/handle_event.cpp index d3752d1..b6412c2 100644 --- a/src/handle_event.cpp +++ b/src/handle_event.cpp @@ -27,6 +27,8 @@ PATCHAGE_DISABLE_FMT_WARNINGS #include <fmt/ostream.h> PATCHAGE_RESTORE_WARNINGS +namespace patchage { + namespace { class EventHandler @@ -123,3 +125,5 @@ handle_event(Patchage& patchage, const PatchageEvent& event) EventHandler handler{patchage}; boost::apply_visitor(handler, event); } + +} // namespace patchage diff --git a/src/handle_event.hpp b/src/handle_event.hpp index b08bab2..0993db1 100644 --- a/src/handle_event.hpp +++ b/src/handle_event.hpp @@ -19,10 +19,14 @@ #include "PatchageEvent.hpp" +namespace patchage { + class Patchage; /// Handle an event in the GUI void handle_event(Patchage& patchage, const PatchageEvent& event); +} // namespace patchage + #endif // PATCHAGE_HANDLE_EVENT_HPP diff --git a/src/main.cpp b/src/main.cpp index 2763852..d5feb14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -111,7 +111,7 @@ main(int argc, char** argv) --argc; // Parse command line options - Options options; + patchage::Options options; while (argc > 0) { if (!strcmp(*argv, "-h") || !strcmp(*argv, "--help")) { print_usage(); @@ -136,7 +136,7 @@ main(int argc, char** argv) } // Run until main loop is finished - Patchage patchage(options); + patchage::Patchage patchage(options); Gtk::Main::run(*patchage.window()); patchage.save(); diff --git a/src/make_alsa_driver.hpp b/src/make_alsa_driver.hpp index 4c21583..8762718 100644 --- a/src/make_alsa_driver.hpp +++ b/src/make_alsa_driver.hpp @@ -22,6 +22,8 @@ #include <memory> +namespace patchage { + class ILog; #if defined(HAVE_ALSA) @@ -39,4 +41,6 @@ make_alsa_driver(ILog&, Driver::EventSink) #endif +} // namespace patchage + #endif // PATCHAGE_MAKE_ALSA_DRIVER_HPP diff --git a/src/make_jack_driver.hpp b/src/make_jack_driver.hpp index 1099a18..00019a6 100644 --- a/src/make_jack_driver.hpp +++ b/src/make_jack_driver.hpp @@ -22,6 +22,8 @@ #include <memory> +namespace patchage { + class ILog; #if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS) @@ -39,4 +41,6 @@ make_jack_driver(ILog&, Driver::EventSink) #endif +} // namespace patchage + #endif // PATCHAGE_MAKE_JACK_DRIVER_HPP |