#pragma once #include "../ConnectedClient.h" #include "Song.h" #include #include namespace ts { namespace server { class MusicClient; } namespace music { class MusicHistoryEntry : public SongInfo { public: MusicHistoryEntry(std::string url, ClientDbId invoker, ts::SongId songId) : url(std::move(url)), invoker(invoker), id(songId) {} std::string getUrl() const override { return this->url; } ts::ClientDbId getInvoker() const override { return this->invoker; } ts::SongId getSongId() const override { return this->id; } private: ts::SongId id; std::string url; ts::ClientDbId invoker; }; class MusicQueue { public: MusicQueue(server::MusicClient*); ~MusicQueue(); std::shared_ptr currentSong(); std::deque> queueEntries(); std::deque> history(); //near to past std::shared_ptr rewind(); std::shared_ptr getNextSong(); std::shared_ptr find_queue(ts::SongId); std::shared_ptr find(ts::SongId); bool deleteEntry(const std::shared_ptr&); int changeOrder(const std::shared_ptr&, int position); std::shared_ptr insertEntry(const std::string& url, const tsclient& invoker, const std::shared_ptr& loader = nullptr); void notifySongEnded(); void notifySongAbort(); private: server::MusicClient* handle; threads::Mutex lock; std::shared_ptr current; std::deque> queue; uint32_t song_id_index = 1; std::deque> _history; }; } }