Skip to content
This repository
Browse code

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

…and add some comments
  • Loading branch information...
commit 593bf80bf2a41d761b5ea542c510b31ced50a278 1 parent 0175bfd
night199uk authored

Showing 1 changed file with 139 additions and 65 deletions. Show diff stats Hide diff stats

  1. 204  xbmc/music/MusicDatabase.h
204  xbmc/music/MusicDatabase.h
@@ -102,63 +102,152 @@ class CMusicDatabase : public CDatabase
102 102
   bool LookupCDDBInfo(bool bRequery=false);
103 103
   void DeleteCDDBInfo();
104 104
 
  105
+  /////////////////////////////////////////////////
  106
+  // Song CRUD
  107
+  /////////////////////////////////////////////////
105 108
   /*! \brief Add an album and all its songs to the database
106 109
    \param album the album to add
107 110
    \param songIDs [out] the ids of the added songs
108 111
    \return the id of the album
109 112
    */
110  
-  int AddAlbum(const CAlbum &album, std::vector<int> &songIDs);
  113
+  int  AddSong(const CSong& song, bool bCheck = true, int idAlbum = -1);
  114
+  bool GetSongById(int idSong, CSong& song);
  115
+  int  UpdateSong(const CSong& song, int idSong = -1);
  116
+  // bool DeleteSong(int idSong);
  117
+
  118
+  //// Misc Song
  119
+  bool GetSongByFileName(const CStdString& strFileName, CSong& song, int startOffset = 0);
  120
+  bool GetSongsByPath(const CStdString& strPath, MAPSONGS& songs, bool bAppendToMap = false);
  121
+  bool Search(const CStdString& search, CFileItemList &items);
  122
+  bool RemoveSongsFromPath(const CStdString &path, MAPSONGS& songs, bool exact=true);
  123
+  bool SetSongRating(const CStdString &filePath, char rating);
  124
+  int  GetSongByArtistAndAlbumAndTitle(const CStdString& strArtist, const CStdString& strAlbum, const CStdString& strTitle);
  125
+
  126
+  /////////////////////////////////////////////////
  127
+  // Album
  128
+  /////////////////////////////////////////////////
  129
+  /*! \brief Add an album and all its songs to the database
  130
+   \param album the album to add
  131
+   \param songIDs [out] the ids of the added songs
  132
+   \return the id of the album
  133
+   */
  134
+  int  AddAlbum(const CAlbum &album, std::vector<int> &songIDs);
  135
+  int  AddAlbum(const CStdString& strAlbum, const CStdString& strArtist, const CStdString& strGenre, int year, bool bCompilation);
  136
+  bool GetAlbum(int idAlbum, CAlbum& album);
  137
+  int  UpdateAlbum(int idAlbum, const CAlbum &album);
  138
+  bool DeleteAlbum(int idAlbum);
  139
+
  140
+  //// Misc Album
  141
+  int  GetAlbumIdByPath(const CStdString& path);
  142
+  bool GetAlbumFromSong(int idSong, CAlbum &album);
  143
+  bool GetAlbumFromSong(const CSong &song, CAlbum &album);
  144
+  int  GetAlbumByName(const CStdString& strAlbum, const CStdString& strArtist="");
  145
+  int  GetAlbumByName(const CStdString& strAlbum, const std::vector<std::string>& artist);
  146
+  CStdString GetAlbumById(int id);
111 147
 
112  
-  int UpdateSong(const CSong& song, int idSong = -1);
  148
+  /////////////////////////////////////////////////
  149
+  // Artist CRUD
  150
+  /////////////////////////////////////////////////
  151
+  int  AddArtist(const CStdString& strArtist);
  152
+  bool GetArtist(int idArtist, CArtist& artist);
  153
+  int  UpdateArtist(int idArtist, const CArtist& artist);
  154
+  bool DeleteArtist(int idArtist);
  155
+
  156
+  CStdString GetArtistById(int id);
  157
+  int GetArtistByName(const CStdString& strArtist);
  158
+
  159
+  /////////////////////////////////////////////////
  160
+  // Paths
  161
+  /////////////////////////////////////////////////
  162
+  int AddPath(const CStdString& strPath);
  163
+
  164
+  bool GetPaths(std::set<CStdString> &paths);
  165
+  bool SetPathHash(const CStdString &path, const CStdString &hash);
  166
+  bool GetPathHash(const CStdString &path, CStdString &hash);
  167
+  bool GetAlbumPath(int idAlbum, CStdString &path);
  168
+  bool GetArtistPath(int idArtist, CStdString &path);
  169
+
  170
+  /////////////////////////////////////////////////
  171
+  // Genres
  172
