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 #include "core/meta/Meta.h" 0018 #include "core/meta/support/PrivateMetaRegistry.h" 0019 #include "core/support/Debug.h" 0020 0021 namespace Meta { 0022 0023 0024 PrivateMetaRegistry* PrivateMetaRegistry::s_instance = nullptr; 0025 0026 0027 PrivateMetaRegistry * PrivateMetaRegistry::instance() 0028 { 0029 if ( s_instance == nullptr ) 0030 s_instance = new PrivateMetaRegistry(); 0031 return s_instance; 0032 } 0033 0034 0035 PrivateMetaRegistry::PrivateMetaRegistry() 0036 { 0037 } 0038 0039 0040 PrivateMetaRegistry::~PrivateMetaRegistry() 0041 { 0042 } 0043 0044 0045 void PrivateMetaRegistry::insertAlbum( const QString &owner, const QString &key, const AlbumPtr &album ) 0046 { 0047 const QString compositeKey = owner + '-' + key; 0048 m_albums.insert( compositeKey, album ); 0049 } 0050 0051 void PrivateMetaRegistry::insertArtist( const QString &owner, const QString &key, const ArtistPtr &artist ) 0052 { 0053 const QString compositeKey = owner + '-' + key; 0054 m_artists.insert( compositeKey, artist ); 0055 } 0056 0057 void PrivateMetaRegistry::insertGenre( const QString &owner, const QString &key, const GenrePtr &genre ) 0058 { 0059 const QString compositeKey = owner + '-' + key; 0060 m_genre.insert( compositeKey, genre ); 0061 } 0062 0063 void PrivateMetaRegistry::insertComposer( const QString &owner, const QString &key, const ComposerPtr &composer ) 0064 { 0065 const QString compositeKey = owner + '-' + key; 0066 m_composers.insert( compositeKey, composer ); 0067 } 0068 0069 void PrivateMetaRegistry::insertYear( const QString &owner, const QString &key, const YearPtr &year ) 0070 { 0071 const QString compositeKey = owner + '-' + key; 0072 m_years.insert( compositeKey, year ); 0073 } 0074 0075 AlbumPtr PrivateMetaRegistry::album( const QString &owner, const QString &key ) 0076 { 0077 DEBUG_BLOCK 0078 const QString compositeKey = owner + '-' + key; 0079 if ( m_albums.contains( compositeKey ) ) { 0080 debug() << "reusing album with key: " << key; 0081 return m_albums.value( compositeKey ); 0082 0083 } 0084 return AlbumPtr(); 0085 } 0086 0087 ArtistPtr PrivateMetaRegistry::artist( const QString &owner, const QString &key ) 0088 { 0089 const QString compositeKey = owner + '-' + key; 0090 if ( m_artists.contains( compositeKey ) ) 0091 return m_artists.value( compositeKey ); 0092 return ArtistPtr(); 0093 } 0094 0095 GenrePtr PrivateMetaRegistry::genre( const QString &owner, const QString &key ) 0096 { 0097 const QString compositeKey = owner + '-' + key; 0098 if ( m_genre.contains( compositeKey ) ) 0099 return m_genre.value( compositeKey ); 0100 return GenrePtr(); 0101 } 0102 0103 ComposerPtr PrivateMetaRegistry::composer( const QString &owner, const QString &key ) 0104 { 0105 const QString compositeKey = owner + '-' + key; 0106 if ( m_composers.contains( compositeKey ) ) 0107 return m_composers.value( compositeKey ); 0108 return ComposerPtr(); 0109 } 0110 0111 YearPtr PrivateMetaRegistry::year( const QString &owner, const QString &key ) 0112 { 0113 const QString compositeKey = owner + '-' + key; 0114 if ( m_years.contains( compositeKey ) ) 0115 return m_years.value( compositeKey ); 0116 return YearPtr(); 0117 } 0118 0119 } 0120