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 
32 namespace core
33 {
34 namespace ubuntu
35 {
36 namespace media
37 {
38 class Player;
39 
40 class TrackList : public std::enable_shared_from_this<TrackList>
41 {
42  public:
43  typedef std::vector<Track::Id> Container;
44  typedef std::tuple<std::vector<Track::Id>, Track::Id> ContainerTrackIdTuple;
45  typedef Container::iterator Iterator;
46  typedef Container::const_iterator ConstIterator;
47 
48  static const Track::Id& after_empty_track();
49 
50  TrackList(const TrackList&) = delete;
51  ~TrackList();
52 
53  TrackList& operator=(const TrackList&) = delete;
54  bool operator==(const TrackList&) const = delete;
55 
57  virtual const core::Property<bool>& can_edit_tracks() const = 0;
58 
60  virtual const core::Property<Container>& tracks() const = 0;
61 
64 
66  virtual Track::UriType query_uri_for_track(const Track::Id& id) = 0;
67 
69  virtual void add_track_with_uri_at(const Track::UriType& uri, const Track::Id& position, bool make_current) = 0;
70 
72  virtual void remove_track(const Track::Id& id) = 0;
73 
75  virtual void go_to(const Track::Id& track, bool toggle_player_state) = 0;
76 
78  bool has_next() const;
79 
81  bool has_previous() const;
82 
84  virtual Track::Id next() = 0;
85 
87  virtual Track::Id previous() = 0;
88 
89 
91  virtual void shuffle_tracks() = 0;
92 
94  virtual void unshuffle_tracks() = 0;
95 
97  virtual void reset() = 0;
98 
99 
101  virtual const core::Signal<ContainerTrackIdTuple>& on_track_list_replaced() const = 0;
102 
104  virtual const core::Signal<Track::Id>& on_track_added() const = 0;
105 
107  virtual const core::Signal<Track::Id>& on_track_removed() const = 0;
108 
110  virtual const core::Signal<Track::Id>& on_track_changed() const = 0;
111 
113  virtual const core::Signal<std::pair<Track::Id, bool>>& on_go_to_track() const = 0;
114 
116  virtual const core::Signal<void>& on_end_of_tracklist() const = 0;
117 
118 protected:
119  TrackList();
120 };
121 
122 }
123 }
124 }
125 
126 #endif // CORE_UBUNTU_MEDIA_TRACK_LIST_H_
virtual const core::Property< Container > & tracks() const =0
virtual const core::Signal< Track::Id > & on_track_changed() const =0
bool operator==(const TrackList &) const =delete
virtual Track::MetaData query_meta_data_for_track(const Track::Id &id)=0
virtual void go_to(const Track::Id &track, bool toggle_player_state)=0
Definition: player.h:33
virtual const core::Signal< std::pair< Track::Id, bool > > & on_go_to_track() const =0
virtual const core::Signal< Track::Id > & on_track_added() const =0
virtual const core::Signal< Track::Id > & on_track_removed() const =0
virtual Track::Id next()=0
std::tuple< std::vector< Track::Id >, Track::Id > ContainerTrackIdTuple
Definition: track_list.h:44
virtual const core::Signal< void > & on_end_of_tracklist() const =0
virtual const core::Signal< ContainerTrackIdTuple > & on_track_list_replaced() const =0
virtual void unshuffle_tracks()=0
virtual void remove_track(const Track::Id &id)=0
Container::iterator Iterator
Definition: track_list.h:45
virtual Track::UriType query_uri_for_track(const Track::Id &id)=0
virtual void add_track_with_uri_at(const Track::UriType &uri, const Track::Id &position, bool make_current)=0
TrackList & operator=(const TrackList &)=delete
std::string UriType
Definition: track.h:40
std::vector< Track::Id > Container
Definition: track_list.h:43
virtual void shuffle_tracks()=0
static const Track::Id & after_empty_track()
Definition: track_list.cpp:23
virtual const core::Property< bool > & can_edit_tracks() const =0
Container::const_iterator ConstIterator
Definition: track_list.h:46
virtual Track::Id previous()=0