258875bdb8
Ocarina no longer has a header file subdirectory so there is no reason to have a libsaria subdirectory anymore. Putting header files directly in the include/ directory is a bit simpler. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
141 lines
2.7 KiB
C++
141 lines
2.7 KiB
C++
// Copyright (c) 2012 Bryan Schumaker.
|
|
#ifndef LIBSARIA_PLAYLIST_H
|
|
#define LIBSARIA_PLAYLIST_H
|
|
|
|
#include <notify.h>
|
|
#include <index.h>
|
|
#include <fs.h>
|
|
|
|
#include <list>
|
|
#include <string>
|
|
using namespace std;
|
|
|
|
enum PlaylistFlags {
|
|
PL_NONE = (0),
|
|
PL_NO_DRAIN = (1 << 0),
|
|
PL_STATIC = (1 << 1),
|
|
PL_DISABLED = (1 << 2),
|
|
};
|
|
|
|
enum PlaylistType {
|
|
PLIST_SET,
|
|
PLIST_QUEUE,
|
|
PLIST_LIST,
|
|
};
|
|
|
|
namespace libsaria
|
|
{
|
|
|
|
/* Forward declaration of PlaylistRenderer class */
|
|
class PlaylistRenderer;
|
|
class Track;
|
|
|
|
class Playlist {
|
|
private:
|
|
int number;
|
|
unsigned int flags;
|
|
unsigned int length;
|
|
PlaylistType type;
|
|
DataState data_state;
|
|
list<Track *>::iterator cur;
|
|
Index index;
|
|
|
|
void schedule_save();
|
|
void rm_file();
|
|
void notify_ui(notify_t, Track *, unsigned int);
|
|
|
|
void incr_iter();
|
|
Track *picked_next();
|
|
unsigned int find_cur_index();
|
|
unsigned int find_index(Track *);
|
|
void add_track(Track *, unsigned int);
|
|
void do_remove_tracks(list<Track *> &);
|
|
unsigned int remove_track_it(list<Track *>::iterator &it, unsigned int);
|
|
|
|
protected:
|
|
string name;
|
|
list<Track *> plist;
|
|
PlaylistRenderer *renderer;
|
|
|
|
Track *pick_random();
|
|
Track *pick_sequential();
|
|
void add_sorted(list<Track *> &);
|
|
void add_to_end(list<Track *> &);
|
|
void add_to_front(list<Track *> &);
|
|
|
|
public:
|
|
Playlist(string, unsigned int, PlaylistType);
|
|
virtual ~Playlist();
|
|
void set_renderer(PlaylistRenderer *);
|
|
PlaylistRenderer *get_renderer();
|
|
|
|
void save(ofstream &);
|
|
bool is_static();
|
|
bool is_disabled();
|
|
void prepare_for_removal();
|
|
void reset_iterator();
|
|
void set_filter_text(string &);
|
|
bool is_visible(libsaria::Track *);
|
|
|
|
void set_disabled(bool);
|
|
|
|
virtual Track *next() = 0;
|
|
string &get_name();
|
|
void renumber(int);
|
|
unsigned int get_number();
|
|
unsigned int get_size();
|
|
unsigned int get_length();
|
|
PlaylistType get_type();
|
|
|
|
virtual void do_add_tracks(list<Track *> &) = 0;
|
|
void add_tracks(list<Track *> &);
|
|
void add_track(Track *);
|
|
void remove_indices(list<unsigned int> &);
|
|
void remove_track(Track *);
|
|
void track_updated(Track *);
|
|
};
|
|
|
|
|
|
class Set : public Playlist {
|
|
public:
|
|
Set(unsigned int);
|
|
Set(string, unsigned int);
|
|
~Set();
|
|
|
|
Track *next();
|
|
void do_add_tracks(list<Track *> &);
|
|
};
|
|
|
|
|
|
class Queue : public Playlist {
|
|
public:
|
|
Queue(unsigned int);
|
|
Queue(string, unsigned int);
|
|
~Queue();
|
|
|
|
Track *next();
|
|
void do_add_tracks(list<Track *> &);
|
|
};
|
|
|
|
|
|
class Stack : public Playlist {
|
|
public:
|
|
Stack(unsigned int);
|
|
Stack(string, unsigned int);
|
|
~Stack();
|
|
|
|
Track *next();
|
|
void do_add_tracks(list<Track *> &);
|
|
};
|
|
|
|
|
|
struct PlaylistNotification {
|
|
Playlist *plist;
|
|
Track *track;
|
|
unsigned int index;
|
|
};
|
|
|
|
}; /* Namespace: libsaria */
|
|
|
|
#endif /* LIBSARIA_PLAYLIST_H */
|