itunesdb::TrackPtrList Class Reference

A SortablePtrVector implementation for Track pointers. More...

#include <track.h>

Inheritance diagram for itunesdb::TrackPtrList:

itunesdb::utils::SortablePtrVector< itunesdb::Track > List of all members.

Public Types

typedef Comparator< itunesdb::TrackSortableVectorElemComparator
 Comparator Type definition.
typedef QTPOD_SHARED_PTR_IMPL_DEF<
SortableVectorElemComparator
ComparatorPtr
 Shared Pointer type managing the pointer to the comparator.
typedef FilteredIterator Iterator
typedef FilteredConstIterator ConstIterator

Public Member Functions

 TrackPtrList ()
 Creates an empty TrackPtrList.
template<typename IterT>
 TrackPtrList (IterT elements)
 Creates a TrackPtrList and fills in the itunesdb::Track pointers returned by the given utils::RangeIterator.
bool hasDirtyTracks () const
 Returns true if this list contains tracks not in sync with the database.
bool hasRecentlyPlayedTracks () const
 Returns true if this list contains tracks being played after the last sync.
TrackPtrListgetTracksBy (TrackPredicate &predicate, itunesdb::TrackPtrList &buffer) const
 Returns all the Tracks where the given predicate returned true.
TrackfindFirstTrackBy (TrackPredicate &predicate) const
 Returns the first Track where the given predicate returned true.
bool removeIfTrue (TrackPredicate &predicate)
 Removes the elements the given predicate returns true.
bool removeAllRefs (itunesdb::Track *track)
 Removes all references to the given track.
void setDefaultSortOrder ()
 Sets the sort order to default ( Artist/Album/Tracknumber ).
void setComparator (SortableVectorElemComparator *comparator)
 Sets the comparator for this container to by used by sort() and inSort().
void setComparator (const ComparatorPtr &comparator)
 Sets the comparator for this container to by used by sort() and inSort().
const ComparatorPtrgetComparator () const
 Returns the currently used comparator for sorting.
void sort ()
 Sorts the containers element using the comparator set by setComparator().
void randomize ()
 Randomizes the order of the elements.
unsigned int inSort (itunesdb::Track *item)
 Inserts the given element accordingly to the comparator set by setComparator().
void addAll (IterT elemIter)
 Adds all elements delivered by the given Iterator.
bool remove (unsigned int pos)
 Removes the element at the given position from the container.
unsigned int count () const
 Returns the number of elements,.
bool isEmpty () const
 Returns true if the number of elements is zero meaning the container is empty, false otherwise.
Iterator iterator ()
 Returns a SortablePtrVector::Iterator over all elements of this Container.
ConstIterator iterator () const
 Returns a SortablePtrVector::ConstIterator over all elements of this Container.
ConstIterator const_iterator () const
 Returns a SortablePtrVector::ConstIterator over all elements of this Container.
FilteredIterator< TUnaryPredicate > filteredElements (const TUnaryPredicate &pred)
 Returns a FilteredIterator over those elements matching the given predicate.
FilteredConstIterator< TUnaryPredicate > filteredElements (const TUnaryPredicate &pred) const
 Returns a FilteredConstIterator over those elements matching the given predicate.
void append (itunesdb::Track *item)
 Appends the given element at the end of the container disregarding any comparator.
itunesdb::Trackoperator[] (unsigned int pos) const
 An operator to access the element at the given position.
itunesdb::Track *& operator[] (unsigned int pos)
 An operator to access the element at the given position.
itunesdb::Tracklast () const
 Returns a pointer to the last element.
void clear ()
 Removes all elements.

Detailed Description

A SortablePtrVector implementation for Track pointers.

The default sort order is set to Artist - Album - tracknumber

See also:
itunesdb::utils::SortablePtrVector for details about the base class

itunesdb::TrackComparators for a collection of predefined comparators

Examples:

listtests.cpp, and listtrackstest.cpp.


Member Typedef Documentation

typedef Comparator<itunesdb::Track > itunesdb::utils::SortablePtrVector< itunesdb::Track >::SortableVectorElemComparator [inherited]

