ocarina/include/core/queue.h

67 lines
1.3 KiB
C++

/*
* Copyright 2013 (c) Anna Schumaker.
*/
#ifndef OCARINA_QUEUE_H
#define OCARINA_QUEUE_H
#include <core/file.h>
#include <core/tags.h>
#include <vector>
#include <list>
enum queue_flags {
Q_ENABLED = (1 << 0),
Q_RANDOM = (1 << 1),
Q_REPEAT = (1 << 2),
Q_NO_SORT = (1 << 3),
Q_DISABLE_CHANGED_SIZE = (1 << 31),
};
static const unsigned int Q_FLAG_MASK = Q_ENABLED | Q_RANDOM | Q_REPEAT | Q_NO_SORT | Q_DISABLE_CHANGED_SIZE;
struct sort_info {
sort_t field;
bool ascending;
};
class Queue {
protected:
std :: vector <Track *> _tracks;
std :: vector <struct sort_info> _sort_order;
unsigned int _cur;
unsigned int _flags;
unsigned int _length;
unsigned int find_sorted_id(Track *);
unsigned int _add_at(Track *, unsigned int);
void _del_at(Track *, unsigned int);
public:
Queue();
Queue(unsigned int);
~Queue();
void write(File &);
void read(File &);
virtual void set_flag(queue_flags);
virtual void unset_flag(queue_flags);
bool has_flag(queue_flags);
virtual unsigned int add(Track *);
virtual void del(Track *);
virtual void del(unsigned int);
void updated(Track *);
Track *next();
unsigned int size();
const std::string size_str();
const std::string length_str();
virtual void sort(sort_t, bool);
Track *operator[](unsigned int);
void track_selected(unsigned int);
};
#endif /* OCARINA_QUEUE_H */