2014-09-13 10:26:17 -04:00
|
|
|
/**
|
2013-12-22 22:21:19 -05:00
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
2014-06-21 09:37:47 -04:00
|
|
|
#ifndef OCARINA_CORE_DECK_H
|
|
|
|
#define OCARINA_CORE_DECK_H
|
2013-12-22 22:21:19 -05:00
|
|
|
|
2015-12-02 10:22:11 -05:00
|
|
|
extern "C" {
|
2014-06-05 10:19:22 -04:00
|
|
|
#include <core/queue.h>
|
2015-12-02 10:22:11 -05:00
|
|
|
}
|
2014-05-26 22:20:07 -04:00
|
|
|
#include <list>
|
2013-12-22 22:21:19 -05:00
|
|
|
|
2014-05-31 09:09:44 -04:00
|
|
|
|
2014-12-12 08:25:31 -05:00
|
|
|
/**
|
|
|
|
* A TempQueue is a wrapper around the Queue class that
|
|
|
|
* allows us to save the list of queues when necessary.
|
|
|
|
*/
|
2015-11-16 09:12:15 -05:00
|
|
|
class TempQueue : public queue
|
2014-05-31 09:09:44 -04:00
|
|
|
{
|
|
|
|
public:
|
2015-11-29 17:34:21 -05:00
|
|
|
void read(file &);
|
|
|
|
void write(file &);
|
|
|
|
|
2015-10-24 19:34:45 -04:00
|
|
|
unsigned int add(struct track *);
|
|
|
|
void del(struct track *);
|
2014-05-31 09:09:44 -04:00
|
|
|
void del(unsigned int);
|
|
|
|
};
|
|
|
|
|
2014-12-12 08:25:31 -05:00
|
|
|
|
2014-09-13 10:26:17 -04:00
|
|
|
/**
|
2014-12-12 08:25:31 -05:00
|
|
|
* The deck is used to hold temporary queues created by the user. This
|
|
|
|
* code is also in charge of maintaining a "recently played" queue of
|
|
|
|
* songs that have just played.
|
|
|
|
*
|
|
|
|
* When saving to disk:
|
|
|
|
* ... << deck.size() << endl;
|
|
|
|
* ... << deck[0] << endl;
|
|
|
|
* ...
|
|
|
|
* ... << deck[N] <<< endl;
|
2014-09-13 10:26:17 -04:00
|
|
|
*/
|
2013-12-22 22:21:19 -05:00
|
|
|
namespace deck
|
|
|
|
{
|
|
|
|
|
2014-09-13 10:26:17 -04:00
|
|
|
/**
|
|
|
|
* Save the current queues to a file on disk.
|
|
|
|
*/
|
2014-01-24 21:43:18 -05:00
|
|
|
void write();
|
2015-11-24 09:08:20 -05:00
|
|
|
void save(struct queue *, enum queue_flags);
|
2013-12-23 10:37:22 -05:00
|
|
|
|
2014-09-13 10:26:17 -04:00
|
|
|
/**
|
2014-12-12 08:25:31 -05:00
|
|
|
* Move the queue to a new location in the deck.
|
2014-09-13 10:26:17 -04:00
|
|
|
*
|
|
|
|
* @param queue The queue to be moved.
|
|
|
|
* @param index The new index of the queue.
|
|
|
|
*/
|
2015-11-16 09:12:15 -05:00
|
|
|
void move(queue *, unsigned int);
|
2014-06-05 11:04:55 -04:00
|
|
|
|
2014-09-13 10:26:17 -04:00
|
|
|
/**
|
|
|
|
* Access the queue at the specified index.
|
|
|
|
*
|
|
|
|
* @param index The index of the queue that should be accessed.
|
|
|
|
* @return The queue at the requested index.
|
|
|
|
*/
|
2015-11-16 09:12:15 -05:00
|
|
|
queue *get(unsigned int);
|
2014-05-26 22:20:07 -04:00
|
|
|
|
2014-09-13 10:26:17 -04:00
|
|
|
/**
|
|
|
|
* @return A track from the first enabled queue. If no queues are
|
|
|
|
* enabled, return a track from the Library.
|
|
|
|
*/
|
2015-10-24 19:34:45 -04:00
|
|
|
struct track *next();
|
2014-09-13 10:26:17 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return The deck of queues.
|
|
|
|
*/
|
2014-05-31 09:09:44 -04:00
|
|
|
std::list<TempQueue> &get_queues();
|
2014-09-13 10:26:17 -04:00
|
|
|
|
2013-12-22 22:21:19 -05:00
|
|
|
};
|
|
|
|
|
2015-12-13 09:27:52 -05:00
|
|
|
|
|
|
|
/* Called to initialize the temporary queue manager. */
|
|
|
|
void tempq_init(struct queue_ops *);
|
|
|
|
|
2015-12-14 09:05:54 -05:00
|
|
|
|
|
|
|
/* Called to allocate a new temporary queue. */
|
|
|
|
struct queue *tempq_alloc(struct queue_ops *, unsigned int);
|
|
|
|
|
2015-12-14 09:26:58 -05:00
|
|
|
/* Called to free a temporary queue. */
|
|
|
|
void tempq_free(struct queue *);
|
|
|
|
|
2014-06-21 09:37:47 -04:00
|
|
|
#endif /* OCARINA_CORE_DECK_H */
|