1111namespace telemetry
1212{
1313
14+ // / a generic map that corresponds to T -> key && Stats -> value
15+ // /
16+ // / ex: StatsMap<SongID> -> for each song id we have a corresponding stat struct
17+ // / describing about the song (like no of plays, total playtime, last played, etc.)
18+ template <typename T>
19+ using StatsMap = ankerl::unordered_dense::map<T, Stats>;
20+
1421class Store
1522{
1623public:
@@ -27,10 +34,10 @@ class Store
2734 [[nodiscard]] auto album (AlbumID id) const -> const Stats*;
2835 [[nodiscard]] auto genre (GenreID id) const -> const Stats*;
2936
30- [[nodiscard]] auto songs () const -> const ankerl::unordered_dense::map <SongID, Stats >&;
31- [[nodiscard]] auto artists () const -> const ankerl::unordered_dense::map <ArtistID, Stats >&;
32- [[nodiscard]] auto albums () const -> const ankerl::unordered_dense::map <AlbumID, Stats >&;
33- [[nodiscard]] auto genres () const -> const ankerl::unordered_dense::map <GenreID, Stats >&;
37+ [[nodiscard]] auto songs () const -> const StatsMap <SongID>&;
38+ [[nodiscard]] auto artists () const -> const StatsMap <ArtistID>&;
39+ [[nodiscard]] auto albums () const -> const StatsMap <AlbumID>&;
40+ [[nodiscard]] auto genres () const -> const StatsMap <GenreID>&;
3441
3542 // Disk API
3643 [[nodiscard]] auto save (const std::string& path) const -> bool;
@@ -45,10 +52,10 @@ class Store
4552 std::vector<Event> events;
4653 double minPlaySec = 30.0 ;
4754
48- ankerl::unordered_dense::map <SongID, Stats > songStats;
49- ankerl::unordered_dense::map <ArtistID, Stats > artistStats;
50- ankerl::unordered_dense::map <AlbumID, Stats > albumStats;
51- ankerl::unordered_dense::map <GenreID, Stats > genreStats;
55+ StatsMap <SongID> songStats;
56+ StatsMap <ArtistID> artistStats;
57+ StatsMap <AlbumID> albumStats;
58+ StatsMap <GenreID> genreStats;
5259
5360 static auto find (const auto & map, auto id) -> const Stats*;
5461
0 commit comments