/* * Copyright 2013 (c) Anna Schumaker. */ #ifndef OCARINA_QUEUE_H #define OCARINA_QUEUE_H #include #include #include #include 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 _tracks; std :: list _sort_order; unsigned int _cur; unsigned int _flags; unsigned int _length; unsigned int find_sorted_id(Track *); void _add_sort(sort_t, bool); public: Queue(); Queue(unsigned int); ~Queue(); void write(File &); void read(File &); void set_flag(queue_flags); void unset_flag(queue_flags); bool has_flag(queue_flags); std::string get_length_str(); unsigned int add(Track *); unsigned int add_front(unsigned int); void del(unsigned int); void del_track(unsigned int); void track_updated(unsigned int); unsigned int size(); void add_sort(sort_t, bool ascending = true); void reset_sort(sort_t, bool ascending = true); void force_clear_sort(); std::list &get_sort_order(); Track *operator[](unsigned int); Track *next(); void set_cur(unsigned int); void path_selected(unsigned int); #ifdef CONFIG_TEST void reset(); #endif /* CONFIG_TEST */ }; #endif /* OCARINA_QUEUE_H */