Comparator Type definition.

typedef QTPOD_SHARED_PTR_IMPL_DEF< SortableVectorElemComparator > itunesdb::utils::SortablePtrVector< itunesdb::Track >::ComparatorPtr [inherited]

Shared Pointer type managing the pointer to the comparator.

typedef FilteredIterator itunesdb::utils::SortablePtrVector< itunesdb::Track >::Iterator [inherited]

An unfiltered Iterator over all elements of this container.

typedef FilteredConstIterator itunesdb::utils::SortablePtrVector< itunesdb::Track >::ConstIterator [inherited]

A const Iterator over all elements of this container.

See also:
RangeIterator for more details


Constructor & Destructor Documentation

itunesdb::TrackPtrList::TrackPtrList (  ) 

Creates an empty TrackPtrList.

The default sort order ist set accordingly to setDefaultSortOrder()

template<typename IterT>
itunesdb::TrackPtrList::TrackPtrList ( IterT  elements  )  [inline]

Creates a TrackPtrList and fills in the itunesdb::Track pointers returned by the given utils::RangeIterator.

The default sort order ist set accordingly to setDefaultSortOrder()

Parameters:
elements the Tracks to be filled in to the list


Member Function Documentation

bool itunesdb::TrackPtrList::hasDirtyTracks (  )  const

Returns true if this list contains tracks not in sync with the database.

bool itunesdb::TrackPtrList::hasRecentlyPlayedTracks (  )  const

Returns true if this list contains tracks being played after the last sync.

TrackPtrList * itunesdb::TrackPtrList::getTracksBy ( TrackPredicate predicate,
itunesdb::TrackPtrList buffer 
) const

Returns all the Tracks where the given predicate returned true.

Track * itunesdb::TrackPtrList::findFirstTrackBy ( TrackPredicate predicate  )  const

Returns the first Track where the given predicate returned true.

The given trackpredicate needs to contain a method that gets a track, and returns a bool if it's the desired track

Returns:
the first Track where the given predicate returned true
See also:
class TrackPredicate

bool itunesdb::TrackPtrList::removeIfTrue ( TrackPredicate predicate  ) 

Removes the elements the given predicate returns true.

Returns:
true if at least one of the elements got removed.

bool itunesdb::TrackPtrList::removeAllRefs ( itunesdb::Track track  ) 

Removes all references to the given track.

Returns:
true if at least one element got removed. false otherwise

void itunesdb::TrackPtrList::setDefaultSortOrder (  ) 

Sets the sort order to default ( Artist/Album/Tracknumber ).

void itunesdb::utils::SortablePtrVector< itunesdb::Track >::setComparator ( SortableVectorElemComparator comparator  )  [inline, inherited]

Sets the comparator for this container to by used by sort() and inSort().

Parameters:
comparator the comparator to be set. The pointer is owned by the container and will be deleted if a new comparator is set.
Examples:
listtests.cpp, and listtrackstest.cpp.

void itunesdb::utils::SortablePtrVector< itunesdb::Track >::setComparator ( const ComparatorPtr comparator  )  [inline, inherited]

Sets the comparator for this container to by used by sort() and inSort().

Parameters:
comparator the comparator to be set. The comparators lifecycle is managed by the ComparatorPtr.

const ComparatorPtr& itunesdb::utils::SortablePtrVector< itunesdb::Track >::getComparator (  )  const [inline, inherited]

Returns the currently used comparator for sorting.

Returns:
the currently used comparator for sorting.

void itunesdb::utils::SortablePtrVector< itunesdb::Track >::sort (  )  [inline, inherited]

Sorts the containers element using the comparator set by setComparator().

If no comparator has been set the order is kept unchanged.

Examples:
listtests.cpp, and listtrackstest.cpp.

void itunesdb::utils::SortablePtrVector< itunesdb::Track >::randomize (  )  [inline, inherited]

Randomizes the order of the elements.

unsigned int itunesdb::utils::SortablePtrVector< itunesdb::Track >::inSort ( itunesdb::Track item  )  [inline, inherited]

