diff options
author | David Robillard <d@drobilla.net> | 2021-01-02 14:02:44 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-01-02 14:02:44 +0100 |
commit | 663a5d01b1931b97370ed8feff3ae229a9cc7ea4 (patch) | |
tree | aba74794cb45f06734bd80bbf53d79f947008e54 /src/ClientID.hpp | |
parent | 1936aace80b5594078d874e9b661a9a91e461279 (diff) | |
download | patchage-663a5d01b1931b97370ed8feff3ae229a9cc7ea4.tar.gz patchage-663a5d01b1931b97370ed8feff3ae229a9cc7ea4.tar.bz2 patchage-663a5d01b1931b97370ed8feff3ae229a9cc7ea4.zip |
Format all code with clang-format
Diffstat (limited to 'src/ClientID.hpp')
-rw-r--r-- | src/ClientID.hpp | 139 |
1 files changed, 69 insertions, 70 deletions
diff --git a/src/ClientID.hpp b/src/ClientID.hpp index c0a2db8..911d2ec 100644 --- a/src/ClientID.hpp +++ b/src/ClientID.hpp @@ -28,99 +28,98 @@ namespace patchage { /// An ID for some client (program) that has ports -struct ClientID -{ - using Type = ClientType; +struct ClientID { + using Type = ClientType; - ClientID(const ClientID& copy) = default; - ClientID& operator=(const ClientID& copy) = default; + ClientID(const ClientID& copy) = default; + ClientID& operator=(const ClientID& copy) = default; - ClientID(ClientID&& id) = default; - ClientID& operator=(ClientID&& id) = default; + ClientID(ClientID&& id) = default; + ClientID& operator=(ClientID&& id) = default; - ~ClientID() = default; + ~ClientID() = default; - /// Return an ID for a JACK client by name - static ClientID jack(std::string name) - { - return ClientID{Type::jack, std::move(name)}; - } + /// Return an ID for a JACK client by name + static ClientID jack(std::string name) + { + return ClientID{Type::jack, std::move(name)}; + } - /// Return an ID for an ALSA Sequencer client by ID - static ClientID alsa(const uint8_t id) { return ClientID{Type::alsa, id}; } + /// Return an ID for an ALSA Sequencer client by ID + static ClientID alsa(const uint8_t id) { return ClientID{Type::alsa, id}; } - Type type() const { return _type; } - const std::string& jack_name() const { return _jack_name; } - uint8_t alsa_id() const { return _alsa_id; } + Type type() const { return _type; } + const std::string& jack_name() const { return _jack_name; } + uint8_t alsa_id() const { return _alsa_id; } private: - ClientID(const Type type, std::string jack_name) - : _type{type} - , _jack_name{std::move(jack_name)} - { - assert(_type == Type::jack); - } - - ClientID(const Type type, const uint8_t alsa_id) - : _type{type} - , _alsa_id{alsa_id} - { - assert(_type == Type::alsa); - } - - Type _type; ///< Determines which field is active - std::string _jack_name{}; ///< Client name for Type::jack - uint8_t _alsa_id{}; ///< Client ID for Type::alsa + ClientID(const Type type, std::string jack_name) + : _type{type} + , _jack_name{std::move(jack_name)} + { + assert(_type == Type::jack); + } + + ClientID(const Type type, const uint8_t alsa_id) + : _type{type} + , _alsa_id{alsa_id} + { + assert(_type == Type::alsa); + } + + Type _type; ///< Determines which field is active + std::string _jack_name{}; ///< Client name for Type::jack + uint8_t _alsa_id{}; ///< Client ID for Type::alsa }; static inline std::ostream& operator<<(std::ostream& os, const ClientID& id) { - switch (id.type()) { - case ClientID::Type::jack: - return os << "jack:" << id.jack_name(); - case ClientID::Type::alsa: - return os << "alsa:" << int(id.alsa_id()); - } - - assert(false); - return os; + switch (id.type()) { + case ClientID::Type::jack: + return os << "jack:" << id.jack_name(); + case ClientID::Type::alsa: + return os << "alsa:" << int(id.alsa_id()); + } + + assert(false); + return os; } static inline bool operator==(const ClientID& lhs, const ClientID& rhs) { - if (lhs.type() != rhs.type()) { - return false; - } - - switch (lhs.type()) { - case ClientID::Type::jack: - return lhs.jack_name() == rhs.jack_name(); - case ClientID::Type::alsa: - return lhs.alsa_id() == rhs.alsa_id(); - } - - assert(false); - return false; + if (lhs.type() != rhs.type()) { + return false; + } + + switch (lhs.type()) { + case ClientID::Type::jack: + return lhs.jack_name() == rhs.jack_name(); + case ClientID::Type::alsa: + return lhs.alsa_id() == rhs.alsa_id(); + } + + assert(false); + return false; } static inline bool operator<(const ClientID& lhs, const ClientID& rhs) { - if (lhs.type() != rhs.type()) { - return lhs.type() < rhs.type(); - } - - switch (lhs.type()) { - case ClientID::Type::jack: - return lhs.jack_name() < rhs.jack_name(); - case ClientID::Type::alsa: - return lhs.alsa_id() < rhs.alsa_id(); - } - - assert(false); - return false; + if (lhs.type() != rhs.type()) { + return lhs.type() < rhs.type(); + } + + switch (lhs.type()) { + case ClientID::Type::jack: + return lhs.jack_name() < rhs.jack_name(); + case ClientID::Type::alsa: + return lhs.alsa_id() < rhs.alsa_id(); + } + + assert(false); + return false; } } // namespace patchage |