From f09ba5ffd53bf7d28e0dc516c00a8f69ca7efae9 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 28 Sep 2023 08:29:55 +1000 Subject: Use bindey for databinding instead of hand rolling ui updates --- src/database/include/track.hpp | 43 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src/database/include/track.hpp') diff --git a/src/database/include/track.hpp b/src/database/include/track.hpp index 1c11ddea..3c7b20fa 100644 --- a/src/database/include/track.hpp +++ b/src/database/include/track.hpp @@ -61,12 +61,17 @@ enum class Tag { */ class TrackTags { public: - auto encoding() const -> Container { return encoding_; }; - auto encoding(Container e) -> void { encoding_ = e; }; - TrackTags() : encoding_(Container::kUnsupported), tags_(&memory::kSpiRamResource) {} + TrackTags(const TrackTags& other) = delete; + TrackTags& operator=(TrackTags& other) = delete; + + bool operator==(const TrackTags&) const = default; + + auto encoding() const -> Container { return encoding_; }; + auto encoding(Container e) -> void { encoding_ = e; }; + std::optional channels; std::optional sample_rate; std::optional bits_per_sample; @@ -85,10 +90,6 @@ class TrackTags { */ auto Hash() const -> uint64_t; - bool operator==(const TrackTags&) const = default; - TrackTags& operator=(const TrackTags&) = default; - TrackTags(const TrackTags&) = default; - private: Container encoding_; std::pmr::unordered_map tags_; @@ -139,6 +140,11 @@ class TrackData { play_count_(play_count), is_tombstoned_(is_tombstoned) {} + TrackData(TrackData&& other) = delete; + TrackData& operator=(TrackData& other) = delete; + + bool operator==(const TrackData&) const = default; + auto id() const -> TrackId { return id_; } auto filepath() const -> std::pmr::string { return filepath_; } auto play_count() const -> uint32_t { return play_count_; } @@ -158,8 +164,6 @@ class TrackData { * new location. */ auto Exhume(const std::pmr::string& new_path) const -> TrackData; - - bool operator==(const TrackData&) const = default; }; /* @@ -172,23 +176,22 @@ class TrackData { */ class Track { public: - Track(const TrackData& data, const TrackTags& tags) + Track(std::shared_ptr& data, std::shared_ptr tags) : data_(data), tags_(tags) {} - Track(const Track& other) = default; - auto data() const -> const TrackData& { return data_; } - auto tags() const -> const TrackTags& { return tags_; } - - auto TitleOrFilename() const -> std::pmr::string; + Track(Track& other) = delete; + Track& operator=(Track& other) = delete; bool operator==(const Track&) const = default; - Track operator=(const Track& other) const { return Track(other); } + + auto data() const -> const TrackData& { return *data_; } + auto tags() const -> const TrackTags& { return *tags_; } + + auto TitleOrFilename() const -> std::pmr::string; private: - const TrackData data_; - const TrackTags tags_; + std::shared_ptr data_; + std::shared_ptr tags_; }; -void swap(Track& first, Track& second); - } // namespace database -- cgit v1.2.3