1 /***************************************************************************
2 * Copyright (C) 2008-2014 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_EDITABLE_SONG_H
22 #define NCMPCPP_EDITABLE_SONG_H
30 struct MutableSong
: public Song
32 typedef void (MutableSong::*SetFunction
)(const std::string
&, unsigned);
34 MutableSong() : m_mtime(0), m_duration(0) { }
35 MutableSong(Song s
) : Song(s
), m_mtime(0), m_duration(0) { }
37 virtual std::string
getArtist(unsigned idx
= 0) const OVERRIDE
;
38 virtual std::string
getTitle(unsigned idx
= 0) const OVERRIDE
;
39 virtual std::string
getAlbum(unsigned idx
= 0) const OVERRIDE
;
40 virtual std::string
getAlbumArtist(unsigned idx
= 0) const OVERRIDE
;
41 virtual std::string
getTrack(unsigned idx
= 0) const OVERRIDE
;
42 virtual std::string
getDate(unsigned idx
= 0) const OVERRIDE
;
43 virtual std::string
getGenre(unsigned idx
= 0) const OVERRIDE
;
44 virtual std::string
getComposer(unsigned idx
= 0) const OVERRIDE
;
45 virtual std::string
getPerformer(unsigned idx
= 0) const OVERRIDE
;
46 virtual std::string
getDisc(unsigned idx
= 0) const OVERRIDE
;
47 virtual std::string
getComment(unsigned idx
= 0) const OVERRIDE
;
49 void setArtist(const std::string
&value
, unsigned idx
= 0);
50 void setTitle(const std::string
&value
, unsigned idx
= 0);
51 void setAlbum(const std::string
&value
, unsigned idx
= 0);
52 void setAlbumArtist(const std::string
&value
, unsigned idx
= 0);
53 void setTrack(const std::string
&value
, unsigned idx
= 0);
54 void setDate(const std::string
&value
, unsigned idx
= 0);
55 void setGenre(const std::string
&value
, unsigned idx
= 0);
56 void setComposer(const std::string
&value
, unsigned idx
= 0);
57 void setPerformer(const std::string
&value
, unsigned idx
= 0);
58 void setDisc(const std::string
&value
, unsigned idx
= 0);
59 void setComment(const std::string
&value
, unsigned idx
= 0);
61 const std::string
&getNewName() const;
62 void setNewName(const std::string
&value
);
64 virtual unsigned getDuration() const OVERRIDE
;
65 virtual time_t getMTime() const OVERRIDE
;
66 void setDuration(unsigned duration
);
67 void setMTime(time_t mtime
);
69 void setTags(SetFunction set
, const std::string
&value
, const std::string
&delimiter
);
71 bool isModified() const;
72 void clearModifications();
77 Tag(mpd_tag_type type_
, unsigned idx_
) : m_type(type_
), m_idx(idx_
) { }
79 mpd_tag_type
type() const { return m_type
; }
80 unsigned idx() const { return m_idx
; }
82 bool operator<(const Tag
&t
) const
84 if (m_type
!= t
.m_type
)
85 return m_type
< t
.m_type
;
86 return m_idx
< t
.m_idx
;
94 void replaceTag(mpd_tag_type tag_type
, std::string orig_value
,
95 const std::string
&value
, unsigned idx
);
98 std::string
getTag(mpd_tag_type tag_type
, F orig_value
, unsigned idx
) const {
99 auto it
= m_tags
.find(Tag(tag_type
, idx
));
101 if (it
== m_tags
.end())
102 result
= orig_value();
111 std::map
<Tag
, std::string
> m_tags
;
116 #endif // NCMPCPP_EDITABLE_SONG_H