File indexing completed on 2024-05-19 04:49:29
0001 /**************************************************************************************** 0002 * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com> * 0003 * Copyright (c) 2008 Mark Kretschmann <kretschmann@kde.org> * 0004 * Copyright (c) 2013 Matěj Laitl <matej@laitl.cz> * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify it under * 0007 * the terms of the GNU General Public License as published by the Free Software * 0008 * Foundation; either version 2 of the License, or (at your option) any later * 0009 * version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0013 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License along with * 0016 * this program. If not, see <http://www.gnu.org/licenses/>. * 0017 ***************************************************************************************/ 0018 0019 #include "Observer.h" 0020 0021 #include "core/meta/Base.h" 0022 0023 using namespace Meta; 0024 0025 Observer::~Observer() 0026 { 0027 // Unsubscribe all stray Meta subscriptions: 0028 foreach( Base *ptr, m_subscriptions ) 0029 { 0030 if( ptr ) 0031 ptr->unsubscribe( this ); 0032 } 0033 } 0034 0035 void 0036 Observer::metadataChanged( const TrackPtr &track ) 0037 { 0038 Q_UNUSED( track ); 0039 } 0040 0041 void 0042 Observer::metadataChanged( const ArtistPtr &artist ) 0043 { 0044 Q_UNUSED( artist ); 0045 } 0046 0047 void 0048 Observer::metadataChanged( const AlbumPtr &album ) 0049 { 0050 Q_UNUSED( album ); 0051 } 0052 0053 void 0054 Observer::metadataChanged( const ComposerPtr &composer ) 0055 { 0056 Q_UNUSED( composer ); 0057 } 0058 0059 void 0060 Observer::metadataChanged( const GenrePtr &genre ) 0061 { 0062 Q_UNUSED( genre ); 0063 } 0064 0065 void 0066 Observer::metadataChanged( const YearPtr &year ) 0067 { 0068 Q_UNUSED( year ); 0069 } 0070 0071 void 0072 Observer::entityDestroyed() 0073 { 0074 } 0075 0076 void 0077 Observer::subscribeTo( Base *ptr ) 0078 { 0079 if( !ptr ) 0080 return; 0081 QMutexLocker locker( &m_subscriptionsMutex ); 0082 ptr->subscribe( this ); 0083 m_subscriptions.insert( ptr ); 0084 } 0085 0086 void 0087 Observer::unsubscribeFrom( Base *ptr ) 0088 { 0089 QMutexLocker locker( &m_subscriptionsMutex ); 0090 if( ptr ) 0091 ptr->unsubscribe( this ); 0092 m_subscriptions.remove( ptr ); 0093 } 0094 0095 void 0096 Observer::destroyedNotify( Base *ptr ) 0097 { 0098 { 0099 QMutexLocker locker( &m_subscriptionsMutex ); 0100 m_subscriptions.remove( ptr ); 0101 } 0102 entityDestroyed(); 0103 }