actions: use unique_ptr for storing actions
[ncmpcpp.git] / src / song_list.h
blob3b8a0b938a7d1f39ec473e1c30ec215be1fd2b42
1 /***************************************************************************
2 * Copyright (C) 2008-2016 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
4 * *
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. *
9 * *
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. *
14 * *
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>
26 #include "menu.h"
27 #include "song.h"
29 template <typename ValueT>
30 using SongIteratorT = boost::range_detail::any_iterator<
31 ValueT,
32 boost::random_access_traversal_tag,
33 const ValueT, // const needed, see https://svn.boost.org/trac/boost/ticket/10493
34 std::ptrdiff_t
37 typedef SongIteratorT<boost::tuple<NC::List::Properties &, MPD::Song *>> SongIterator;
38 typedef SongIteratorT<boost::tuple<const NC::List::Properties &, const MPD::Song *>> ConstSongIterator;
40 namespace Bit {
41 const size_t Properties = 0;
42 const size_t Song = 1;
45 struct SongList
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
64 SongMenu() { }
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