1 /***************************************************************************
2 * Copyright (C) 2008-2014 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #ifndef NCMPCPP_SONG_LIST_H
22 #define NCMPCPP_SONG_LIST_H
24 #include <boost/range/detail/any_iterator.hpp>
25 #include <boost/tuple/tuple.hpp>
29 template <typename ValueT
>
30 using SongIteratorT
= boost::range_detail::any_iterator
<
32 boost::random_access_traversal_tag
,
33 const ValueT
, // const needed, see https://svn.boost.org/trac/boost/ticket/10493
37 typedef SongIteratorT
<boost::tuple
<NC::List::Properties
&, MPD::Song
*>> SongIterator
;
38 typedef SongIteratorT
<boost::tuple
<const NC::List::Properties
&, const MPD::Song
*>> ConstSongIterator
;
41 const size_t Properties
= 0;
42 const size_t Song
= 1;
47 virtual SongIterator
currentS() = 0;
48 virtual ConstSongIterator
currentS() const = 0;
49 virtual SongIterator
beginS() = 0;
50 virtual ConstSongIterator
beginS() const = 0;
51 virtual SongIterator
endS() = 0;
52 virtual ConstSongIterator
endS() const = 0;
54 virtual std::vector
<MPD::Song
> getSelectedSongs() = 0;
57 inline SongIterator
begin(SongList
&list
) { return list
.beginS(); }
58 inline ConstSongIterator
begin(const SongList
&list
) { return list
.beginS(); }
59 inline SongIterator
end(SongList
&list
) { return list
.endS(); }
60 inline ConstSongIterator
end(const SongList
&list
) { return list
.endS(); }
62 struct SongMenu
: NC::Menu
<MPD::Song
>, SongList
65 SongMenu(NC::Menu
<MPD::Song
> &&base
)
66 : NC::Menu
<MPD::Song
>(std::move(base
)) { }
68 virtual SongIterator
currentS() OVERRIDE
;
69 virtual ConstSongIterator
currentS() const OVERRIDE
;
70 virtual SongIterator
beginS() OVERRIDE
;
71 virtual ConstSongIterator
beginS() const OVERRIDE
;
72 virtual SongIterator
endS() OVERRIDE
;
73 virtual ConstSongIterator
endS() const OVERRIDE
;
75 virtual std::vector
<MPD::Song
> getSelectedSongs() OVERRIDE
;
78 #endif // NCMPCPP_SONG_LIST_H