Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[musicdb] cosmetic: restructured MusicDatabase.h to be a bit clearer …

…and add some comments
  • Loading branch information...
commit 593bf80bf2a41d761b5ea542c510b31ced50a278 1 parent 0175bfd
night199uk night199uk authored
Showing with 139 additions and 65 deletions.
  1. +139 −65 xbmc/music/MusicDatabase.h
204 xbmc/music/MusicDatabase.h
View
@@ -102,63 +102,152 @@ class CMusicDatabase : public CDatabase
bool LookupCDDBInfo(bool bRequery=false);
void DeleteCDDBInfo();
+ /////////////////////////////////////////////////
+ // Song CRUD
+ /////////////////////////////////////////////////
/*! \brief Add an album and all its songs to the database
\param album the album to add
\param songIDs [out] the ids of the added songs
\return the id of the album
*/
- int AddAlbum(const CAlbum &album, std::vector<int> &songIDs);
+ int AddSong(const CSong& song, bool bCheck = true, int idAlbum = -1);
+ bool GetSongById(int idSong, CSong& song);
+ int UpdateSong(const CSong& song, int idSong = -1);
+ // bool DeleteSong(int idSong);
+
+ //// Misc Song
+ bool GetSongByFileName(const CStdString& strFileName, CSong& song, int startOffset = 0);
+ bool GetSongsByPath(const CStdString& strPath, MAPSONGS& songs, bool bAppendToMap = false);
+ bool Search(const CStdString& search, CFileItemList &items);
+ bool RemoveSongsFromPath(const CStdString &path, MAPSONGS& songs, bool exact=true);
+ bool SetSongRating(const CStdString &filePath, char rating);
+ int GetSongByArtistAndAlbumAndTitle(const CStdString& strArtist, const CStdString& strAlbum, const CStdString& strTitle);
+
+ /////////////////////////////////////////////////
+ // Album
+ /////////////////////////////////////////////////
+ /*! \brief Add an album and all its songs to the database
+ \param album the album to add
+ \param songIDs [out] the ids of the added songs
+ \return the id of the album
+ */
+ int AddAlbum(const CAlbum &album, std::vector<int> &songIDs);
+ int AddAlbum(const CStdString& strAlbum, const CStdString& strArtist, const CStdString& strGenre, int year, bool bCompilation);
+ bool GetAlbum(int idAlbum, CAlbum& album);
+ int UpdateAlbum(int idAlbum, const CAlbum &album);
+ bool DeleteAlbum(int idAlbum);
+
+ //// Misc Album
+ int GetAlbumIdByPath(const CStdString& path);
+ bool GetAlbumFromSong(int idSong, CAlbum &album);
+ bool GetAlbumFromSong(const CSong &song, CAlbum &album);
+ int GetAlbumByName(const CStdString& strAlbum, const CStdString& strArtist="");
+ int GetAlbumByName(const CStdString& strAlbum, const std::vector<std::string>& artist);
+ CStdString GetAlbumById(int id);
- int UpdateSong(const CSong& song, int idSong = -1);
+ /////////////////////////////////////////////////
+ // Artist CRUD
+ /////////////////////////////////////////////////
+ int AddArtist(const CStdString& strArtist);
+ bool GetArtist(int idArtist, CArtist& artist);
+ int UpdateArtist(int idArtist, const CArtist& artist);
+ bool DeleteArtist(int idArtist);
+
+ CStdString GetArtistById(int id);
+ int GetArtistByName(const CStdString& strArtist);
+
+ /////////////////////////////////////////////////
+ // Paths
+ /////////////////////////////////////////////////
+ int AddPath(const CStdString& strPath);
+
+ bool GetPaths(std::set<CStdString> &paths);
+ bool SetPathHash(const CStdString &path, const CStdString &hash);
+ bool GetPathHash(const CStdString &path, CStdString &hash);
+ bool GetAlbumPath(int idAlbum, CStdString &path);
+ bool GetArtistPath(int idArtist, CStdString &path);
+
+ /////////////////////////////////////////////////
+ // Genres
+ /////////////////////////////////////////////////
+ int AddGenre(const CStdString& strGenre);
+ CStdString GetGenreById(int id);
+ int GetGenreByName(const CStdString& strGenre);
+
+ /////////////////////////////////////////////////
+ // AlbumInfo
+ /////////////////////////////////////////////////
+ bool HasAlbumInfo(int idAlbum);
int SetAlbumInfo(int idAlbum, const CAlbum& album, const VECSONGS& songs, bool bTransaction=true);
- bool DeleteAlbumInfo(int idArtist);
- int SetArtistInfo(int idArtist, const CArtist& artist);
- bool DeleteArtistInfo(int idArtist);
bool GetAlbumInfo(int idAlbum, CAlbum &info, VECSONGS* songs, bool scrapedInfo = false);
- bool HasAlbumInfo(int idAlbum);
- bool GetArtistInfo(int idArtist, CArtist &info, bool needAll=true);
+ bool DeleteAlbumInfo(int idArtist);
+ bool SetAlbumInfoSongs(int idAlbumInfo, const VECSONGS& songs);
+ bool GetAlbumInfoSongs(int idAlbumInfo, VECSONGS& songs);
+ /////////////////////////////////////////////////
+ // ArtistInfo
+ /////////////////////////////////////////////////
/*! \brief Check if an artist entity has additional metadata (scraped)
\param idArtist the id of the Artist to check
\return true or false - whether the artist has metadata
*/
bool HasArtistInfo(int idArtist);
- bool GetSongByFileName(const CStdString& strFileName, CSong& song, int startOffset = 0);
- int GetAlbumIdByPath(const CStdString& path);
- bool GetSongById(int idSong, CSong& song);
- bool GetSongByKaraokeNumber( int number, CSong& song );
- bool SetKaraokeSongDelay( int idSong, int delay );
- bool GetSongsByPath(const CStdString& strPath, MAPSONGS& songs, bool bAppendToMap = false);
- bool Search(const CStdString& search, CFileItemList &items);
+ int SetArtistInfo(int idArtist, const CArtist& artist);
+ bool GetArtistInfo(int idArtist, CArtist &info, bool needAll=true);
+ bool DeleteArtistInfo(int idArtist);
- bool GetAlbumFromSong(int idSong, CAlbum &album);
- bool GetAlbumFromSong(const CSong &song, CAlbum &album);
-
+ /////////////////////////////////////////////////
+ // Link tables
+ /////////////////////////////////////////////////
+ bool AddAlbumArtist(int idArtist, int idAlbum, bool featured, int iOrder);
bool GetAlbumsByArtist(int idArtist, bool includeFeatured, std::vector<int>& albums);
bool GetArtistsByAlbum(int idAlbum, bool includeFeatured, std::vector<int>& artists);
+
+ bool AddSongArtist(int idArtist, int idSong, bool featured, int iOrder);
bool GetSongsByArtist(int idArtist, bool includeFeatured, std::vector<int>& songs);
bool GetArtistsBySong(int idSong, bool includeFeatured, std::vector<int>& artists);
- bool GetGenresByAlbum(int idAlbum, std::vector<int>& genres);
+ bool AddSongGenre(int idGenre, int idSong, int iOrder);
bool GetGenresBySong(int idSong, std::vector<int>& genres);
+ bool AddAlbumGenre(int idGenre, int idAlbum, int iOrder);
+ bool GetGenresByAlbum(int idAlbum, std::vector<int>& genres);
+
+ /////////////////////////////////////////////////
+ // Top 100
+ /////////////////////////////////////////////////
bool GetTop100(const CStdString& strBaseDir, CFileItemList& items);
bool GetTop100Albums(VECALBUMS& albums);
bool GetTop100AlbumSongs(const CStdString& strBaseDir, CFileItemList& item);
+
+ /////////////////////////////////////////////////
+ // Recently added
+ /////////////////////////////////////////////////
bool GetRecentlyAddedAlbums(VECALBUMS& albums, unsigned int limit=0);
bool GetRecentlyAddedAlbumSongs(const CStdString& strBaseDir, CFileItemList& item, unsigned int limit=0);
bool GetRecentlyPlayedAlbums(VECALBUMS& albums);
bool GetRecentlyPlayedAlbumSongs(const CStdString& strBaseDir, CFileItemList& item);
+
+ /////////////////////////////////////////////////
+ // Compilations
+ /////////////////////////////////////////////////
+ bool GetCompilationAlbums(const CStdString& strBaseDir, CFileItemList& items);
+ bool GetCompilationSongs(const CStdString& strBaseDir, CFileItemList& items);
+ int GetCompilationAlbumsCount();
+ bool GetVariousArtistsAlbums(const CStdString& strBaseDir, CFileItemList& items);
+ bool GetVariousArtistsAlbumsSongs(const CStdString& strBaseDir, CFileItemList& items);
+ int GetVariousArtistsAlbumsCount();
+
/*! \brief Increment the playcount of an item
Increments the playcount and updates the last played date
\param item CFileItem to increment the playcount for
*/
void IncrementPlayCount(const CFileItem &item);
- bool RemoveSongsFromPath(const CStdString &path, MAPSONGS& songs, bool exact=true);
bool CleanupOrphanedItems();
- bool GetPaths(std::set<CStdString> &paths);
- bool SetPathHash(const CStdString &path, const CStdString &hash);
- bool GetPathHash(const CStdString &path, CStdString &hash);
+
+ /////////////////////////////////////////////////
+ // VIEWS
+ /////////////////////////////////////////////////
bool GetGenresNav(const CStdString& strBaseDir, CFileItemList& items, const Filter &filter = Filter(), bool countOnly = false);
bool GetYearsNav(const CStdString& strBaseDir, CFileItemList& items, const Filter &filter = Filter());
bool GetArtistsNav(const CStdString& strBaseDir, CFileItemList& items, bool albumArtistsOnly = false, int idGenre = -1, int idAlbum = -1, int idSong = -1, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription(), bool countOnly = false);
@@ -173,56 +262,56 @@ class CMusicDatabase : public CDatabase
bool GetAlbumsByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription = SortDescription(), bool countOnly = false);
bool GetArtistsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription(), bool countOnly = false);
bool GetRandomSong(CFileItem* item, int& idSong, const Filter &filter);
- int GetKaraokeSongsCount();
int GetSongsCount(const Filter &filter = Filter());
unsigned int GetSongIDs(const Filter &filter, std::vector<std::pair<int,int> > &songIDs);
+ virtual bool GetFilter(CDbUrl &musicUrl, Filter &filter, SortDescription &sorting);
- bool GetAlbumPath(int idAlbum, CStdString &path);
- bool SaveAlbumThumb(int idAlbum, const CStdString &thumb);
- bool GetArtistPath(int idArtist, CStdString &path);
-
- CStdString GetGenreById(int id);
- CStdString GetArtistById(int id);
- CStdString GetAlbumById(int id);
-
- int GetArtistByName(const CStdString& strArtist);
- int GetAlbumByName(const CStdString& strAlbum, const CStdString& strArtist="");
- int GetAlbumByName(const CStdString& strAlbum, const std::vector<std::string>& artist);
- int GetGenreByName(const CStdString& strGenre);
- int GetSongByArtistAndAlbumAndTitle(const CStdString& strArtist, const CStdString& strAlbum, const CStdString& strTitle);
-
- bool GetCompilationAlbums(const CStdString& strBaseDir, CFileItemList& items);
- bool GetCompilationSongs(const CStdString& strBaseDir, CFileItemList& items);
- int GetCompilationAlbumsCount();
- bool GetVariousArtistsAlbums(const CStdString& strBaseDir, CFileItemList& items);
- bool GetVariousArtistsAlbumsSongs(const CStdString& strBaseDir, CFileItemList& items);
- int GetVariousArtistsAlbumsCount();
-
- bool SetSongRating(const CStdString &filePath, char rating);
+ /////////////////////////////////////////////////
+ // Scraper
+ /////////////////////////////////////////////////
bool SetScraperForPath(const CStdString& strPath, const ADDON::ScraperPtr& info);
bool GetScraperForPath(const CStdString& strPath, ADDON::ScraperPtr& info, const ADDON::TYPE &type);
-
+
/*! \brief Check whether a given scraper is in use.
\param scraperID the scraper to check for.
\return true if the scraper is in use, false otherwise.
*/
bool ScraperInUse(const CStdString &scraperID) const;
- // retrieve a list of items
+ /////////////////////////////////////////////////
+ // Karaoke
+ /////////////////////////////////////////////////
+ void AddKaraokeData(int idSong, const CSong& song);
+ bool GetSongByKaraokeNumber( int number, CSong& song );
+ bool SetKaraokeSongDelay( int idSong, int delay );
+ int GetKaraokeSongsCount();
+ void ExportKaraokeInfo(const CStdString &outFile, bool asHTML );
+ void ImportKaraokeInfo(const CStdString &inputFile );
+
+ /////////////////////////////////////////////////
+ // Filters
+ /////////////////////////////////////////////////
bool GetItems(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
bool GetItems(const CStdString &strBaseDir, const CStdString &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
CStdString GetItemById(const CStdString &itemType, int id);
+ /////////////////////////////////////////////////
+ // XML
+ /////////////////////////////////////////////////
void ExportToXML(const CStdString &xmlFile, bool singleFiles = false, bool images=false, bool overwrite=false);
void ImportFromXML(const CStdString &xmlFile);
- void ExportKaraokeInfo(const CStdString &outFile, bool asHTML );
- void ImportKaraokeInfo(const CStdString &inputFile );
-
+ /////////////////////////////////////////////////
+ // Properties
+ /////////////////////////////////////////////////
void SetPropertiesForFileItem(CFileItem& item);
static void SetPropertiesFromArtist(CFileItem& item, const CArtist& artist);
static void SetPropertiesFromAlbum(CFileItem& item, const CAlbum& album);
+ /////////////////////////////////////////////////
+ // Art
+ /////////////////////////////////////////////////
+ bool SaveAlbumThumb(int idAlbum, const CStdString &thumb);
/*! \brief Sets art for a database item.
Sets a single piece of art for a database item.
\param mediaId the id in the media (song/artist/album) table.
@@ -282,8 +371,6 @@ class CMusicDatabase : public CDatabase
*/
std::string GetArtistArtForItem(int mediaId, const std::string &mediaType, const std::string &artType);
- virtual bool GetFilter(CDbUrl &musicUrl, Filter &filter, SortDescription &sorting);
-
protected:
std::map<CStdString, int> m_artistCache;
std::map<CStdString, int> m_genreCache;
@@ -295,20 +382,7 @@ class CMusicDatabase : public CDatabase
virtual int GetMinVersion() const;
const char *GetBaseDBName() const { return "MyMusic"; };
- int AddSong(const CSong& song, bool bCheck = true, int idAlbum = -1);
- int AddAlbum(const CStdString& strAlbum1, const CStdString &strArtist1, const CStdString& strGenre, int year, bool bCompilation);
- int AddGenre(const CStdString& strGenre);
- int AddArtist(const CStdString& strArtist);
- int AddPath(const CStdString& strPath);
- bool AddAlbumArtist(int idArtist, int idAlbum, bool featured, int iOrder);
- bool AddSongArtist(int idArtist, int idSong, bool featured, int iOrder);
- bool AddSongGenre(int idGenre, int idSong, int iOrder);
- bool AddAlbumGenre(int idGenre, int idAlbum, int iOrder);
-
- void AddKaraokeData(int idSong, const CSong& song);
- bool SetAlbumInfoSongs(int idAlbumInfo, const VECSONGS& songs);
- bool GetAlbumInfoSongs(int idAlbumInfo, VECSONGS& songs);
private:
/*! \brief (Re)Create the generic database views for songs and albums
*/
Please sign in to comment.
Something went wrong with that request. Please try again.