2013-12-31 15:44:44 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
2014-04-01 20:28:19 -04:00
|
|
|
#ifndef OCARINA_QUEUE_H
|
|
|
|
#define OCARINA_QUEUE_H
|
2013-12-31 15:44:44 -05:00
|
|
|
|
|
|
|
#include <file.h>
|
2014-01-02 21:58:18 -05:00
|
|
|
#include <library.h>
|
2013-12-31 15:44:44 -05:00
|
|
|
#include <vector>
|
2014-01-26 12:12:01 -05:00
|
|
|
#include <list>
|
2013-12-31 15:44:44 -05:00
|
|
|
|
2014-04-01 20:28:19 -04:00
|
|
|
enum queue_flags {
|
|
|
|
Q_ENABLED = (1 << 0),
|
|
|
|
Q_RANDOM = (1 << 1),
|
|
|
|
Q_REPEAT = (1 << 2),
|
2014-04-13 18:38:49 -04:00
|
|
|
Q_NO_SORT = (1 << 3),
|
2014-04-01 20:28:19 -04:00
|
|
|
Q_DISABLE_CHANGED_SIZE = (1 << 31),
|
2013-12-31 15:44:44 -05:00
|
|
|
};
|
|
|
|
|
2014-04-13 18:38:49 -04:00
|
|
|
static const unsigned int Q_FLAG_MASK = Q_ENABLED | Q_RANDOM | Q_REPEAT | Q_NO_SORT | Q_DISABLE_CHANGED_SIZE;
|
|
|
|
|
2014-01-26 14:44:56 -05:00
|
|
|
struct sort_info {
|
|
|
|
sort_t field;
|
|
|
|
bool ascending;
|
|
|
|
};
|
|
|
|
|
2014-04-01 20:28:19 -04:00
|
|
|
class Queue {
|
2014-04-13 12:26:32 -04:00
|
|
|
protected:
|
|
|
|
std :: vector <Track *> _tracks;
|
|
|
|
std :: list <sort_info> _sort_order;
|
|
|
|
unsigned int _cur;
|
|
|
|
unsigned int _flags;
|
|
|
|
unsigned int _length;
|
2013-12-31 15:44:44 -05:00
|
|
|
|
2014-03-29 11:44:39 -04:00
|
|
|
unsigned int find_sorted_id(Track *);
|
2014-01-29 21:37:06 -05:00
|
|
|
void _add_sort(sort_t, bool);
|
2014-01-25 14:43:51 -05:00
|
|
|
|
2013-12-31 15:44:44 -05:00
|
|
|
public:
|
2014-04-01 20:28:19 -04:00
|
|
|
Queue();
|
2014-04-13 18:38:49 -04:00
|
|
|
Queue(unsigned int);
|
2014-04-01 20:28:19 -04:00
|
|
|
~Queue();
|
2013-12-31 15:44:44 -05:00
|
|
|
void write(File &);
|
|
|
|
void read(File &);
|
|
|
|
|
2014-04-01 20:28:19 -04:00
|
|
|
void set_flag(queue_flags);
|
|
|
|
void unset_flag(queue_flags);
|
2014-04-13 12:26:32 -04:00
|
|
|
bool has_flag(queue_flags);
|
|
|
|
|
2014-01-22 21:17:51 -05:00
|
|
|
std::string get_length_str();
|
2013-12-31 15:44:44 -05:00
|
|
|
|
2014-05-11 10:40:54 -04:00
|
|
|
unsigned int add(Track *);
|
2014-01-02 21:58:18 -05:00
|
|
|
unsigned int add_front(unsigned int);
|
2013-12-31 15:44:44 -05:00
|
|
|
void del(unsigned int);
|
2014-01-16 22:05:36 -05:00
|
|
|
void del_track(unsigned int);
|
2014-01-29 22:45:01 -05:00
|
|
|
void track_updated(unsigned int);
|
2013-12-31 15:44:44 -05:00
|
|
|
unsigned int size();
|
|
|
|
|
2014-01-29 21:37:06 -05:00
|
|
|
void add_sort(sort_t, bool ascending = true);
|
|
|
|
void reset_sort(sort_t, bool ascending = true);
|
|
|
|
void force_clear_sort();
|
2014-01-26 14:44:56 -05:00
|
|
|
std::list <sort_info> &get_sort_order();
|
2014-01-26 12:12:01 -05:00
|
|
|
|
2014-04-13 12:26:32 -04:00
|
|
|
Track *operator[](unsigned int);
|
|
|
|
Track *next();
|
2014-01-29 22:11:03 -05:00
|
|
|
void set_cur(unsigned int);
|
2014-02-06 20:06:58 -05:00
|
|
|
void path_selected(unsigned int);
|
2014-01-22 19:34:01 -05:00
|
|
|
#ifdef CONFIG_TEST
|
|
|
|
void reset();
|
|
|
|
#endif /* CONFIG_TEST */
|
2013-12-31 15:44:44 -05:00
|
|
|
};
|
|
|
|
|
2014-04-01 20:28:19 -04:00
|
|
|
#endif /* OCARINA_QUEUE_H */
|