]> git.tdb.fi Git - libs/al.git/blobdiff - source/playlist.h
Externalize playlist management from Jukebox
[libs/al.git] / source / playlist.h
diff --git a/source/playlist.h b/source/playlist.h
new file mode 100644 (file)
index 0000000..72226ad
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef MSP_AL_PLAYLIST_H_
+#define MSP_AL_PLAYLIST_H_
+
+#include <string>
+#include <vector>
+#include <msp/datafile/objectloader.h>
+
+namespace Msp {
+namespace AL {
+
+class Playlist
+{
+public:
+       class Loader: public DataFile::CollectionObjectLoader<Playlist>
+       {
+       public:
+               Loader(Playlist &);
+               Loader(Playlist &, Collection &);
+       private:
+               void init();
+
+               void track(const std::string &);
+       };
+
+private:
+       struct Track
+       {
+               const DataFile::Collection *collection;
+               std::string filename;
+
+               Track();
+               Track(const std::string &);
+       };
+
+       bool shuffle;
+       std::vector<Track> tracks;
+
+public:
+       Playlist();
+
+       void add_track(const std::string &);
+       void remove_track(const std::string &);
+       void clear_tracks();
+       void set_shuffle(bool);
+       const std::string &get_track(unsigned) const;
+       unsigned size() const { return tracks.size(); }
+       bool empty() const { return tracks.empty(); }
+
+       unsigned advance(unsigned, int = 1) const;
+       IO::Seekable *open(unsigned) const;
+};
+
+} // namespace AL
+} // namespace Msp
+
+#endif