Music Hub ..
A session-wide music playback service
track_list.h
Go to the documentation of this file.
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18#ifndef CORE_UBUNTU_MEDIA_TRACK_LIST_H_
19#define CORE_UBUNTU_MEDIA_TRACK_LIST_H_
20
21#include <core/media/track.h>
22
23#include <core/property.h>
24#include <core/signal.h>
25
26#include <functional>
27#include <iosfwd>
28#include <memory>
29#include <string>
30#include <vector>
31
32namespace core
33{
34namespace ubuntu
35{
36namespace media
37{
38class Player;
39
40class TrackList : public std::enable_shared_from_this<TrackList>
41{
42 public:
43 typedef std::vector<Track::Id> Container;
44 typedef std::vector<Track::UriType> ContainerURI;
45 typedef std::tuple<std::vector<Track::Id>, Track::Id> ContainerTrackIdTuple;
46 typedef std::tuple<Track::Id, Track::Id> TrackIdTuple;
47 typedef Container::iterator Iterator;
48 typedef Container::const_iterator ConstIterator;
49
50 struct Errors
51 {
52 Errors() = delete;
53
54 struct InsufficientPermissionsToAddTrack : public std::runtime_error
55 {
57 };
58
59 struct FailedToMoveTrack : public std::runtime_error
60 {
62 };
63
64 struct FailedToFindMoveTrackSource : public std::runtime_error
65 {
66 FailedToFindMoveTrackSource(const std::string& err);
67 };
68
69 struct FailedToFindMoveTrackDest : public std::runtime_error
70 {
71 FailedToFindMoveTrackDest(const std::string& err);
72 };
73
74 struct TrackNotFound : public std::runtime_error
75 {
77 };
78 };
79
80 static const Track::Id& after_empty_track();
81
82 TrackList(const TrackList&) = delete;
83 ~TrackList();
84
85 TrackList& operator=(const TrackList&) = delete;
86 bool operator==(const TrackList&) const = delete;
87
89 virtual const core::Property<bool>& can_edit_tracks() const = 0;
90
92 virtual const core::Property<Container>& tracks() const = 0;
93
96
99
101 virtual void add_track_with_uri_at(const Track::UriType& uri, const Track::Id& position, bool make_current) = 0;
102
104 virtual void add_tracks_with_uri_at(const ContainerURI& uris, const Track::Id& position) = 0;
105
107 virtual bool move_track(const Track::Id& id, const Track::Id& to) = 0;
108
110 virtual void remove_track(const Track::Id& id) = 0;
111
113 virtual void go_to(const Track::Id& track) = 0;
114
116 bool has_next() const;
117
119 bool has_previous() const;
120
122 virtual Track::Id next() = 0;
123
125 virtual Track::Id previous() = 0;
126
128 virtual void reset() = 0;
129
131 virtual const core::Signal<ContainerTrackIdTuple>& on_track_list_replaced() const = 0;
132
134 virtual const core::Signal<Track::Id>& on_track_added() const = 0;
135
137 virtual const core::Signal<ContainerURI>& on_tracks_added() const = 0;
138
142 virtual const core::Signal<TrackIdTuple>& on_track_moved() const = 0;
143
145 virtual const core::Signal<Track::Id>& on_track_removed() const = 0;
146
148 virtual const core::Signal<void>& on_track_list_reset() const = 0;
149
151 virtual const core::Signal<Track::Id>& on_track_changed() const = 0;
152
154 virtual const core::Signal<Track::Id>& on_go_to_track() const = 0;
155
157 virtual const core::Signal<void>& on_end_of_tracklist() const = 0;
158
159protected:
160 TrackList();
161};
162
163}
164}
165}
166
167#endif // CORE_UBUNTU_MEDIA_TRACK_LIST_H_
TrackList(const TrackList &)=delete
virtual const core::Property< bool > & can_edit_tracks() const =0
virtual bool move_track(const Track::Id &id, const Track::Id &to)=0
virtual const core::Signal< void > & on_track_list_reset() const =0
std::tuple< Track::Id, Track::Id > TrackIdTuple
Definition: track_list.h:46
virtual const core::Signal< ContainerTrackIdTuple > & on_track_list_replaced() const =0
virtual const core::Signal< Track::Id > & on_track_changed() const =0
virtual const core::Signal< void > & on_end_of_tracklist() const =0
virtual Track::Id next()=0
virtual const core::Property< Container > & tracks() const =0
std::vector< Track::Id > Container
Definition: track_list.h:43
bool operator==(const TrackList &) const =delete
std::tuple< std::vector< Track::Id >, Track::Id > ContainerTrackIdTuple
Definition: track_list.h:45
virtual const core::Signal< Track::Id > & on_track_added() const =0
static const Track::Id & after_empty_track()
Definition: track_list.cpp:50
virtual void add_track_with_uri_at(const Track::UriType &uri, const Track::Id &position, bool make_current)=0
TrackList & operator=(const TrackList &)=delete
virtual Track::MetaData query_meta_data_for_track(const Track::Id &id)=0
virtual const core::Signal< TrackIdTuple > & on_track_moved() const =0
virtual Track::UriType query_uri_for_track(const Track::Id &id)=0
virtual void remove_track(const Track::Id &id)=0
virtual void add_tracks_with_uri_at(const ContainerURI &uris, const Track::Id &position)=0
Container::const_iterator ConstIterator
Definition: track_list.h:48
virtual const core::Signal< Track::Id > & on_track_removed() const =0
virtual void go_to(const Track::Id &track)=0
virtual const core::Signal< Track::Id > & on_go_to_track() const =0
virtual Track::Id previous()=0
Container::iterator Iterator
Definition: track_list.h:47
std::vector< Track::UriType > ContainerURI
Definition: track_list.h:44
virtual const core::Signal< ContainerURI > & on_tracks_added() const =0
std::string UriType
Definition: track.h:40
Definition: player.h:34