[filesystem][SpecialProtocol] Removed assert from GetPath
[xbmc.git] / xbmc / music / Song.h
blob3fc127a60f427cfa8601c8911489fd310e8964c5
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 /*!
12 \file Song.h
13 \brief
16 #include "Artist.h"
17 #include "XBDateTime.h"
18 #include "music/tags/ReplayGain.h"
19 #include "utils/EmbeddedArt.h"
20 #include "utils/ISerializable.h"
22 #include <map>
23 #include <string>
24 #include <vector>
26 class CVariant;
28 /*!
29 \ingroup music
30 \brief Class to store and read album information from CMusicDatabase
31 \sa CSong, CMusicDatabase
34 class CGenre
36 public:
37 int idGenre;
38 std::string strGenre;
41 class CFileItem;
43 /*!
44 \ingroup music
45 \brief Class to store and read song information from CMusicDatabase
46 \sa CAlbum, CMusicDatabase
48 class CSong final : public ISerializable
50 public:
51 CSong() ;
52 explicit CSong(CFileItem& item);
53 void Clear() ;
54 void MergeScrapedSong(const CSong& source, bool override);
55 void Serialize(CVariant& value) const override;
57 bool operator<(const CSong &song) const
59 if (strFileName < song.strFileName) return true;
60 if (strFileName > song.strFileName) return false;
61 if (iTrack < song.iTrack) return true;
62 return false;
65 /*! \brief Get artist names from the vector of artistcredits objects
66 \return artist names as a vector of strings
68 const std::vector<std::string> GetArtist() const;
70 /*! \brief Get artist sort name string
71 \return artist sort name as a single string
73 const std::string GetArtistSort() const;
75 /*! \brief Get artist MusicBrainz IDs from the vector of artistcredits objects
76 \return artist MusicBrainz IDs as a vector of strings
78 const std::vector<std::string> GetMusicBrainzArtistID() const;
80 /*! \brief Get artist names from the artist description string (if it exists)
81 or concatenated from the vector of artistcredits objects
82 \return artist names as a single string
84 const std::string GetArtistString() const;
86 /*! \brief Get song artist IDs (for json rpc) from the vector of artistcredits objects
87 \return album artist IDs as a vector of integers
89 const std::vector<int> GetArtistIDArray() const;
91 /*! \brief Get album artist names associated with song from tag data
92 Note for initial album processing only, normalised album artist data belongs to album
93 and is stored in album artist credits
94 \return album artist names as a vector of strings
96 const std::vector<std::string> GetAlbumArtist() const { return m_albumArtist; }
98 /*! \brief Get album artist sort name string
99 \return album artist sort name as a single string
101 const std::string GetAlbumArtistSort() const { return m_strAlbumArtistSort; }
103 /*! \brief Get disc subtitle string where one exists
104 \return disc subtitle as a single string
106 const std::string GetDiscSubtitle() const;
108 /*! \brief Get composer sort name string
109 \return composer sort name as a single string
111 const std::string GetComposerSort() const { return m_strComposerSort; }
113 /*! \brief Get the full list of artist names and the role each played for those
114 that contributed to the recording. Given in music file tags other than ARTIST
115 or ALBUMARTIST, e.g. COMPOSER or CONDUCTOR etc.
116 \return a vector of all contributing artist names and their roles
118 const VECMUSICROLES& GetContributors() const { return m_musicRoles; }
119 //void AddArtistRole(const int &role, const std::string &artist);
120 void AppendArtistRole(const CMusicRole& musicRole);
122 /*! \brief Set album artist vector.
123 Album artist is held local to song until album created for initial processing only.
124 Normalised album artist data belongs to album and is stored in album artist credits
125 \param album artist names as a vector of strings
127 void SetAlbumArtist(const std::vector<std::string>& albumartists) { m_albumArtist = albumartists; }
129 /*! \brief Whether this song has any artists in artist credits vector
130 Tests if artist credits has been populated yet, during processing there can be
131 artists in the artist description but not yet in the credits
133 bool HasArtistCredits() const { return !artistCredits.empty(); }
135 /*! \brief Whether this song has any artists in music roles (contributors) vector
136 Tests if contributors has been populated yet, there may be none.
138 bool HasContributors() const { return !m_musicRoles.empty(); }
140 /*! \brief whether this song has art associated with it
141 Tests both the strThumb and embeddedArt members.
143 bool HasArt() const;
145 /*! \brief whether the art from this song matches the art from another
146 Tests both the strThumb and embeddedArt members.
148 bool ArtMatches(const CSong &right) const;
150 /*! \brief Set artist credits using the arrays of tag values.
151 If strArtistSort (as from ARTISTSORT tag) is already set then individual
152 artist sort names are also processed.
153 \param names String vector of artist names (as from ARTIST tag)
154 \param hints String vector of artist name hints (as from ARTISTS tag)
155 \param mbids String vector of artist Musicbrainz IDs (as from MUSICBRAINZARTISTID tag)
157 void SetArtistCredits(const std::vector<std::string>& names, const std::vector<std::string>& hints,
158 const std::vector<std::string>& mbids);
160 int idSong;
161 int idAlbum;
162 std::string strFileName;
163 std::string strTitle;
164 std::string strArtistSort;
165 std::string strArtistDesc;
166 VECARTISTCREDITS artistCredits;
167 std::string strAlbum;
168 std::vector<std::string> genre;
169 std::string strThumb;
170 EmbeddedArtInfo embeddedArt;
171 std::string strMusicBrainzTrackID;
172 std::string strComment;
173 std::string strMood;
174 std::string strCueSheet;
175 float rating;
176 int userrating;
177 int votes;
178 int iTrack;
179 int iDuration;
180 std::string strOrigReleaseDate;
181 std::string strReleaseDate;
182 std::string strDiscSubtitle;
183 int iTimesPlayed;
184 CDateTime lastPlayed;
185 CDateTime dateAdded; // File creation or modification time, or when tags (re-)scanned
186 CDateTime dateUpdated; // Time db record Last modified
187 CDateTime dateNew; // Time db record created
188 int iStartOffset;
189 int iEndOffset;
190 bool bCompilation;
191 int iBPM;
192 int iSampleRate;
193 int iBitRate;
194 int iChannels;
195 std::string strRecordLabel; // Record label from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
196 std::string strAlbumType; // (Musicbrainz release type) album type from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
198 ReplayGain replayGain;
199 private:
200 std::vector<std::string> m_albumArtist; // Album artist from tag for album processing, no desc or MBID
201 std::string m_strAlbumArtistSort; // Albumartist sort string from tag for album processing by CMusicInfoScanner::FileItemsToAlbums
202 std::string m_strComposerSort;
203 VECMUSICROLES m_musicRoles;
207 \ingroup music
208 \brief A vector of CSong objects, used for CMusicDatabase
209 \sa CMusicDatabase
211 typedef std::vector<CSong> VECSONGS;
214 \ingroup music
215 \brief A map of a vector of CSong objects key by filename, used for CMusicDatabase
217 typedef std::map<std::string, VECSONGS> MAPSONGS;
220 \ingroup music
221 \brief A vector of std::string objects, used for CMusicDatabase
222 \sa CMusicDatabase
224 typedef std::vector<CGenre> VECGENRES;