File indexing completed on 2024-05-19 04:49:17

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com>            *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef MEMORYMATCHER_H
0019 #define MEMORYMATCHER_H
0020 
0021 #include "amarok_export.h"
0022 #include "MemoryCollection.h"
0023 #include "core/collections/QueryMaker.h"
0024 #include "core/meta/forward_declarations.h"
0025 
0026 /**
0027 A helper class for finding items in a MemoryCollection
0028 
0029     @author 
0030 */
0031 class AMAROK_EXPORT MemoryMatcher{
0032     public:
0033         MemoryMatcher();
0034         virtual ~MemoryMatcher();
0035         virtual Meta::TrackList match( Collections::MemoryCollection *memColl) = 0;
0036         virtual Meta::TrackList match( const Meta::TrackList &tracks ) = 0;
0037 
0038         bool isLast() const;
0039         void setNext( MemoryMatcher *next );
0040         MemoryMatcher* next() const;
0041 
0042     private:
0043         MemoryMatcher *m_next;
0044 };
0045 
0046 
0047 class AMAROK_EXPORT TrackMatcher : public MemoryMatcher
0048 {
0049     public:
0050         explicit TrackMatcher( const Meta::TrackPtr &track );
0051         Meta::TrackList match( Collections::MemoryCollection *memColl ) override;
0052         Meta::TrackList match( const Meta::TrackList &tracks ) override;
0053 
0054     private:
0055         Meta::TrackPtr m_track;
0056 };
0057 
0058 
0059 class AMAROK_EXPORT ArtistMatcher : public MemoryMatcher
0060 {
0061     public:
0062         ArtistMatcher( const Meta::ArtistPtr &artist, Collections::QueryMaker::ArtistMatchBehaviour artistMode
0063                        = Collections::QueryMaker::TrackArtists );
0064         Meta::TrackList match( Collections::MemoryCollection *memColl ) override;
0065         Meta::TrackList match( const Meta::TrackList &tracks ) override;
0066 
0067     private:
0068         Meta::ArtistPtr m_artist;
0069         Collections::QueryMaker::ArtistMatchBehaviour m_queryMode;
0070 };
0071 
0072 class AMAROK_EXPORT AlbumMatcher : public MemoryMatcher
0073 {
0074     public:
0075         explicit AlbumMatcher( const Meta::AlbumPtr &album );
0076         Meta::TrackList match( Collections::MemoryCollection *memColl ) override;
0077         Meta::TrackList match( const Meta::TrackList &tracks ) override;
0078 
0079     private:
0080         Meta::AlbumPtr m_album;
0081 };
0082 
0083 class AMAROK_EXPORT GenreMatcher : public MemoryMatcher
0084 {
0085     public:
0086         explicit GenreMatcher( const Meta::GenrePtr &genre );
0087         Meta::TrackList match( Collections::MemoryCollection *memColl ) override;
0088         Meta::TrackList match( const Meta::TrackList &tracks ) override;
0089 
0090     private:
0091         Meta::GenrePtr m_genre;
0092 };
0093 
0094 class AMAROK_EXPORT ComposerMatcher : public MemoryMatcher
0095 {
0096     public:
0097         explicit ComposerMatcher( const Meta::ComposerPtr &composer );
0098         Meta::TrackList match( Collections::MemoryCollection *memColl ) override;
0099         Meta::TrackList match( const Meta::TrackList &tracks ) override;
0100 
0101     private:
0102         Meta::ComposerPtr m_composer;
0103 };
0104 
0105 class AMAROK_EXPORT YearMatcher : public MemoryMatcher
0106 {
0107     public:
0108         explicit YearMatcher( const Meta::YearPtr &year );
0109         Meta::TrackList match( Collections::MemoryCollection *memColl ) override;
0110         Meta::TrackList match( const Meta::TrackList &tracks ) override;
0111 
0112     private:
0113         Meta::YearPtr m_year;
0114 };
0115 
0116 class AMAROK_EXPORT LabelMatcher : public MemoryMatcher
0117 {
0118     public:
0119         explicit LabelMatcher( const Meta::LabelPtr &label );
0120         Meta::TrackList match( Collections::MemoryCollection *memColl ) override;
0121         Meta::TrackList match( const Meta::TrackList &tracks ) override;
0122 
0123     private:
0124         Meta::LabelPtr m_label;
0125 };
0126 
0127 
0128 #endif