Inserts the given element accordingly to the comparator set by setComparator().

If no comparator has been set the element will be appended at the end.

Parameters:
item the element to be inserted
Returns:
the position/index of the item in this vector.

void itunesdb::utils::SortablePtrVector< itunesdb::Track >::addAll ( IterT  elemIter  )  [inline, inherited]

Adds all elements delivered by the given Iterator.

bool itunesdb::utils::SortablePtrVector< itunesdb::Track >::remove ( unsigned int  pos  )  [inline, inherited]

Removes the element at the given position from the container.

If the container was created with deleteElements set to true the element will be deleted.

Parameters:
pos the position of the element to be removed.
Returns:
true if the given position was valid accordingly to the number of elements.

unsigned int itunesdb::utils::SortablePtrVector< itunesdb::Track >::count (  )  const [inline, inherited]

Returns the number of elements,.

Returns:
the number of elements,

bool itunesdb::utils::SortablePtrVector< itunesdb::Track >::isEmpty (  )  const [inline, inherited]

Returns true if the number of elements is zero meaning the container is empty, false otherwise.

Returns:
true if the container is empty.

Iterator itunesdb::utils::SortablePtrVector< itunesdb::Track >::iterator (  )  [inline, inherited]

Returns a SortablePtrVector::Iterator over all elements of this Container.

Returns:
a SortablePtrVector::Iterator over all elements of this Container
Examples:
listtests.cpp, and listtrackstest.cpp.

ConstIterator itunesdb::utils::SortablePtrVector< itunesdb::Track >::iterator (  )  const [inline, inherited]

Returns a SortablePtrVector::ConstIterator over all elements of this Container.

Returns:
a SortablePtrVector::ConstIterator over all elements of this Container

ConstIterator itunesdb::utils::SortablePtrVector< itunesdb::Track >::const_iterator (  )  const [inline, inherited]

Returns a SortablePtrVector::ConstIterator over all elements of this Container.

Returns:
a SortablePtrVector::ConstIterator over all elements of this Container

FilteredIterator<TUnaryPredicate> itunesdb::utils::SortablePtrVector< itunesdb::Track >::filteredElements ( const TUnaryPredicate &  pred  )  [inline, inherited]

Returns a FilteredIterator over those elements matching the given predicate.

Parameters:
pred the predicate used for filtering
Returns:
a filtered Iterator over the elements of this container.

FilteredConstIterator<TUnaryPredicate> itunesdb::utils::SortablePtrVector< itunesdb::Track >::filteredElements ( const TUnaryPredicate &  pred  )  const [inline, inherited]

Returns a FilteredConstIterator over those elements matching the given predicate.

Parameters:
pred the predicate used for filtering
Returns:
a filtered const Iterator over the elements of this container.

void itunesdb::utils::SortablePtrVector< itunesdb::Track >::append ( itunesdb::Track item  )  [inline, inherited]

Appends the given element at the end of the container disregarding any comparator.

Parameters:
item the element to be appended.

itunesdb::Track * itunesdb::utils::SortablePtrVector< itunesdb::Track >::operator[] ( unsigned int  pos  )  const [inline, inherited]

An operator to access the element at the given position.

Parameters:
pos the position of the element to be returned
Returns:
a pointer to the element at the given position

itunesdb::Track *& itunesdb::utils::SortablePtrVector< itunesdb::Track >::operator[] ( unsigned int  pos  )  [inline, inherited]

An operator to access the element at the given position.

Parameters:
pos the position of the element to be returned
Returns:
a reference to the pointer at the given position

itunesdb::Track * itunesdb::utils::SortablePtrVector< itunesdb::Track >::last (  )  const [inline, inherited]

Returns a pointer to the last element.

Returns:
a pointer to the last element.

void itunesdb::utils::SortablePtrVector< itunesdb::Track >::clear (  )  [inline, inherited]

Removes all elements.


The documentation for this class was generated from the following files:
Generated on Wed Dec 19 00:15:20 2007 for libqtpod by  doxygen 1.5.0