#include <track.h>
Inheritance diagram for itunesdb::TrackPredicate:
Public Member Functions | |
virtual bool | operator() (const Track &)=0 |
Example: you need to get all the tracks performed at a given year (e.g. 2004) from the database
First create an implementor for TrackPredicate like this:
class TracksByYearPredicate : public TrackPredicate {
Q_UINT32 m_givenYear;
public:
TracksByYearPredicate( Q_UINT32 givenYear ) : m_givenYear( givenYear ) {}
~TracksByYearPredicate() {}
bool operator() ( const itunesdb::Track& track ) {
return track.getYear() == m_givenYear;
}
};
then you call the getTracksBy() method of your ITunesDB instance (here itunesdb) with a reference to your predicate
TracksByYearPredicate yearPredicate( 2004 );
TrackPtrList result;
itunesdb.getTracksBy( yearPredicate, result );
Now you have all tracks performed at 2004 in your result list.
virtual bool itunesdb::TrackPredicate::operator() | ( | const Track & | ) | [pure virtual] |
Implement this method accordingly to the documentation above and (!) the documentation of the function this predicate will be given to.
Implemented in ITunesDBSPLRuleSet, itunesdb::TrackPredicates::ByArtist, itunesdb::TrackPredicates::ByAlbum, itunesdb::TrackPredicates::ByFullInfo, and itunesdb::TrackPredicates::Contains.