queue/Queue: add method GetLight()
This commit is contained in:
parent
ec961f26e9
commit
c68dbc4e5c
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "Queue.hxx"
|
#include "Queue.hxx"
|
||||||
#include "song/DetachedSong.hxx"
|
#include "song/DetachedSong.hxx"
|
||||||
|
#include "song/LightSong.hxx"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -38,6 +39,15 @@ Queue::~Queue() noexcept
|
||||||
delete[] order;
|
delete[] order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LightSong
|
||||||
|
Queue::GetLight(unsigned position) const noexcept
|
||||||
|
{
|
||||||
|
assert(position < length);
|
||||||
|
|
||||||
|
LightSong song{Get(position)};
|
||||||
|
return song;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Queue::GetNextOrder(unsigned _order) const noexcept
|
Queue::GetNextOrder(unsigned _order) const noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
struct LightSong;
|
||||||
class DetachedSong;
|
class DetachedSong;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,6 +201,11 @@ struct Queue {
|
||||||
return *items[position].song;
|
return *items[position].song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like Get(), but return a #LightSong instance.
|
||||||
|
*/
|
||||||
|
LightSong GetLight(unsigned position) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the song at the specified order number.
|
* Returns the song at the specified order number.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -28,7 +28,7 @@ QueueSelection::MatchPosition(const Queue &queue,
|
||||||
unsigned position) const noexcept
|
unsigned position) const noexcept
|
||||||
{
|
{
|
||||||
if (filter != nullptr) {
|
if (filter != nullptr) {
|
||||||
const LightSong song{queue.Get(position)};
|
const auto song = queue.GetLight(position);
|
||||||
if (!filter->Match(song))
|
if (!filter->Match(song))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "queue/Queue.hxx"
|
#include "queue/Queue.hxx"
|
||||||
#include "song/DetachedSong.hxx"
|
#include "song/DetachedSong.hxx"
|
||||||
|
#include "song/LightSong.hxx"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
@ -8,6 +9,11 @@
|
||||||
Tag::Tag(const Tag &) noexcept {}
|
Tag::Tag(const Tag &) noexcept {}
|
||||||
void Tag::Clear() noexcept {}
|
void Tag::Clear() noexcept {}
|
||||||
|
|
||||||
|
DetachedSong::operator LightSong() const noexcept
|
||||||
|
{
|
||||||
|
return {uri.c_str(), tag};
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_descending_priority(const Queue *queue,
|
check_descending_priority(const Queue *queue,
|
||||||
unsigned start_order)
|
unsigned start_order)
|
||||||
|
|
Loading…
Reference in New Issue