Add convenience method to find tracks by ID
This commit is contained in:
parent
2beb4b02aa
commit
f7ce96f4f9
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue