File indexing completed on 2024-05-19 04:49:29
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef METAPRIVATEMETAREGISTRY_H 0018 #define METAPRIVATEMETAREGISTRY_H 0019 0020 #include "core/amarokcore_export.h" 0021 #include "core/meta/forward_declarations.h" 0022 0023 #include <QMap> 0024 0025 namespace Meta { 0026 0027 /** 0028 * An extremely simple registry used where tracks often have private album (or other 0029 * members) to correlate these instead of creating a new one for each track (even if they 0030 * are from the same album). This, besides saving memory, also makes it possible to group 0031 * by pointers in the playlist instead of some album/artist name foo. 0032 */ 0033 class AMAROKCORE_EXPORT PrivateMetaRegistry 0034 { 0035 public: 0036 static PrivateMetaRegistry *instance(); 0037 0038 void insertAlbum( const QString &owner, const QString &key, const AlbumPtr &album ); 0039 void insertArtist( const QString &owner, const QString &key, const ArtistPtr &artist ); 0040 void insertGenre( const QString &owner, const QString &key, const GenrePtr &genre ); 0041 void insertComposer( const QString &owner, const QString &key, const ComposerPtr &composer ); 0042 void insertYear( const QString &owner, const QString &key, const YearPtr &year ); 0043 0044 AlbumPtr album( const QString &owner, const QString &key ); 0045 ArtistPtr artist( const QString &owner, const QString &key ); 0046 GenrePtr genre( const QString &owner, const QString &key ); 0047 ComposerPtr composer( const QString &owner, const QString &key ); 0048 YearPtr year( const QString &owner, const QString &key ); 0049 0050 private: 0051 PrivateMetaRegistry(); 0052 ~PrivateMetaRegistry(); 0053 0054 static PrivateMetaRegistry *s_instance; //!< instance variable 0055 0056 QMap<QString, AlbumPtr> m_albums; 0057 QMap<QString, ArtistPtr> m_artists; 0058 QMap<QString, GenrePtr> m_genre; 0059 QMap<QString, ComposerPtr> m_composers; 0060 QMap<QString, YearPtr> m_years; 0061 }; 0062 } 0063 0064 #endif