Skip to content

Commit 1b4b81b

Browse files
committed
Split out and extend the CI dispatcher backends.
1 parent de0e82b commit 1b4b81b

11 files changed

+1394
-563
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#===-- CMakeLists ------------------------------------------------------------*- C++ -*-===//
23
#
34
# midi2 library under the MIT license.
@@ -32,11 +33,12 @@ set(MIDI2_HEADERS
3233
"${INCLUDE_DIR}/midi2/ci7text.hpp"
3334
"${INCLUDE_DIR}/midi2/ci_create_message.hpp"
3435
"${INCLUDE_DIR}/midi2/ci_dispatcher.hpp"
36+
"${INCLUDE_DIR}/midi2/ci_dispatcher_backend.hpp"
3537
"${INCLUDE_DIR}/midi2/ci_types.hpp"
36-
"${INCLUDE_DIR}/midi2/dispatcher_backend.hpp"
3738
"${INCLUDE_DIR}/midi2/icubaby.hpp"
3839
"${INCLUDE_DIR}/midi2/mcoded7.hpp"
3940
"${INCLUDE_DIR}/midi2/ump_dispatcher.hpp"
41+
"${INCLUDE_DIR}/midi2/ump_dispatcher_backend.hpp"
4042
"${INCLUDE_DIR}/midi2/ump_to_bytestream.hpp"
4143
"${INCLUDE_DIR}/midi2/ump_to_midi1.hpp"
4244
"${INCLUDE_DIR}/midi2/ump_to_midi2.hpp"

include/midi2/ci_dispatcher.hpp

+56-256
Large diffs are not rendered by default.

include/midi2/ci_dispatcher_backend.hpp

+607
Large diffs are not rendered by default.

include/midi2/ci_types.hpp

+37-3
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ struct endpoint_info {
336336
constexpr endpoint_info &operator=(endpoint_info const &) = default;
337337
constexpr endpoint_info &operator=(endpoint_info &&) noexcept = default;
338338

339-
bool operator==(endpoint_info const &) const = default;
339+
constexpr bool operator==(endpoint_info const &) const noexcept = default;
340340

341341
explicit constexpr operator packed::endpoint_info_v1() const;
342342

@@ -383,6 +383,10 @@ struct endpoint_info_reply {
383383
constexpr endpoint_info_reply &operator=(endpoint_info_reply const &) = default;
384384
constexpr endpoint_info_reply &operator=(endpoint_info_reply &&) noexcept = default;
385385

386+
constexpr bool operator==(endpoint_info_reply const &other) const noexcept {
387+
return status == other.status && std::ranges::equal(information, other.information);
388+
}
389+
386390
explicit constexpr operator packed::endpoint_info_reply_v1() const;
387391

388392
std::byte status{};
@@ -478,6 +482,8 @@ struct ack {
478482

479483
explicit constexpr operator packed::ack_v1() const;
480484

485+
constexpr bool operator==(ack const &other) const noexcept;
486+
481487
std::uint8_t original_id = 0;
482488
std::uint8_t status_code = 0;
483489
std::uint8_t status_data = 0;
@@ -502,6 +508,11 @@ constexpr ack::operator packed::ack_v1() const {
502508
{std::byte{0}}};
503509
}
504510

511+
constexpr bool ack::operator==(ack const &other) const noexcept {
512+
return original_id == other.original_id && status_code == other.status_code && status_data == other.status_data &&
513+
details == other.details && std::ranges::equal(message, other.message);
514+
}
515+
505516
//* _ *
506517
//* _ _ __ _| |__ *
507518
//* | ' \/ _` | / / *
@@ -577,6 +588,11 @@ constexpr nak::operator packed::nak_v2() const {
577588
{std::byte{0}}};
578589
}
579590

591+
constexpr bool nak::operator==(nak const &other) const {
592+
return original_id == other.original_id && status_code == other.status_code && status_data == other.status_data &&
593+
details == other.details && std::ranges::equal(message, other.message);
594+
}
595+
580596
namespace profile_configuration {
581597

582598
//* __ _ _ _ _ *
@@ -630,6 +646,9 @@ struct inquiry_reply {
630646
constexpr inquiry_reply &operator=(inquiry_reply const &) = default;
631647
constexpr inquiry_reply &operator=(inquiry_reply &&) noexcept = default;
632648

649+
constexpr bool operator==(inquiry_reply const &other) const {
650+
return std::ranges::equal(enabled, other.enabled) && std::ranges::equal(disabled, other.disabled);
651+
}
633652
explicit constexpr operator packed::inquiry_reply_v1_pt1() const;
634653
explicit constexpr operator packed::inquiry_reply_v1_pt2() const;
635654

@@ -808,6 +827,10 @@ struct details_reply {
808827

809828
explicit constexpr operator packed::details_reply_v1() const;
810829

830+
constexpr bool operator==(details_reply const &other) const {
831+
return pid == other.pid && target == other.target && std::ranges::equal(data, other.data);
832+
}
833+
811834
byte_array_5 pid{}; ///< Profile ID of profile
812835
std::uint8_t target = 0; ///< Inquiry target
813836
std::span<std::byte const> data;
@@ -1107,6 +1130,10 @@ struct specific_data {
11071130

11081131
explicit constexpr operator packed::specific_data_v1() const;
11091132

1133+
constexpr bool operator==(specific_data const &other) const {
1134+
return pid == other.pid && std::ranges::equal(data, other.data);
1135+
}
1136+
11101137
byte_array_5 pid{}; ///< Profile ID
11111138
std::span<std::byte const> data; ///< Profile specific data
11121139
};
@@ -1299,7 +1326,8 @@ static_assert(std::is_trivially_copyable_v<property_exchange_pt2>);
12991326

13001327
} // end namespace packed
13011328

1302-
struct property_exchange {
1329+
class property_exchange {
1330+
public:
13031331
struct chunk_info {
13041332
chunk_info() = default;
13051333
chunk_info(std::uint16_t const number_of_chunks_, std::uint16_t const chunk_number_)
@@ -1316,9 +1344,10 @@ struct property_exchange {
13161344
explicit constexpr operator packed::property_exchange_pt1() const;
13171345
explicit constexpr operator packed::property_exchange_pt2() const;
13181346

1347+
constexpr bool operator==(property_exchange const &other) const;
1348+
13191349
protected:
13201350
constexpr property_exchange() = default;
1321-
13221351
constexpr property_exchange(chunk_info const &chunk_, std::uint8_t request_, std::span<char const> header_,
13231352
std::span<char const> data_)
13241353
: chunk{chunk_}, request{request_}, header{header_}, data{data_} {}
@@ -1341,6 +1370,11 @@ constexpr property_exchange::operator packed::property_exchange_pt2() const {
13411370
};
13421371
}
13431372

1373+
constexpr bool property_exchange::operator==(property_exchange const &other) const {
1374+
return chunk == other.chunk && request == other.request && std::ranges::equal(header, other.header) &&
1375+
std::ranges::equal(data, other.data);
1376+
}
1377+
13441378
struct get : public property_exchange {
13451379
public:
13461380
constexpr get() = default;

include/midi2/ump_dispatcher.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <cstdint>
1717
#include <span>
1818

19-
#include "midi2/dispatcher_backend.hpp"
19+
#include "midi2/ump_dispatcher_backend.hpp"
2020
#include "midi2/ump_types.hpp"
2121
#include "midi2/utils.hpp"
2222

0 commit comments

Comments
 (0)