+  /////////////////////////////////////////////////
  173
+  int AddGenre(const CStdString& strGenre);
  174
+  CStdString GetGenreById(int id);
  175
+  int GetGenreByName(const CStdString& strGenre);
  176
+
  177
+  /////////////////////////////////////////////////
  178
+  // AlbumInfo
  179
+  /////////////////////////////////////////////////
  180
+  bool HasAlbumInfo(int idAlbum);
113 181
   int SetAlbumInfo(int idAlbum, const CAlbum& album, const VECSONGS& songs, bool bTransaction=true);
114  
-  bool DeleteAlbumInfo(int idArtist);
115  
-  int SetArtistInfo(int idArtist, const CArtist& artist);
116  
-  bool DeleteArtistInfo(int idArtist);
117 182
   bool GetAlbumInfo(int idAlbum, CAlbum &info, VECSONGS* songs, bool scrapedInfo = false);
118  
-  bool HasAlbumInfo(int idAlbum);
119  
-  bool GetArtistInfo(int idArtist, CArtist &info, bool needAll=true);
  183
+  bool DeleteAlbumInfo(int idArtist);
  184
+  bool SetAlbumInfoSongs(int idAlbumInfo, const VECSONGS& songs);
  185
+  bool GetAlbumInfoSongs(int idAlbumInfo, VECSONGS& songs);
120 186
 
  187
+  /////////////////////////////////////////////////
  188
+  // ArtistInfo
  189
+  /////////////////////////////////////////////////
121 190
   /*! \brief Check if an artist entity has additional metadata (scraped)
122 191
    \param idArtist the id of the Artist to check
123 192
    \return true or false - whether the artist has metadata
124 193
    */
125 194
   bool HasArtistInfo(int idArtist);
126  
-  bool GetSongByFileName(const CStdString& strFileName, CSong& song, int startOffset = 0);
127  
-  int GetAlbumIdByPath(const CStdString& path);
128  
-  bool GetSongById(int idSong, CSong& song);
129  
-  bool GetSongByKaraokeNumber( int number, CSong& song );
130  
-  bool SetKaraokeSongDelay( int idSong, int delay );
131  
-  bool GetSongsByPath(const CStdString& strPath, MAPSONGS& songs, bool bAppendToMap = false);
132  
-  bool Search(const CStdString& search, CFileItemList &items);
  195
+  int SetArtistInfo(int idArtist, const CArtist& artist);
  196
+  bool GetArtistInfo(int idArtist, CArtist &info, bool needAll=true);
  197
+  bool DeleteArtistInfo(int idArtist);
133 198
 
134  
-  bool GetAlbumFromSong(int idSong, CAlbum &album);
135  
-  bool GetAlbumFromSong(const CSong &song, CAlbum &album);
136  
-  
  199
+  /////////////////////////////////////////////////
  200
+  // Link tables
  201
+  /////////////////////////////////////////////////
  202
+  bool AddAlbumArtist(int idArtist, int idAlbum, bool featured, int iOrder);
137 203
   bool GetAlbumsByArtist(int idArtist, bool includeFeatured, std::vector<int>& albums);
138 204
   bool GetArtistsByAlbum(int idAlbum, bool includeFeatured, std::vector<int>& artists);
  205
+
  206
+  bool AddSongArtist(int idArtist, int idSong, bool featured, int iOrder);
139 207
   bool GetSongsByArtist(int idArtist, bool includeFeatured, std::vector<int>& songs);
140 208
   bool GetArtistsBySong(int idSong, bool includeFeatured, std::vector<int>& artists);
141 209
 
142  
-  bool GetGenresByAlbum(int idAlbum, std::vector<int>& genres);
  210
+  bool AddSongGenre(int idGenre, int idSong, int iOrder);
143 211
   bool GetGenresBySong(int idSong, std::vector<int>& genres);
144 212
 
  213
+  bool AddAlbumGenre(int idGenre, int idAlbum, int iOrder);
  214
+  bool GetGenresByAlbum(int idAlbum, std::vector<int>& genres);
  215
+
  216
+  /////////////////////////////////////////////////
  217
+  // Top 100
  218
+  /////////////////////////////////////////////////
145 219
   bool GetTop100(const CStdString& strBaseDir, CFileItemList& items);
146 220
   bool GetTop100Albums(VECALBUMS& albums);
147 221
   bool GetTop100AlbumSongs(const CStdString& strBaseDir, CFileItemList& item);
  222
+
  223
+  /////////////////////////////////////////////////
  224
+  // Recently added
  225
+  /////////////////////////////////////////////////
148 226
   bool GetRecentlyAddedAlbums(VECALBUMS& albums, unsigned int limit=0);
