Music Hub  ..
A session-wide music playback service
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Friends
track.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 COM_UBUNTU_MUSIC_TRACK_H_
19 #define COM_UBUNTU_MUSIC_TRACK_H_
20 
22 
23 #include <functional>
24 #include <memory>
25 #include <string>
26 
27 namespace com
28 {
29 namespace ubuntu
30 {
31 namespace music
32 {
33 class Track
34 {
35 public:
36  typedef std::string UriType;
37 
38  class MetaData
39  {
40  public:
41  typedef std::string KeyType;
42  typedef std::string ValueType;
43 
44  static const KeyType& track_id_key();
45 
46  ~MetaData();
47  MetaData(const MetaData&);
48  MetaData& operator=(const MetaData&);
49  bool operator==(const MetaData&) const;
50 
51  bool has_value_for_key(const KeyType& key) const;
52  const ValueType& value_for_key(const KeyType& key) const;
53 
54  void for_each(const std::function<void(const KeyType&, const ValueType&)>& f);
55 
56  private:
57  friend class Player;
58  friend class Track;
59 
60  MetaData();
61 
62  struct Private;
63  std::unique_ptr<Private> d;
64  };
65 
66  Track(const Track&);
67  ~Track();
68 
69  Track& operator=(const Track&);
70  bool operator==(const Track&) const;
71 
72  const UriType& uri() const;
73 
74  const MetaData& meta_data() const;
75  Connection on_meta_data_changed(const std::function<void(const MetaData&)>& f);
76 
77  private:
78  explicit Track(const UriType& uri, const MetaData& meta_data);
79 
80  struct Private;
81  std::unique_ptr<Private> d;
82 };
83 }
84 }
85 }
86 
87 #endif // COM_UBUNTU_MUSIC_TRACK_H_