#include <track.h>
Inheritance diagram for itunesdb::TrackPredicate:
Public Member Functions | |
virtual bool | operator() (const Track *) const =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 ITunesDB::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. Alternatively you can call the getTracksBy() method returning a RangeIterator and add the tracks to your own container.
ITunesDB::FilteredTrackConstIterator<TracksByYearPredicate> iter = itunesdb.getTracksBy( yearPredicate );
std::vector<itunesdb::Track*> vector;
while( iter.hasNext() ) {
vector.push_back( iter.next() );
}
virtual bool itunesdb::TrackPredicate::operator() | ( | const Track * | ) | const [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, itunesdb::TrackPredicates::ByPathInfo, and itunesdb::TrackPredicates::Contains.