libsaria: Implement playlist iterators
I replace the old queue iterator functions with calls to the queue playlist object that way I don't need to modify the UI. This creates a common iterator that can be used by all playlists. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
356f6c0465
commit
6866200e42
|
@ -15,6 +15,7 @@ namespace libsaria
|
|||
private:
|
||||
string filename;
|
||||
list<sid_t> plist;
|
||||
list<sid_t>::iterator it;
|
||||
|
||||
public:
|
||||
Playlist(string);
|
||||
|
@ -22,6 +23,11 @@ namespace libsaria
|
|||
|
||||
void load();
|
||||
void add_ids(list<sid_t> &);
|
||||
|
||||
/* Iterator functions */
|
||||
void iter_reset();
|
||||
Track *iter_next();
|
||||
bool iter_end();
|
||||
};
|
||||
|
||||
}; /* Namespace: libsaria */
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker.
|
||||
|
||||
#include <libsaria/library.h>
|
||||
#include <libsaria/playlist.h>
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
||||
void Playlist::iter_reset()
|
||||
{
|
||||
it = plist.begin();
|
||||
}
|
||||
|
||||
Track *Playlist::iter_next()
|
||||
{
|
||||
Track *track = library::get_info(*it);
|
||||
it++;
|
||||
return track;
|
||||
}
|
||||
|
||||
bool Playlist::iter_end()
|
||||
{
|
||||
return it == plist.end();
|
||||
}
|
||||
|
||||
}; /* Namespace: libsaria */
|
|
@ -12,19 +12,17 @@ namespace libsaria
|
|||
|
||||
void iter::reset()
|
||||
{
|
||||
it = playqueue.begin();
|
||||
q_queue.iter_reset();
|
||||
}
|
||||
|
||||
libsaria::Track *iter::next()
|
||||
{
|
||||
Track *track = library::get_info(*it);
|
||||
it++;
|
||||
return track;
|
||||
return q_queue.iter_next();
|
||||
}
|
||||
|
||||
bool iter::end()
|
||||
{
|
||||
return it == playqueue.end();
|
||||
return q_queue.iter_end();
|
||||
}
|
||||
|
||||
}; /* Namespace: queue */
|
||||
|
|
Loading…
Reference in New Issue