149 227
   bool GetRecentlyAddedAlbumSongs(const CStdString& strBaseDir, CFileItemList& item, unsigned int limit=0);
150 228
   bool GetRecentlyPlayedAlbums(VECALBUMS& albums);
151 229
   bool GetRecentlyPlayedAlbumSongs(const CStdString& strBaseDir, CFileItemList& item);
  230
+
  231
+  /////////////////////////////////////////////////
  232
+  // Compilations
  233
+  /////////////////////////////////////////////////
  234
+  bool GetCompilationAlbums(const CStdString& strBaseDir, CFileItemList& items);
  235
+  bool GetCompilationSongs(const CStdString& strBaseDir, CFileItemList& items);
  236
+  int  GetCompilationAlbumsCount();
  237
+  bool GetVariousArtistsAlbums(const CStdString& strBaseDir, CFileItemList& items);
  238
+  bool GetVariousArtistsAlbumsSongs(const CStdString& strBaseDir, CFileItemList& items);
  239
+  int GetVariousArtistsAlbumsCount();
  240
+  
152 241
   /*! \brief Increment the playcount of an item
153 242
    Increments the playcount and updates the last played date
154 243
    \param item CFileItem to increment the playcount for
155 244
    */
156 245
   void IncrementPlayCount(const CFileItem &item);
157  
-  bool RemoveSongsFromPath(const CStdString &path, MAPSONGS& songs, bool exact=true);
158 246
   bool CleanupOrphanedItems();
159  
-  bool GetPaths(std::set<CStdString> &paths);
160  
-  bool SetPathHash(const CStdString &path, const CStdString &hash);
161  
-  bool GetPathHash(const CStdString &path, CStdString &hash);
  247
+
  248
+  /////////////////////////////////////////////////
  249
+  // VIEWS
  250
+  /////////////////////////////////////////////////
162 251
   bool GetGenresNav(const CStdString& strBaseDir, CFileItemList& items, const Filter &filter = Filter(), bool countOnly = false);
163 252
   bool GetYearsNav(const CStdString& strBaseDir, CFileItemList& items, const Filter &filter = Filter());
164 253
   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
173 262
   bool GetAlbumsByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList &items, const SortDescription &sortDescription = SortDescription(), bool countOnly = false);
174 263
   bool GetArtistsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription(), bool countOnly = false);
175 264
   bool GetRandomSong(CFileItem* item, int& idSong, const Filter &filter);
176  
-  int GetKaraokeSongsCount();
177 265
   int GetSongsCount(const Filter &filter = Filter());
178 266
   unsigned int GetSongIDs(const Filter &filter, std::vector<std::pair<int,int> > &songIDs);
  267
+  virtual bool GetFilter(CDbUrl &musicUrl, Filter &filter, SortDescription &sorting);
179 268
 
180  
-  bool GetAlbumPath(int idAlbum, CStdString &path);
181  
-  bool SaveAlbumThumb(int idAlbum, const CStdString &thumb);
182  
-  bool GetArtistPath(int idArtist, CStdString &path);
183  
-
184  
-  CStdString GetGenreById(int id);
185  
-  CStdString GetArtistById(int id);
186  
-  CStdString GetAlbumById(int id);
187  
-
188  
-  int GetArtistByName(const CStdString& strArtist);
189  
-  int GetAlbumByName(const CStdString& strAlbum, const CStdString& strArtist="");
190  
-  int GetAlbumByName(const CStdString& strAlbum, const std::vector<std::string>& artist);
191  
-  int GetGenreByName(const CStdString& strGenre);
192  
-  int GetSongByArtistAndAlbumAndTitle(const CStdString& strArtist, const CStdString& strAlbum, const CStdString& strTitle);
193  
-
194  
-  bool GetCompilationAlbums(const CStdString& strBaseDir, CFileItemList& items);
195  
-  bool GetCompilationSongs(const CStdString& strBaseDir, CFileItemList& items);
196  
-  int  GetCompilationAlbumsCount();
197  
-  bool GetVariousArtistsAlbums(const CStdString& strBaseDir, CFileItemList& items);
198  
-  bool GetVariousArtistsAlbumsSongs(const CStdString& strBaseDir, CFileItemList& items);
199  
-  int GetVariousArtistsAlbumsCount();
200  
-
201  
-  bool SetSongRating(const CStdString &filePath, char rating);
  269
+  /////////////////////////////////////////////////
  270
+  // Scraper
  271
+  /////////////////////////////////////////////////
202 272
   bool SetScraperForPath(const CStdString& strPath, const ADDON::ScraperPtr& info);
