Add convenience method to find tracks by ID

This commit is contained in:
Martchus 2017-06-11 01:17:13 +02:00
parent 2beb4b02aa
commit f7ce96f4f9
1 changed files with 12 additions and 0 deletions

View File

@ -37,6 +37,7 @@ public:
TagType *tag(std::size_t index);
std::size_t tagCount() const;
TrackType *track(std::size_t index);
TrackType *trackById(uint64 id);
std::size_t trackCount() const;
const std::vector<std::unique_ptr<TagType> > &tags() const;
std::vector<std::unique_ptr<TagType> > &tags();
@ -177,6 +178,17 @@ inline TrackType *GenericContainer<FileInfoType, TagType, TrackType, ElementType
return m_tracks[index].get();
}
template<class FileInfoType, class TagType, class TrackType, class ElementType>
inline TrackType *GenericContainer<FileInfoType, TagType, TrackType, ElementType>::trackById(uint64 id)
{
for (auto &track : m_tracks) {
if(track->id() == id) {
return track.get();
}
}
return nullptr;
}
template <class FileInfoType, class TagType, class TrackType, class ElementType>
inline std::size_t GenericContainer<FileInfoType, TagType, TrackType, ElementType>::trackCount() const
{