1 /***************************************************************************
2 * Copyright (C) 2008-2017 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_H
22 #define NCMPCPP_SONG_H
30 #include <mpd/client.h>
37 size_t operator()(const Song
&s
) const { return s
.m_hash
; }
40 typedef std::string (Song::*GetFunction
)(unsigned) const;
42 Song() : m_hash(0) { }
47 Song(const Song
&rhs
) : m_song(rhs
.m_song
), m_hash(rhs
.m_hash
) { }
48 Song(Song
&&rhs
) : m_song(std::move(rhs
.m_song
)), m_hash(rhs
.m_hash
) { }
49 Song
&operator=(Song rhs
)
51 m_song
= std::move(rhs
.m_song
);
56 std::string
get(mpd_tag_type type
, unsigned idx
= 0) const;
58 virtual std::string
getURI(unsigned idx
= 0) const;
59 virtual std::string
getName(unsigned idx
= 0) const;
60 virtual std::string
getDirectory(unsigned idx
= 0) const;
61 virtual std::string
getArtist(unsigned idx
= 0) const;
62 virtual std::string
getTitle(unsigned idx
= 0) const;
63 virtual std::string
getAlbum(unsigned idx
= 0) const;
64 virtual std::string
getAlbumArtist(unsigned idx
= 0) const;
65 virtual std::string
getTrack(unsigned idx
= 0) const;
66 virtual std::string
getTrackNumber(unsigned idx
= 0) const;
67 virtual std::string
getDate(unsigned idx
= 0) const;
68 virtual std::string
getGenre(unsigned idx
= 0) const;
69 virtual std::string
getComposer(unsigned idx
= 0) const;
70 virtual std::string
getPerformer(unsigned idx
= 0) const;
71 virtual std::string
getDisc(unsigned idx
= 0) const;
72 virtual std::string
getComment(unsigned idx
= 0) const;
73 virtual std::string
getLength(unsigned idx
= 0) const;
74 virtual std::string
getPriority(unsigned idx
= 0) const;
76 virtual std::string
getTags(GetFunction f
) const;
78 virtual unsigned getDuration() const;
79 virtual unsigned getPosition() const;
80 virtual unsigned getID() const;
81 virtual unsigned getPrio() const;
82 virtual time_t getMTime() const;
84 virtual bool isFromDatabase() const;
85 virtual bool isStream() const;
87 virtual bool empty() const;
89 bool operator==(const Song
&rhs
) const
91 if (m_hash
!= rhs
.m_hash
)
93 return strcmp(c_uri(), rhs
.c_uri()) == 0;
95 bool operator!=(const Song
&rhs
) const
97 return !(operator==(rhs
));
100 const char *c_uri() const { return m_song
? mpd_song_get_uri(m_song
.get()) : ""; }
102 static std::string
ShowTime(unsigned length
);
104 static std::string TagsSeparator
;
106 static bool ShowDuplicateTags
;
109 std::shared_ptr
<mpd_song
> m_song
;
115 #endif // NCMPCPP_SONG_H