203 273
   bool GetScraperForPath(const CStdString& strPath, ADDON::ScraperPtr& info, const ADDON::TYPE &type);
204  
-
  274
+  
205 275
   /*! \brief Check whether a given scraper is in use.
206 276
    \param scraperID the scraper to check for.
207 277
    \return true if the scraper is in use, false otherwise.
208 278
    */
209 279
   bool ScraperInUse(const CStdString &scraperID) const;
210 280
 
211  
-  // retrieve a list of items
  281
+  /////////////////////////////////////////////////
  282
+  // Karaoke
  283
+  /////////////////////////////////////////////////
  284
+  void AddKaraokeData(int idSong, const CSong& song);
  285
+  bool GetSongByKaraokeNumber( int number, CSong& song );
  286
+  bool SetKaraokeSongDelay( int idSong, int delay );
  287
+  int GetKaraokeSongsCount();
  288
+  void ExportKaraokeInfo(const CStdString &outFile, bool asHTML );
  289
+  void ImportKaraokeInfo(const CStdString &inputFile );
  290
+
  291
+  /////////////////////////////////////////////////
  292
+  // Filters
  293
+  /////////////////////////////////////////////////
212 294
   bool GetItems(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
213 295
   bool GetItems(const CStdString &strBaseDir, const CStdString &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
214 296
   CStdString GetItemById(const CStdString &itemType, int id);
215 297
 
  298
+  /////////////////////////////////////////////////
  299
+  // XML
  300
+  /////////////////////////////////////////////////
216 301
   void ExportToXML(const CStdString &xmlFile, bool singleFiles = false, bool images=false, bool overwrite=false);
217 302
   void ImportFromXML(const CStdString &xmlFile);
218 303
 
219  
-  void ExportKaraokeInfo(const CStdString &outFile, bool asHTML );
220  
-  void ImportKaraokeInfo(const CStdString &inputFile );
221  
-
  304
+  /////////////////////////////////////////////////
  305
+  // Properties
  306
+  /////////////////////////////////////////////////
222 307
   void SetPropertiesForFileItem(CFileItem& item);
223 308
   static void SetPropertiesFromArtist(CFileItem& item, const CArtist& artist);
224 309
   static void SetPropertiesFromAlbum(CFileItem& item, const CAlbum& album);
225 310
 
  311
+  /////////////////////////////////////////////////
  312
+  // Art
  313
+  /////////////////////////////////////////////////
  314
+  bool SaveAlbumThumb(int idAlbum, const CStdString &thumb);
226 315
   /*! \brief Sets art for a database item.
227 316
    Sets a single piece of art for a database item.
228 317
    \param mediaId the id in the media (song/artist/album) table.
@@ -282,8 +371,6 @@ class CMusicDatabase : public CDatabase
282 371
    */
283 372
   std::string GetArtistArtForItem(int mediaId, const std::string &mediaType, const std::string &artType);
284 373
 
285  
-  virtual bool GetFilter(CDbUrl &musicUrl, Filter &filter, SortDescription &sorting);
286  
-
287 374
 protected:
288 375
   std::map<CStdString, int> m_artistCache;
289 376
   std::map<CStdString, int> m_genreCache;
@@ -295,20 +382,7 @@ class CMusicDatabase : public CDatabase
295 382
   virtual int GetMinVersion() const;
296 383
   const char *GetBaseDBName() const { return "MyMusic"; };
297 384
 
298  
-  int AddSong(const CSong& song, bool bCheck = true, int idAlbum = -1);
299  
-  int AddAlbum(const CStdString& strAlbum1, const CStdString &strArtist1, const CStdString& strGenre, int year, bool bCompilation);
300  
-  int AddGenre(const CStdString& strGenre);
301  
-  int AddArtist(const CStdString& strArtist);
302  
-  int AddPath(const CStdString& strPath);
303 385
 
304  
-  bool AddAlbumArtist(int idArtist, int idAlbum, bool featured, int iOrder);
305  
-  bool AddSongArtist(int idArtist, int idSong, bool featured, int iOrder);
306  
-  bool AddSongGenre(int idGenre, int idSong, int iOrder);
307  
-  bool AddAlbumGenre(int idGenre, int idAlbum, int iOrder);
308  
-
309  
-  void AddKaraokeData(int idSong, const CSong& song);
310  
-  bool SetAlbumInfoSongs(int idAlbumInfo, const VECSONGS& songs);
311  
-  bool GetAlbumInfoSongs(int idAlbumInfo, VECSONGS& songs);
312 386
 private:
313 387
   /*! \brief (Re)Create the generic database views for songs and albums
314 388
    */

0 notes on commit 593bf80

Please sign in to comment.
Something went wrong with that request. Please try again.