deck: Reintroduce deck :: get()
This function turned out to be really useful for the gui. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
eb777c04f1
commit
9e3399b619
4
DESIGN
4
DESIGN
|
@ -1273,6 +1273,10 @@ Deck:
|
||||||
Return the index of the queue in the deck or deck.size() if
|
Return the index of the queue in the deck or deck.size() if
|
||||||
the queue is not currently in the deck.
|
the queue is not currently in the deck.
|
||||||
|
|
||||||
|
Queue *deck :: get(unsigned int index);
|
||||||
|
Return the queue at the requested index, or NULL if no queue
|
||||||
|
is found.
|
||||||
|
|
||||||
Track *deck :: next();
|
Track *deck :: next();
|
||||||
Find the first enabled queue on the deck and return the track
|
Find the first enabled queue on the deck and return the track
|
||||||
given by queue->next().
|
given by queue->next().
|
||||||
|
|
|
@ -187,6 +187,18 @@ unsigned int deck :: index(Queue *queue)
|
||||||
return queue_deck.size();
|
return queue_deck.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Queue *deck :: get(unsigned int index)
|
||||||
|
{
|
||||||
|
std::list<TempQueue>::iterator it;
|
||||||
|
|
||||||
|
for (it = queue_deck.begin(); it != queue_deck.end(); it++) {
|
||||||
|
if (index == 0)
|
||||||
|
return &(*it);
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Track *deck :: next()
|
Track *deck :: next()
|
||||||
{
|
{
|
||||||
Track *track = NULL;
|
Track *track = NULL;
|
||||||
|
|
|
@ -33,7 +33,9 @@ namespace deck
|
||||||
Queue *create(bool);
|
Queue *create(bool);
|
||||||
void destroy(Queue *);
|
void destroy(Queue *);
|
||||||
void move(Queue *, unsigned int);
|
void move(Queue *, unsigned int);
|
||||||
|
|
||||||
unsigned int index(Queue *);
|
unsigned int index(Queue *);
|
||||||
|
Queue *get(unsigned int);
|
||||||
|
|
||||||
Track *next();
|
Track *next();
|
||||||
Track *prev();
|
Track *prev();
|
||||||
|
|
|
@ -74,12 +74,14 @@ static void test_create_mv_destroy()
|
||||||
test_equal(q1->has_flag(Q_ENABLED), true);
|
test_equal(q1->has_flag(Q_ENABLED), true);
|
||||||
test_equal(q1->has_flag(Q_RANDOM), true);
|
test_equal(q1->has_flag(Q_RANDOM), true);
|
||||||
test_equal(deck :: index(q1), (unsigned)2);
|
test_equal(deck :: index(q1), (unsigned)2);
|
||||||
|
test_equal(deck :: get(2), q1);
|
||||||
|
|
||||||
q2 = deck :: create(false);
|
q2 = deck :: create(false);
|
||||||
test_not_equal(q2, Q_NULL);
|
test_not_equal(q2, Q_NULL);
|
||||||
test_equal(q2->has_flag(Q_ENABLED), true);
|
test_equal(q2->has_flag(Q_ENABLED), true);
|
||||||
test_equal(q2->has_flag(Q_RANDOM), false);
|
test_equal(q2->has_flag(Q_RANDOM), false);
|
||||||
test_equal(deck :: index(q2), (unsigned)3);
|
test_equal(deck :: index(q2), (unsigned)3);
|
||||||
|
test_equal(deck :: get(3), q2);
|
||||||
|
|
||||||
deck :: move(q1, 3);
|
deck :: move(q1, 3);
|
||||||
test_equal(deck :: index(q1), (unsigned)3);
|
test_equal(deck :: index(q1), (unsigned)3);
|
||||||
|
@ -98,6 +100,8 @@ static void test_create_mv_destroy()
|
||||||
deck :: destroy(q2);
|
deck :: destroy(q2);
|
||||||
test_equal(n, (unsigned)2);
|
test_equal(n, (unsigned)2);
|
||||||
test_equal(deck :: index(q2), (unsigned)2);
|
test_equal(deck :: index(q2), (unsigned)2);
|
||||||
|
|
||||||
|
test_equal(deck :: get(3), Q_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_next_prev()
|
static void test_next_prev()
|
||||||
|
|
Loading…
Reference in New Issue