factor out matcher classes into seperate file that can be used by other classes
[amarok.git] / src / collection / support / MemoryMatcher.h
blobff75ee4a9333d544bc0308824a2d7ce4b592fd95
1 /***************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
3 * (C) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef MEMORYMATCHER_H
22 #define MEMORYMATCHER_H
24 #include "MemoryCollection.h"
25 #include "meta.h"
27 /**
28 A helper class for finding items in a MemoryCollection
30 @author
32 class MemoryMatcher{
33 public:
34 MemoryMatcher();
35 virtual ~MemoryMatcher();
36 virtual Meta::TrackList match( MemoryCollection *memColl) = 0;
37 virtual Meta::TrackList match( const Meta::TrackList &tracks ) = 0;
39 bool isLast() const;
40 void setNext( MemoryMatcher *next );
41 MemoryMatcher* next() const;
43 private:
44 MemoryMatcher *m_next;
48 class TrackMatcher : public MemoryMatcher
50 public:
51 TrackMatcher( Meta::TrackPtr track );
52 virtual Meta::TrackList match( MemoryCollection *memColl );
53 virtual Meta::TrackList match( const Meta::TrackList &tracks );
55 private:
56 Meta::TrackPtr m_track;
60 class ArtistMatcher : public MemoryMatcher
62 public:
63 ArtistMatcher( Meta::ArtistPtr artist );
64 virtual Meta::TrackList match( MemoryCollection *memColl );
65 virtual Meta::TrackList match( const Meta::TrackList &tracks );
67 private:
68 Meta::ArtistPtr m_artist;
71 class AlbumMatcher : public MemoryMatcher
73 public:
74 AlbumMatcher( Meta::AlbumPtr album );
75 virtual Meta::TrackList match( MemoryCollection *memColl );
76 virtual Meta::TrackList match( const Meta::TrackList &tracks );
78 private:
79 Meta::AlbumPtr m_album;
82 class GenreMatcher : public MemoryMatcher
84 public:
85 GenreMatcher( Meta::GenrePtr genre );
86 virtual Meta::TrackList match( MemoryCollection *memColl );
87 virtual Meta::TrackList match( const Meta::TrackList &tracks );
89 private:
90 Meta::GenrePtr m_genre;
93 class ComposerMatcher : public MemoryMatcher
95 public:
96 ComposerMatcher( Meta::ComposerPtr composer );
97 virtual Meta::TrackList match( MemoryCollection *memColl );
98 virtual Meta::TrackList match( const Meta::TrackList &tracks );
100 private:
101 Meta::ComposerPtr m_composer;
104 class YearMatcher : public MemoryMatcher
106 public:
107 YearMatcher( Meta::YearPtr year );
108 virtual Meta::TrackList match( MemoryCollection *memColl );
109 virtual Meta::TrackList match( const Meta::TrackList &tracks );
111 private:
112 Meta::YearPtr m_year;
116 #endif