Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
TrackList Class Referencefinal

A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list of tracks, event notifications. More...

#include <Track.h>

Inheritance diagram for TrackList:
[legend]
Collaboration diagram for TrackList:
[legend]

Public Types

using iterator = TrackIter< Track >
 
using const_iterator = TrackIter< const Track >
 
using value_type = Track *
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
- Public Types inherited from Observer::Publisher< TrackListEvent >
using message_type = TrackListEvent
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const TrackListEvent &) >
 Type of functions that can be connected to the Publisher. More...
 

Public Member Functions

 TrackList (AudacityProject *pOwner)
 
void Swap (TrackList &that)
 
virtual ~TrackList ()
 
AudacityProjectGetOwner ()
 
const AudacityProjectGetOwner () const
 
wxString MakeUniqueTrackName (const wxString &baseTrackName) const
 Returns string that contains baseTrackName, but is guaranteed to be unique among other tracks in that list. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
TrackIter< TrackDoFind (Track *pTrack)
 
TrackIter< TrackFind (Track *pTrack)
 
TrackIter< const TrackFind (const Track *pTrack) const
 
template<typename TrackType = Track>
auto Any () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto Any () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
template<typename TrackType = Track>
auto Selected () -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track>
auto Selected () const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
void Insert (const Track *before, const Track::Holder &pSrc, bool assignIds=false)
 Moves *pSrc to position where before is located. If before is nullptr the track is appended. More...
 
void Permute (const std::vector< Track * > &tracks)
 
TrackFindById (TrackId id)
 
template<typename TrackKind >
TrackKind * AddToHead (const std::shared_ptr< TrackKind > &t)
 Add a Track, giving it a fresh id if this is not temporary. More...
 
template<typename TrackKind >
TrackKind * Add (const std::shared_ptr< TrackKind > &t, bool assignIds=true)
 
Track::Holder ReplaceOne (Track &t, TrackList &&with)
 
Track::Holder Remove (Track &track)
 Remove a track and return it. More...
 
void Clear (bool sendEvent=true)
 Make the list empty. More...
 
bool CanMoveUp (Track &t) const
 
bool CanMoveDown (Track &t) const
 
bool MoveUp (Track &t)
 
bool MoveDown (Track &t)
 
bool Move (Track &t, bool up)
 
template<typename Subclass >
std::shared_ptr< Subclass > Lock (const std::weak_ptr< Subclass > &wTrack)
 
bool empty () const
 
size_t Size () const
 
double GetStartTime () const
 Return the least start time of the tracks, or 0 when no tracks. More...
 
double GetEndTime () const
 Return the greatest end time of the tracks, or 0 when no tracks. More...
 
void Append (TrackList &&list, bool assignIds=true)
 Remove all tracks from list and put them at the end of this More...
 
void AppendOne (TrackList &&list)
 Remove first track (if any) from list and put it at the end of this More...
 
Track::Holder DetachFirst ()
 Remove and return the first track. More...
 
- Public Member Functions inherited from Observer::Publisher< TrackListEvent >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static TrackListGet (AudacityProject &project)
 
static const TrackListGet (const AudacityProject &project)
 
static TrackListHolder Create (AudacityProject *pOwner)
 
template<typename TrackType >
static auto SingletonRange (TrackType *pTrack) -> TrackIterRange< TrackType >
 
template<typename TrackType >
static auto Channels (TrackType *pTrack) -> TrackIterRange< TrackType >
 
static TrackListHolder Temporary (AudacityProject *pProject, const Track::Holder &pTrack={})
 
static void AssignUniqueId (const Track::Holder &track)
 Assigns a new unique non-persistent id to a track. More...
 

Private Member Functions

 TrackList (const TrackList &that)=delete
 
TrackListoperator= (const TrackList &)=delete
 
 TrackList (TrackList &&that)=delete
 
TrackListoperator= (TrackList &&)=delete
 
void clear ()=delete
 
iterator Begin ()
 This private function still iterates channels not tracks. More...
 
iterator End ()
 This private function still iterates channels not tracks. More...
 
const_iterator Begin () const
 This private function still iterates channels not tracks. More...
 
const_iterator End () const
 This private function still iterates channels not tracks. More...
 
TrackDoAddToHead (const std::shared_ptr< Track > &t)
 
TrackDoAdd (const std::shared_ptr< Track > &t, bool assignIds)
 
template<typename TrackType = Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto Tracks (const Pred &pred={}) -> TrackIterRange< TrackType >
 
template<typename TrackType = const Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto Tracks (const Pred &pred={}) const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
 
TrackGetPrev (Track &, bool linked=false) const
 
TrackGetNext (Track &, bool linked=false) const
 Return a track in the list that comes after Track t. More...
 
template<typename TrackType >
TrackIter< TrackType > MakeTrackIterator (TrackNodePointer iter) const
 
template<typename TrackType >
TrackIter< TrackType > EndIterator () const
 
TrackIterRange< TrackEmptyRange () const
 
bool isNull (TrackNodePointer p) const
 
TrackNodePointer getEnd () const
 
TrackNodePointer getBegin () const
 
TrackNodePointer getNext (TrackNodePointer p) const
 Move an iterator to the next node, if any; else stay at end. More...
 
TrackNodePointer getPrev (TrackNodePointer p) const
 Move an iterator to the previous node, if any; else wrap to end. More...
 
void RecalcPositions (TrackNodePointer node)
 
void QueueEvent (TrackListEvent event)
 
void SelectionEvent (Track &track)
 
void PermutationEvent (TrackNodePointer node)
 
void DataEvent (const std::shared_ptr< Track > &pTrack, bool allChannels, int code)
 
void DeletionEvent (std::weak_ptr< Track > node, bool duringReplace)
 
void AdditionEvent (TrackNodePointer node)
 
void ResizingEvent (TrackNodePointer node)
 
void SwapNodes (TrackNodePointer s1, TrackNodePointer s2)
 

Static Private Member Functions

template<typename TrackType , typename InTrackType >
static TrackIterRange< TrackType > Channels_ (TrackIter< InTrackType > iter1)
 

Private Attributes

AudacityProjectmOwner
 
bool mAssignsIds { true }
 

Static Private Attributes

static long sCounter = -1
 

Friends

class Track
 

Additional Inherited Members

- Static Public Attributes inherited from Observer::Publisher< TrackListEvent >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< TrackListEvent >
CallbackReturn Publish (const TrackListEvent &message)
 Send a message to connected callbacks. More...
 

Detailed Description

A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list of tracks, event notifications.

Definition at line 845 of file Track.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 902 of file Track.h.

◆ const_reverse_iterator

using TrackList::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 914 of file Track.h.

◆ iterator

Definition at line 901 of file Track.h.

◆ reverse_iterator

using TrackList::reverse_iterator = std::reverse_iterator<iterator>

Definition at line 913 of file Track.h.

◆ value_type

Definition at line 904 of file Track.h.

Constructor & Destructor Documentation

◆ TrackList() [1/3]

TrackList::TrackList ( const TrackList that)
privatedelete

◆ TrackList() [2/3]

TrackList::TrackList ( TrackList &&  that)
privatedelete

◆ TrackList() [3/3]

TrackList::TrackList ( AudacityProject pOwner)
explicit

Definition at line 324 of file Track.cpp.

325 : mOwner{ pOwner }
326{
327}
AudacityProject * mOwner
Definition: Track.h:1222

◆ ~TrackList()

TrackList::~TrackList ( )
virtual

Definition at line 364 of file Track.cpp.

365{
366 Clear(false);
367}
void Clear(bool sendEvent=true)
Make the list empty.
Definition: Track.cpp:605

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

template<typename TrackKind >
TrackKind * TrackList::Add ( const std::shared_ptr< TrackKind > &  t,
bool  assignIds = true 
)
inline

Add a Track, giving it a fresh id if this is not temporary and assignIds is true

Definition at line 1048 of file Track.h.

1050 { return static_cast<TrackKind*>(DoAdd(t, assignIds)); }
Track * DoAdd(const std::shared_ptr< Track > &t, bool assignIds)
Definition: Track.cpp:540

Referenced by Append(), AppendOne(), PendingTracks::ApplyPendingTracks(), LabelTrack::Create(), AUPImportFileHandle::HandleLabelTrack(), AUPImportFileHandle::HandleNoteTrack(), AUPImportFileHandle::HandleTimeTrack(), AUPImportFileHandle::HandleWaveTrack(), Insert(), LabelTrack::PasteInto(), NoteTrack::PasteInto(), TimeTrack::PasteInto(), WaveTrack::PasteInto(), anonymous_namespace{UndoTracks.cpp}::TrackListRestorer::TrackListRestorer(), and LabelDialog::TransferDataFromWindow().

Here is the caller graph for this function:

◆ AdditionEvent()

void TrackList::AdditionEvent ( TrackNodePointer  node)
private

Definition at line 442 of file Track.cpp.

443{
445}
void QueueEvent(TrackListEvent event)
Definition: Track.cpp:403
@ ADDITION
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
Definition: Track.h:819

References TrackListEvent::ADDITION, and QueueEvent().

Referenced by DoAdd(), DoAddToHead(), and ReplaceOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddToHead()

template<typename TrackKind >
TrackKind * TrackList::AddToHead ( const std::shared_ptr< TrackKind > &  t)
inline

Add a Track, giving it a fresh id if this is not temporary.

Definition at line 1042 of file Track.h.

1043 { return static_cast<TrackKind*>(DoAddToHead(t)); }
Track * DoAddToHead(const std::shared_ptr< Track > &t)
Definition: Track.cpp:528

◆ Any() [1/2]

template<typename TrackType = Track>
auto TrackList::Any ( ) -> TrackIterRange< TrackType >
inline

Definition at line 950 of file Track.h.

952 {
953 return Tracks< TrackType >( &Track::IsLeader );
954 }
bool IsLeader() const
Definition: Track.cpp:261

References Track::IsLeader().

Referenced by anonymous_namespace{Track.cpp}::Accumulate(), audacity::cloud::audiocom::sync::anonymous_namespace{MixdownUploader.cpp}::CalculateChannels(), audacity::cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::CalculateChannels(), PendingTracks::ClearPendingTracks(), LabelDefaultClickHandle::Click(), anonymous_namespace{EditMenus.cpp}::CutCopyAvailableFlag(), LabelTrackView::DoKeyDown(), TimeShiftHandle::DoSlideVertical(), TrackPanel::DrawTracks(), EffectOutputTracks::EffectOutputTracks(), ControlToolBar::EnableDisableButtons(), TranscriptionToolBar::EnableDisableButtons(), anonymous_namespace{EditMenus.cpp}::EstimateCopiedBlocks(), anonymous_namespace{EditMenus.cpp}::EstimateCopyBytesCount(), LabelDialog::FindAllLabels(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), anonymous_namespace{EditMenus.cpp}::FindCorrespondence(), ImportUtils::ForEachChannel(), GetAllSeqBlocks(), anonymous_namespace{EditMenus.cpp}::HasHiddenData(), MixerBoard::HasSolo(), ProjectFileManager::Import(), ProjectFileManager::ImportAndRunTempoDetection(), VampEffect::Init(), MakeTransportTracks(), anonymous_namespace{ExportMIDI.cpp}::NoteTracksExistFlag(), ExportFilePanel::OnChannelsConfigure(), ExportAudioDialog::OnExport(), TranscriptionToolBar::PlayAtSpeed(), TrackSelectHandle::Preview(), FindClippingBase::Process(), NyquistBase::Process(), NyquistBase::ProcessOne(), PerTrackEffect::ProcessPass(), RealtimeEffectPanel::RealtimeEffectPanel(), anonymous_namespace{TimeTrackMenuItems.cpp}::TimeTrackDoesNotExistFlag(), TracksExistFlag(), LabelDialog::TransferDataFromWindow(), ExportFilePanel::UpdateMaxChannels(), MixerBoard::UpdateTrackClusters(), TrackPanel::UpdateVRulerSize(), WaveTracksExistFlag(), ZoomInAvailableFlag(), and ZoomOutAvailableFlag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Any() [2/2]

template<typename TrackType = const Track>
auto TrackList::Any ( ) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inline

Definition at line 957 of file Track.h.

961 {
962 return Tracks< TrackType >( &Track::IsLeader );
963 }

References Track::IsLeader().

Here is the call graph for this function:

◆ Append()

void TrackList::Append ( TrackList &&  list,
bool  assignIds = true 
)

Remove all tracks from list and put them at the end of this

Parameters
assignIdsignored if this is a temporary list; else if false, suppresses TrackId assignment

Definition at line 875 of file Track.cpp.

876{
877 auto iter = list.ListOfTracks::begin(),
878 end = list.ListOfTracks::end();
879 while (iter != end) {
880 auto pTrack = *iter;
881 iter = list.erase(iter);
882 this->Add(pTrack, assignIds);
883 }
884}
iterator end()
Definition: Track.h:906
TrackKind * Add(const std::shared_ptr< TrackKind > &t, bool assignIds=true)
Definition: Track.h:1048

References Add(), and end().

Referenced by PendingTracks::RegisterPendingNewTracks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AppendOne()

void TrackList::AppendOne ( TrackList &&  list)

Remove first track (if any) from list and put it at the end of this

Definition at line 886 of file Track.cpp.

887{
888 const auto iter = list.ListOfTracks::begin(),
889 end = list.ListOfTracks::end();
890 if (iter != end) {
891 auto pTrack = *iter;
892 list.erase(iter);
893 this->Add(pTrack);
894 }
895}

References Add(), and end().

Referenced by EffectOutputTracks::Commit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AssignUniqueId()

void TrackList::AssignUniqueId ( const Track::Holder track)
static

Assigns a new unique non-persistent id to a track.

Definition at line 870 of file Track.cpp.

871{
872 track->SetId(TrackId{ ++sCounter });
873}
An in-session identifier of track objects across undo states. It does not persist between sessions.
Definition: Track.h:79
static long sCounter
Definition: Track.h:1220

References sCounter.

Referenced by WaveTrack::SplitChannels().

Here is the caller graph for this function:

◆ begin() [1/2]

iterator TrackList::begin ( )
inline

Definition at line 905 of file Track.h.

905{ return Any().begin(); }
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950

Referenced by PendingTracks::ApplyPendingTracks(), PendingTracks::DoSubstituteOriginalChannel(), PendingTracks::HasPendingTracks(), and SwapNodes().

Here is the caller graph for this function:

◆ Begin() [1/2]

iterator TrackList::Begin ( )
inlineprivate

This private function still iterates channels not tracks.

Definition at line 939 of file Track.h.

939{ return Tracks<Track>().begin(); }

Referenced by empty().

Here is the caller graph for this function:

◆ begin() [2/2]

const_iterator TrackList::begin ( ) const
inline

Definition at line 907 of file Track.h.

907{ return Any().begin(); }

◆ Begin() [2/2]

const_iterator TrackList::Begin ( ) const
inlineprivate

This private function still iterates channels not tracks.

Definition at line 944 of file Track.h.

944{ return Tracks<const Track>().begin(); }

◆ CanMoveDown()

bool TrackList::CanMoveDown ( Track t) const

Definition at line 677 of file Track.cpp.

678{
679 return GetNext(t, true) != nullptr;
680}
Track * GetNext(Track &, bool linked=false) const
Return a track in the list that comes after Track t.
Definition: Track.cpp:622

References GetNext().

Here is the call graph for this function:

◆ CanMoveUp()

bool TrackList::CanMoveUp ( Track t) const

Definition at line 672 of file Track.cpp.

673{
674 return GetPrev(t, true) != nullptr;
675}
Track * GetPrev(Track &, bool linked=false) const
Definition: Track.cpp:638

References GetPrev().

Here is the call graph for this function:

◆ cbegin()

const_iterator TrackList::cbegin ( ) const
inline

Definition at line 909 of file Track.h.

909{ return begin(); }
iterator begin()
Definition: Track.h:905

References details::begin().

Here is the call graph for this function:

◆ cend()

const_iterator TrackList::cend ( ) const
inline

Definition at line 910 of file Track.h.

910{ return end(); }

References details::end().

Here is the call graph for this function:

◆ Channels()

template<typename TrackType >
static auto TrackList::Channels ( TrackType *  pTrack) -> TrackIterRange< TrackType >
inlinestatic

Definition at line 1016 of file Track.h.

1018 {
1019 return Channels_<TrackType>(pTrack->GetOwner()->Find(pTrack));
1020 }

Referenced by DataEvent(), WaveTrack::FormatConsistencyCheck(), WaveTrack::LinkConsistencyFix(), Permute(), WaveTrack::RateConsistencyCheck(), ProjectFileManager::ReadProjectFile(), and SelectionEvent().

Here is the caller graph for this function:

◆ Channels_()

template<typename TrackType , typename InTrackType >
static TrackIterRange< TrackType > TrackList::Channels_ ( TrackIter< InTrackType >  iter1)
inlinestaticprivate

Definition at line 995 of file Track.h.

996 {
997 if (*iter1) {
998 return {
999 iter1.Filter( &Track::Any )
1000 .template Filter<TrackType>(),
1001 (++iter1).Filter( &Track::Any )
1002 .template Filter<TrackType>()
1003 };
1004 }
1005 else
1006 // empty range
1007 return {
1008 iter1.template Filter<TrackType>(),
1009 iter1.template Filter<TrackType>()
1010 };
1011 }
bool Any() const
Definition: Track.cpp:255
TrackIter Filter(const Predicate2 &pred2) const
Return an iterator that replaces the predicate.
Definition: Track.h:547
Select only the subsequence of the type list satisfying the predicate.
Definition: TypeList.h:500

References Track::Any(), and TrackIter< TrackType >::Filter().

Here is the call graph for this function:

◆ clear()

void TrackList::clear ( )
privatedelete

◆ Clear()

void TrackList::Clear ( bool  sendEvent = true)

Make the list empty.

Definition at line 605 of file Track.cpp.

606{
607 // Null out the back-pointers to this in tracks, in case there
608 // are outstanding shared_ptrs to those tracks, making them outlive
609 // the temporary ListOfTracks below.
610 for (auto pTrack: Tracks<Track>()) {
611 pTrack->SetOwner({}, {});
612
613 if (sendEvent)
614 DeletionEvent(pTrack->shared_from_this(), false);
615 }
616
617 ListOfTracks tempList;
618 tempList.swap( *this );
619}
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:44
void DeletionEvent(std::weak_ptr< Track > node, bool duringReplace)
Definition: Track.cpp:436

References DeletionEvent().

Referenced by ~TrackList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ crbegin()

const_reverse_iterator TrackList::crbegin ( ) const
inline

Definition at line 919 of file Track.h.

919{ return rbegin(); }
reverse_iterator rbegin()
Definition: Track.h:915

◆ Create()

TrackListHolder TrackList::Create ( AudacityProject pOwner)
static

◆ crend()

const_reverse_iterator TrackList::crend ( ) const
inline

Definition at line 920 of file Track.h.

920{ return rend(); }
reverse_iterator rend()
Definition: Track.h:916

◆ DataEvent()

void TrackList::DataEvent ( const std::shared_ptr< Track > &  pTrack,
bool  allChannels,
int  code 
)
private

Definition at line 418 of file Track.cpp.

420{
421 auto doQueueEvent = [this, code](const std::shared_ptr<Track> &theTrack){
423 };
424 if (allChannels)
425 for (auto channel : Channels(pTrack.get()))
426 doQueueEvent(channel->shared_from_this());
427 else
428 doQueueEvent(pTrack);
429}
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1016
@ TRACK_DATA_CHANGE
Posted when certain fields of a track change.
Definition: Track.h:809

References Channels(), QueueEvent(), and TrackListEvent::TRACK_DATA_CHANGE.

Here is the call graph for this function:

◆ DeletionEvent()

void TrackList::DeletionEvent ( std::weak_ptr< Track node,
bool  duringReplace 
)
private

Definition at line 436 of file Track.cpp.

437{
439 { TrackListEvent::DELETION, std::move(node), duringReplace ? 1 : 0 });
440}
@ DELETION
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
Definition: Track.h:825

References TrackListEvent::DELETION, and QueueEvent().

Referenced by Clear(), Remove(), and ReplaceOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DetachFirst()

Track::Holder TrackList::DetachFirst ( )

Remove and return the first track.

Definition at line 897 of file Track.cpp.

898{
899 auto iter = ListOfTracks::begin();
900 auto result = *iter;
901 erase(iter);
902 result->SetOwner({}, {});
903 return result;
904}
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References details::begin().

Here is the call graph for this function:

◆ DoAdd()

Track * TrackList::DoAdd ( const std::shared_ptr< Track > &  t,
bool  assignIds 
)
private

Definition at line 540 of file Track.cpp.

541{
542 if (!ListOfTracks::empty()) {
543 auto &pLast = *ListOfTracks::rbegin();
544 if (pLast->mLinkType != Track::LinkType::None)
545 t->CopyGroupProperties(*pLast);
546 }
547
548 push_back(t);
549
550 auto n = getPrev( getEnd() );
551
552 t->SetOwner(shared_from_this(), n);
553 if (mAssignsIds && assignIds)
554 t->SetId(TrackId{ ++sCounter });
556 AdditionEvent(n);
557 return back().get();
558}
void AdditionEvent(TrackNodePointer node)
Definition: Track.cpp:442
void RecalcPositions(TrackNodePointer node)
Definition: Track.cpp:387
TrackNodePointer getEnd() const
Definition: Track.h:1178
bool mAssignsIds
Definition: Track.h:1226
TrackNodePointer getPrev(TrackNodePointer p) const
Move an iterator to the previous node, if any; else wrap to end.
Definition: Track.h:1194

References AdditionEvent(), getEnd(), getPrev(), mAssignsIds, ChannelGroup::None, RecalcPositions(), and sCounter.

Here is the call graph for this function:

◆ DoAddToHead()

Track * TrackList::DoAddToHead ( const std::shared_ptr< Track > &  t)
private

Definition at line 528 of file Track.cpp.

529{
530 Track *pTrack = t.get();
531 push_front(ListOfTracks::value_type(t));
532 auto n = getBegin();
533 pTrack->SetOwner(shared_from_this(), n);
534 pTrack->SetId( TrackId{ ++sCounter } );
536 AdditionEvent(n);
537 return front().get();
538}
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
void SetOwner(const std::weak_ptr< TrackList > &list, TrackNodePointer node)
Update mNode when Track is added to TrackList, or removed from it.
Definition: Track.cpp:128
void SetId(TrackId id)
Definition: Track.h:138
TrackNodePointer getBegin() const
Definition: Track.h:1180

References AdditionEvent(), getBegin(), RecalcPositions(), sCounter, Track::SetId(), and Track::SetOwner().

Here is the call graph for this function:

◆ DoFind()

auto TrackList::DoFind ( Track pTrack)

Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track

Definition at line 462 of file Track.cpp.

463{
464 if (!pTrack || pTrack->GetOwner().get() != this)
465 return EndIterator<Track>();
466 else
467 return MakeTrackIterator<Track>(pTrack->GetNode());
468}
TrackNodePointer GetNode() const
Retrieve mNode with debug checks.
Definition: Track.cpp:122
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:230

Referenced by RecalcPositions().

Here is the caller graph for this function:

◆ empty()

bool TrackList::empty ( ) const

Definition at line 758 of file Track.cpp.

759{
760 return Begin() == End();
761}
iterator Begin()
This private function still iterates channels not tracks.
Definition: Track.h:939
iterator End()
This private function still iterates channels not tracks.
Definition: Track.h:941

References Begin(), and End().

Referenced by anonymous_namespace{Track.cpp}::Accumulate(), ImportCommand::Apply(), ProjectFileManager::DoImport(), ApplyMacroDialog::OnApplyToFiles(), and anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EmptyRange()

auto TrackList::EmptyRange ( ) const
private

Definition at line 452 of file Track.cpp.

454{
455 auto it = const_cast<TrackList*>(this)->getEnd();
456 return {
457 { it, it, it, &Track::Any },
458 { it, it, it, &Track::Any }
459 };
460}
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850

References Track::Any(), and getEnd().

Here is the call graph for this function:

◆ end() [1/2]

iterator TrackList::end ( )
inline

Definition at line 906 of file Track.h.

906{ return Any().end(); }

Referenced by Append(), AppendOne(), PendingTracks::ApplyPendingTracks(), PendingTracks::DoSubstituteOriginalChannel(), and PendingTracks::HasPendingTracks().

Here is the caller graph for this function:

◆ End() [1/2]

iterator TrackList::End ( )
inlineprivate

This private function still iterates channels not tracks.

Definition at line 941 of file Track.h.

941{ return Tracks<Track>().end(); }

Referenced by empty(), and RecalcPositions().

Here is the caller graph for this function:

◆ end() [2/2]

const_iterator TrackList::end ( ) const
inline

Definition at line 908 of file Track.h.

908{ return Any().end(); }

◆ End() [2/2]

const_iterator TrackList::End ( ) const
inlineprivate

This private function still iterates channels not tracks.

Definition at line 946 of file Track.h.

946{ return Tracks<const Track>().end(); }

◆ EndIterator()

template<typename TrackType >
TrackIter< TrackType > TrackList::EndIterator ( ) const
inlineprivate

Definition at line 1169 of file Track.h.

1170 {
1171 auto e = const_cast<TrackList*>(this)->getEnd();
1172 return { e, e, e };
1173 }

◆ Find() [1/2]

TrackIter< const Track > TrackList::Find ( const Track pTrack) const
inline

Definition at line 930 of file Track.h.

931 {
932 return const_cast<TrackList*>(this)->
933 Find(const_cast<Track*>(pTrack)).Filter<const Track>();
934 }
TrackIter< Track > Find(Track *pTrack)
Definition: Track.cpp:470

References ActiveProjects::Find().

Here is the call graph for this function:

◆ Find() [2/2]

auto TrackList::Find ( Track pTrack)

Definition at line 470 of file Track.cpp.

471{
472 auto iter = DoFind(pTrack);
473 while( *iter && ! ( *iter )->IsLeader() )
474 --iter;
475 return iter.Filter( &Track::IsLeader );
476}
TrackIter< Track > DoFind(Track *pTrack)
Definition: Track.cpp:462

References Track::IsLeader().

Referenced by TimeShiftHandle::DoSlideVertical(), anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence(), Insert(), and anonymous_namespace{ChannelView.cpp}::TrackPositioner::OnUpdate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindById()

Track * TrackList::FindById ( TrackId  id)

Definition at line 517 of file Track.cpp.

518{
519 // Linear search. Tracks in a project are usually very few.
520 // Search only the non-pending tracks.
521 auto it = std::find_if( ListOfTracks::begin(), ListOfTracks::end(),
522 [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
523 if (it == ListOfTracks::end())
524 return {};
525 return it->get();
526}
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::begin(), and details::end().

Referenced by PendingTracks::ApplyPendingTracks(), and PendingTracks::UpdatePendingTracks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [1/2]

TrackList & TrackList::Get ( AudacityProject project)
static

Definition at line 314 of file Track.cpp.

315{
316 return project.AttachedObjects::Get< TrackList >( key );
317}
const auto project
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: Track.cpp:310

References key, and project.

Referenced by ProjectFileManager::AddImportedTracks(), AdornedRulerPanel::AdornedRulerPanel(), AnyTracksSelectedPred(), AppendItem(), SetTrackBase::Apply(), ImportCommand::Apply(), SelectTimeCommand::Apply(), SelectTracksCommand::Apply(), SetClipCommand::Apply(), SetLabelCommand::Apply(), BrushHandleHitTest(), TrackSelectHandle::CalculateRearrangingThresholds(), TrackPanelResizeHandle::Cancel(), ProjectAudioManager::ChooseExistingRecordingTracks(), ButtonHandle::Click(), TrackPanelResizeHandle::Click(), LabelDefaultClickHandle::Click(), LabelGlyphHandle::Click(), SelectHandle::Click(), TimeShiftHandle::Click(), BackgroundHandle::Click(), Viewport::CollapseAllTracks(), ExportPluginHelpers::CreateMixer(), anonymous_namespace{EditMenus.cpp}::CutCopyAvailableFlag(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), anonymous_namespace{TrackMenus.cpp}::DoAlign(), anonymous_namespace{SelectMenus.cpp}::DoBoundaryMove(), anonymous_namespace{ClipMenus.cpp}::DoClipLeftOrRight(), LOFImportFileHandle::doDurationAndScrollOffset(), LabelTrackView::DoEditLabels(), AudacityApplicationLogic::DoEffect(), anonymous_namespace{FileMenus.cpp}::DoExport(), ExportAudioDialog::DoExportSplitByTracks(), ProjectFileManager::DoImport(), anonymous_namespace{ImportMIDI.cpp}::DoImportMIDI(), Scrubber::DoKeyboardScrub(), LabelTrackView::DoKeyDown(), SelectUtilities::DoListSelection(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), TrackUtilities::DoMoveTrack(), anonymous_namespace{SpectrumView.cpp}::DoNextPeakFrequency(), anonymous_namespace{NavigationMenus.cpp}::DoNextTrack(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), anonymous_namespace{EditMenus.cpp}::DoPasteText(), anonymous_namespace{NavigationMenus.cpp}::DoPrevTrack(), ProjectAudioManager::DoRecord(), TrackUtilities::DoRemoveTrack(), TrackUtilities::DoRemoveTracks(), ProjectFileManager::DoSave(), SelectUtilities::DoSelectSomething(), anonymous_namespace{SelectUtilities.cpp}::DoSelectTimeAndAudioTracks(), SelectUtilities::DoSelectTimeAndTracks(), anonymous_namespace{TrackMenus.cpp}::DoSortTracks(), TrackUtilities::DoTrackMute(), TrackUtilities::DoTrackSolo(), ButtonHandle::Drag(), TrackPanelResizeHandle::Drag(), LabelTextHandle::Drag(), NoteTrackVZoomHandle::Drag(), TimeTrackVZoomHandle::Drag(), SelectHandle::Drag(), TimeShiftHandle::Drag(), TrackSelectHandle::Drag(), anonymous_namespace{DropoutDetector.cpp}::DropoutSubscription::DropoutSubscription(), EditableTracksSelectedPred(), audacity::cloud::ShareAudioToolbar::EnableDisableButtons(), ControlToolBar::EnableDisableButtons(), TranscriptionToolBar::EnableDisableButtons(), EstimateRemovedBlocks(), TimerRecordDialog::ExecutePostRecordActions(), Viewport::ExpandAllTracks(), GetInfoCommand::ExploreTrackPanel(), ExportAudioDialog::ExportAudioDialog(), audacity::cloud::audiocom::sync::MixdownUploader::ExportProject(), audacity::cloud::audiocom::ShareAudioDialog::ExportProject(), anonymous_namespace{ClipMenus.cpp}::FindClipBoundaries(), anonymous_namespace{ClipMenus.cpp}::FindClips(), anonymous_namespace{EditMenus.cpp}::FindSourceTracks(), TrackFocus::FindTrack(), SpectrumView::ForAll(), ProjectFileIO::GenerateDoc(), Get(), GetAllSeqBlocks(), PlotSpectrumBase::GetAudio(), ContrastBase::GetDB(), anonymous_namespace{PitchAndSpeedDialog.cpp}::GetHitClip(), GetPropertiesOfSelected(), CompareAudioCommand::GetSelection(), SliderHandle::GetSlider(), TrackFocus::GetTracks(), Viewport::GetZoomOfToFit(), LabelGlyphHandle::HandleGlyphDragRelease(), AUPImportFileHandle::HandleImport(), AUPImportFileHandle::HandleLabelTrack(), AUPImportFileHandle::HandleNoteTrack(), AUPImportFileHandle::HandleTimeTrack(), AUPImportFileHandle::HandleWaveTrack(), audacity::cloud::audiocom::sync::anonymous_namespace{MixdownUploader.cpp}::HasPlayableTracks(), ExportUtils::HasSelectedAudio(), SelectHandle::HitTest(), AUPImportFileHandle::Import(), ProjectFileManager::Import(), ProjectFileManager::ImportAndRunTempoDetection(), anonymous_namespace{ProjectFileManager.cpp}::ImportProject(), EqualizationBase::Init(), NyquistBase::Init(), ExportFilePanel::Init(), anonymous_namespace{EditMenus.cpp}::JoinClipsAvailableFlag(), anonymous_namespace{LabelMenus.cpp}::LabelsSelectedFlag(), LabelTracksExistFlag(), LOFImportFileHandle::lofOpenFiles(), Scrubber::MaybeStartScrubbing(), MixerBoard::MixerBoard(), SpectralSelectionBar::ModifySpectralSelection(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), anonymous_namespace{TrackMenus.cpp}::MuteTracks(), anonymous_namespace{SelectMenus.cpp}::NearestZeroCrossing(), LabelTrack::New(), NoteTrack::New(), TimeTrack::New(), WaveTrack::New(), anonymous_namespace{ExportMIDI.cpp}::NoteTracksExistFlag(), anonymous_namespace{EditMenus.cpp}::NotificationScope(), ApplyMacroDialog::OnApplyToFiles(), ExportFilePanel::OnChannelsConfigure(), ProjectManager::OnCloseWindow(), anonymous_namespace{EditMenus.cpp}::OnCopy(), anonymous_namespace{LabelMenus.cpp}::OnCopyLabels(), SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), anonymous_namespace{EditMenus.cpp}::OnCut(), anonymous_namespace{LabelMenus.cpp}::OnCutLabels(), anonymous_namespace{EditMenus.cpp}::OnDelete(), anonymous_namespace{LabelMenus.cpp}::OnDeleteLabels(), anonymous_namespace{EditMenus.cpp}::OnDisjoin(), anonymous_namespace{LabelMenus.cpp}::OnDisjoinLabels(), anonymous_namespace{EditMenus.cpp}::OnDuplicate(), ExportAudioDialog::OnExport(), anonymous_namespace{FileMenus.cpp}::OnExportLabels(), anonymous_namespace{ExportMIDI.cpp}::OnExportMIDI(), NavigationActions::Handler::OnFirstTrack(), ContrastDialog::OnGetBackground(), ContrastDialog::OnGetForeground(), anonymous_namespace{FileMenus.cpp}::OnImportLabels(), anonymous_namespace{EditMenus.cpp}::OnJoin(), anonymous_namespace{LabelMenus.cpp}::OnJoinLabels(), NavigationActions::Handler::OnLastTrack(), WaveTrackMenuTable::OnMergeStereo(), anonymous_namespace{LabelMenus.cpp}::OnNewLabelTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewStereoTrack(), anonymous_namespace{TimeTrackMenuItems.cpp}::OnNewTimeTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewWaveTrack(), anonymous_namespace{FileMenus.cpp}::OnOpen(), anonymous_namespace{EditMenus.cpp}::OnPaste(), anonymous_namespace{LabelMenus.cpp}::OnPasteNewLabel(), anonymous_namespace{TransportMenus.cpp}::OnPunchAndRoll(), ProjectAudioManager::OnRecord(), anonymous_namespace{EditMenus.cpp}::OnRedo(), anonymous_namespace{TrackMenus.cpp}::OnResample(), SelectActions::Handler::OnSelectAll(), SelectActions::Handler::OnSelectCursorEnd(), SelectActions::Handler::OnSelectStartCursor(), SelectActions::Handler::OnSelectSyncLockSel(), SelectActions::Handler::OnSelectTrackStartToEnd(), anonymous_namespace{EditMenus.cpp}::OnSilence(), anonymous_namespace{LabelMenus.cpp}::OnSilenceLabels(), anonymous_namespace{EditMenus.cpp}::OnSplit(), anonymous_namespace{EditMenus.cpp}::OnSplitCut(), anonymous_namespace{LabelMenus.cpp}::OnSplitCutLabels(), anonymous_namespace{EditMenus.cpp}::OnSplitDelete(), anonymous_namespace{LabelMenus.cpp}::OnSplitDeleteLabels(), anonymous_namespace{LabelMenus.cpp}::OnSplitLabels(), anonymous_namespace{EditMenus.cpp}::OnSplitNew(), audacity::cloud::audiocom::sync::ProjectCloudExtension::OnSyncStarted(), anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveBottom(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveDown(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveTop(), anonymous_namespace{TrackMenus.cpp}::OnTrackMoveUp(), anonymous_namespace{EditMenus.cpp}::OnTrim(), anonymous_namespace{EditMenus.cpp}::OnUndo(), anonymous_namespace{ChannelView.cpp}::TrackPositioner::OnUpdate(), SelectActions::Handler::OnZeroCrossing(), ProjectFileManager::OpenProjectFile(), TimeTrack::PasteInto(), anonymous_namespace{MixerBoard.cpp}::PlayableTracksExistFlag(), TranscriptionToolBar::PlayAtSpeed(), ProjectAudioManager::PlayPlayRegion(), TrackSelectHandle::Preview(), EffectTwoPassSimpleMono::Process(), NyquistBase::Process(), SpectralDataManager::ProcessTracks(), audacity::cloud::audiocom::sync::LocalProjectSnapshot::ProjectBlocksLock::ProjectBlocksLock(), WaveTrack::ProjectNyquistFrequency(), ProjectFileManager::ReadProjectFile(), RealtimeEffectPanel::RealtimeEffectPanel(), ButtonHandle::Release(), LabelTextHandle::Release(), NoteTrackButtonHandle::Release(), NoteTrackVZoomHandle::Release(), TimeTrackVZoomHandle::Release(), LabelDefaultClickHandle::RestoreState(), anonymous_namespace{UndoTracks.cpp}::TrackListRestorer::RestoreUndoRedoState(), ProjectManager::SafeToOpenProjectInto(), ProjectFileIO::SaveCopy(), LabelDefaultClickHandle::SaveState(), Viewport::ScrollToBottom(), Viewport::ScrollToEnd(), anonymous_namespace{SelectMenus.cpp}::SeekWhenAudioInactive(), NoteTrackAffordanceHandle::SelectAt(), SelectUtilities::SelectNone(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendTracks(), Viewport::ShowTrack(), Scrubber::StartKeyboardScrubbing(), StereoRequiredFlag(), anonymous_namespace{TimeTrackMenuItems.cpp}::TimeTrackDoesNotExistFlag(), anonymous_namespace{UndoTracks.cpp}::TrackListRestorer::TrackListRestorer(), TracksExistFlag(), ExportAudioDialog::UpdateLabelExportSettings(), ExportFilePanel::UpdateMaxChannels(), ProjectSettings::UpdatePrefs(), RealtimeEffectPanel::PrefsListenerHelper::UpdatePrefs(), Viewport::UpdateScrollbarsForTracks(), ExportAudioDialog::UpdateTrackExportSettings(), HighlitClipButtonHandle::UpdateTrackSelection(), AffordanceHandle::UpdateTrackSelection(), WaveTracksExistFlag(), WaveTracksSelectedFlag(), ProjectFileIO::WriteXML(), Viewport::ZoomFitHorizontally(), Viewport::ZoomFitHorizontallyAndShowTrack(), Viewport::ZoomFitVertically(), ZoomInAvailableFlag(), and ZoomOutAvailableFlag().

◆ Get() [2/2]

const TrackList & TrackList::Get ( const AudacityProject project)
static

Definition at line 319 of file Track.cpp.

320{
321 return Get( const_cast< AudacityProject & >( project ) );
322}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References Get(), and project.

Here is the call graph for this function:

◆ getBegin()

TrackNodePointer TrackList::getBegin ( ) const
inlineprivate

Definition at line 1180 of file Track.h.

1181 { return const_cast<TrackList*>(this)->ListOfTracks::begin(); }

References details::begin().

Referenced by DoAddToHead(), and Permute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEnd()

TrackNodePointer TrackList::getEnd ( ) const
inlineprivate

Definition at line 1178 of file Track.h.

1179 { return const_cast<TrackList*>(this)->ListOfTracks::end(); }

References details::end().

Referenced by DoAdd(), EmptyRange(), and Remove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEndTime()

double TrackList::GetEndTime ( ) const

Return the greatest end time of the tracks, or 0 when no tracks.

Definition at line 784 of file Track.cpp.

785{
786 return Accumulate(*this, &Track::GetEndTime,
787 std::numeric_limits<double>::lowest(), std::max);
788}
double GetEndTime() const
Get the maximum of End() values of intervals, or 0 when none.
Definition: Channel.cpp:61
double Accumulate(const TrackList &list, double(Track::*memfn)() const, double ident, const double &(*combine)(const double &, const double &))
Definition: Track.cpp:765

References anonymous_namespace{Track.cpp}::Accumulate(), and ChannelGroup::GetEndTime().

Referenced by SelectTimeCommand::Apply(), LOFImportFileHandle::doDurationAndScrollOffset(), Scrubber::DoKeyboardScrub(), Scrubber::MaybeStartScrubbing(), ExportAudioDialog::OnExport(), Scrubber::StartKeyboardScrubbing(), and AdornedRulerPanel::StartQPPlay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNext()

Track * TrackList::GetNext ( Track t,
bool  linked = false 
) const
private

Return a track in the list that comes after Track t.

Definition at line 622 of file Track.cpp.

623{
624 auto node = t.GetNode();
625 if (!isNull(node)) {
626 if (linked && t.HasLinkedTrack())
627 node = getNext(node);
628
629 if (!isNull(node))
630 node = getNext(node);
631
632 if (!isNull(node))
633 return node->get();
634 }
635 return nullptr;
636}
bool HasLinkedTrack() const noexcept
During file loading only, true for leaders of multichannel groups.
Definition: Track.cpp:224
bool isNull(TrackNodePointer p) const
Definition: Track.h:1177
TrackNodePointer getNext(TrackNodePointer p) const
Move an iterator to the next node, if any; else stay at end.
Definition: Track.h:1184

References getNext(), Track::GetNode(), Track::HasLinkedTrack(), and isNull().

Referenced by CanMoveDown(), and MoveDown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNext()

TrackNodePointer TrackList::getNext ( TrackNodePointer  p) const
inlineprivate

Move an iterator to the next node, if any; else stay at end.

Definition at line 1184 of file Track.h.

1185 {
1186 if ( isNull(p) )
1187 return p;
1188 auto q = p;
1189 ++q;
1190 return q;
1191 }

Referenced by GetNext(), and Remove().

Here is the caller graph for this function:

◆ GetOwner() [1/2]

AudacityProject * TrackList::GetOwner ( )
inline

Definition at line 887 of file Track.h.

887{ return mOwner; }

Referenced by PendingTracks::ApplyPendingTracks(), EffectOutputTracks::EffectOutputTracks(), EffectBase::FindProject(), and StereoToMono::ProcessOne().

Here is the caller graph for this function:

◆ GetOwner() [2/2]

const AudacityProject * TrackList::GetOwner ( ) const
inline

Definition at line 888 of file Track.h.

888{ return mOwner; }

◆ GetPrev()

Track * TrackList::GetPrev ( Track t,
bool  linked = false 
) const
private

Definition at line 638 of file Track.cpp.

639{
640 TrackNodePointer prev;
641 auto node = t.GetNode();
642 if (!isNull(node)) {
643 // linked is true and input track second in team?
644 if (linked) {
645 prev = getPrev(node);
646 if (!isNull(prev) &&
647 !t.HasLinkedTrack() && t.GetLinkedTrack())
648 // Make it the first
649 node = prev;
650 }
651
652 prev = getPrev(node);
653 if (!isNull(prev)) {
654 // Back up once
655 node = prev;
656
657 // Back up twice sometimes when linked is true
658 if (linked) {
659 prev = getPrev(node);
660 if( !isNull(prev) &&
661 !(*node)->HasLinkedTrack() &&
662 (*node)->GetLinkedTrack())
663 node = prev;
664 }
665
666 return node->get();
667 }
668 }
669 return nullptr;
670}
ListOfTracks::iterator TrackNodePointer
Definition: Track.h:46
Track * GetLinkedTrack() const
Definition: Track.cpp:198

References Track::GetLinkedTrack(), Track::GetNode(), getPrev(), Track::HasLinkedTrack(), and isNull().

Referenced by CanMoveUp(), and MoveUp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPrev()

TrackNodePointer TrackList::getPrev ( TrackNodePointer  p) const
inlineprivate

Move an iterator to the previous node, if any; else wrap to end.

Definition at line 1194 of file Track.h.

1195 {
1196 if (p == getBegin())
1197 return getEnd();
1198 else {
1199 auto q = p;
1200 --q;
1201 return q;
1202 }
1203 }

Referenced by DoAdd(), GetPrev(), and RecalcPositions().

Here is the caller graph for this function:

◆ GetStartTime()

double TrackList::GetStartTime ( ) const

Return the least start time of the tracks, or 0 when no tracks.

Definition at line 778 of file Track.cpp.

779{
780 return Accumulate(*this, &Track::GetStartTime,
781 std::numeric_limits<double>::max(), std::min);
782}
int min(int a, int b)
double GetStartTime() const
Get the minimum of Start() values of intervals, or 0 when none.
Definition: Channel.cpp:50

References anonymous_namespace{Track.cpp}::Accumulate(), ChannelGroup::GetStartTime(), and min().

Referenced by AdornedRulerPanel::StartQPPlay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Insert()

void TrackList::Insert ( const Track before,
const Track::Holder pSrc,
bool  assignIds = false 
)

Moves *pSrc to position where before is located. If before is nullptr the track is appended.

Parameters
assignIdsignored if this is a temporary list; else if false, suppresses TrackId assignment
Precondition
before == nullptr || (Find(before) != EndIterator<const Track>())

Definition at line 478 of file Track.cpp.

480{
481 assert(before == nullptr || Find(before) != EndIterator<const Track>());
482
483 if(before == nullptr)
484 {
485 Add(pSrc, assignIds);
486 return;
487 }
488
489 std::vector<Track *> arr;
490 arr.reserve(Size() + 1);
491 for (const auto track : *this) {
492 if (track == before)
493 arr.push_back(pSrc.get());
494 arr.push_back(track);
495 }
496 Add(pSrc, assignIds);
497 Permute(arr);
498}
void Permute(const std::vector< Track * > &tracks)
Definition: Track.cpp:500
size_t Size() const
Definition: Track.h:1091

References Add(), Find(), Permute(), and Size().

Referenced by PendingTracks::ApplyPendingTracks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNull()

bool TrackList::isNull ( TrackNodePointer  p) const
inlineprivate

Definition at line 1177 of file Track.h.

1177{ return p == ListOfTracks::end(); }

References details::end().

Referenced by GetNext(), GetPrev(), RecalcPositions(), Remove(), and SwapNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lock()

template<typename Subclass >
std::shared_ptr< Subclass > TrackList::Lock ( const std::weak_ptr< Subclass > &  wTrack)
inline

Definition at line 1079 of file Track.h.

1080 {
1081 auto pTrack = wTrack.lock();
1082 if (pTrack) {
1083 auto pList = pTrack->mList.lock();
1084 if (pTrack && this == pList.get())
1085 return pTrack;
1086 }
1087 return {};
1088 }

Referenced by ButtonHandle::Click(), ButtonHandle::Drag(), LabelTextHandle::Drag(), NoteTrackVZoomHandle::Drag(), TimeTrackVZoomHandle::Drag(), SliderHandle::GetSlider(), TrackPanel::ProcessUIHandleResult(), ButtonHandle::Release(), LabelTextHandle::Release(), NoteTrackButtonHandle::Release(), NoteTrackVZoomHandle::Release(), TimeTrackVZoomHandle::Release(), LabelDefaultClickHandle::RestoreState(), and NoteTrackAffordanceHandle::SelectAt().

Here is the caller graph for this function:

◆ MakeTrackIterator()

template<typename TrackType >
TrackIter< TrackType > TrackList::MakeTrackIterator ( TrackNodePointer  iter) const
inlineprivate

Definition at line 1160 of file Track.h.

1161 {
1162 auto b = const_cast<TrackList*>(this)->getBegin();
1163 auto e = const_cast<TrackList*>(this)->getEnd();
1164 return { b, iter, e };
1165 }

◆ MakeUniqueTrackName()

wxString TrackList::MakeUniqueTrackName ( const wxString &  baseTrackName) const

Returns string that contains baseTrackName, but is guaranteed to be unique among other tracks in that list.

Parameters
baseTrackNameString to be put into the template
Returns
Formatted string: "[baseTrackName] [N]"

Definition at line 369 of file Track.cpp.

370{
371 int n = 1;
372 while(true) {
373 auto name = wxString::Format("%s %d", baseTrackName, n++);
374
375 bool found {false};
376 for(const auto track : Tracks<const Track>()) {
377 if(track->GetName() == name) {
378 found = true;
379 break;
380 }
381 }
382 if(!found)
383 return name;
384 }
385}
wxString name
Definition: TagsEditor.cpp:166

References name.

Referenced by LabelTrack::Create().

Here is the caller graph for this function:

◆ Move()

bool TrackList::Move ( Track t,
bool  up 
)
inline

Definition at line 1074 of file Track.h.

1074{ return up ? MoveUp(t) : MoveDown(t); }
bool MoveUp(Track &t)
Definition: Track.cpp:738
bool MoveDown(Track &t)
Definition: Track.cpp:748

◆ MoveDown()

bool TrackList::MoveDown ( Track t)

Definition at line 748 of file Track.cpp.

749{
750 Track *n = GetNext(t, true);
751 if (n) {
752 SwapNodes(t.GetNode(), n->GetNode());
753 return true;
754 }
755 return false;
756}
void SwapNodes(TrackNodePointer s1, TrackNodePointer s2)
Definition: Track.cpp:685

References GetNext(), Track::GetNode(), and SwapNodes().

Here is the call graph for this function:

◆ MoveUp()

bool TrackList::MoveUp ( Track t)

Definition at line 738 of file Track.cpp.

739{
740 Track *p = GetPrev(t, true);
741 if (p) {
742 SwapNodes(p->GetNode(), t.GetNode());
743 return true;
744 }
745 return false;
746}

References Track::GetNode(), GetPrev(), and SwapNodes().

Here is the call graph for this function:

◆ operator=() [1/2]

TrackList & TrackList::operator= ( const TrackList )
privatedelete

◆ operator=() [2/2]

TrackList & TrackList::operator= ( TrackList &&  )
privatedelete

◆ PermutationEvent()

void TrackList::PermutationEvent ( TrackNodePointer  node)
private

Definition at line 431 of file Track.cpp.

432{
434}
@ PERMUTED
Posted when tracks are reordered but otherwise unchanged.
Definition: Track.h:813

References TrackListEvent::PERMUTED, and QueueEvent().

Referenced by Permute(), and SwapNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Permute()

void TrackList::Permute ( const std::vector< Track * > &  tracks)
Precondition
tracks contains pointers only to tracks of this, and each of them exactly once

Definition at line 500 of file Track.cpp.

501{
502 std::vector<TrackNodePointer> permutation;
503 for (const auto pTrack : tracks)
504 for (const auto pChannel : Channels(pTrack))
505 permutation.push_back(pChannel->GetNode());
506 for (const auto iter : permutation) {
507 ListOfTracks::value_type track = *iter;
508 erase(iter);
509 Track *pTrack = track.get();
510 pTrack->SetOwner(shared_from_this(), insert(ListOfTracks::end(), track));
511 }
512 auto n = getBegin();
515}
const auto tracks
void PermutationEvent(TrackNodePointer node)
Definition: Track.cpp:431

References Channels(), details::end(), getBegin(), PermutationEvent(), RecalcPositions(), Track::SetOwner(), and tracks.

Referenced by Insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ QueueEvent()

void TrackList::QueueEvent ( TrackListEvent  event)
private

Definition at line 403 of file Track.cpp.

404{
405 BasicUI::CallAfter( [wThis = weak_from_this(), event = std::move(event)]{
406 if (auto pThis = wThis.lock())
407 pThis->Publish(event);
408 } );
409}
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:214

References BasicUI::CallAfter().

Referenced by AdditionEvent(), DataEvent(), DeletionEvent(), PermutationEvent(), ResizingEvent(), and SelectionEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rbegin() [1/2]

reverse_iterator TrackList::rbegin ( )
inline

Definition at line 915 of file Track.h.

915{ return Any().rbegin(); }

Referenced by ChannelView::GetTotalHeight().

Here is the caller graph for this function:

◆ rbegin() [2/2]

const_reverse_iterator TrackList::rbegin ( ) const
inline

Definition at line 917 of file Track.h.

917{ return Any().rbegin(); }

◆ RecalcPositions()

void TrackList::RecalcPositions ( TrackNodePointer  node)
private

Definition at line 387 of file Track.cpp.

388{
389 if (isNull(node))
390 return;
391
392 Track *t;
393
394 auto prev = getPrev(node);
395 if (!isNull(prev))
396 t = prev->get();
397
398 const auto theEnd = End();
399 for (auto n = DoFind(node->get()); n != theEnd; ++n)
400 t = *n;
401}

References DoFind(), End(), getPrev(), and isNull().

Referenced by DoAdd(), DoAddToHead(), Permute(), Remove(), ReplaceOne(), and SwapNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Remove()

std::shared_ptr< Track > TrackList::Remove ( Track track)

Remove a track and return it.

Definition at line 584 of file Track.cpp.

585{
586 auto *t = &track;
587 auto iter = getEnd();
588 auto node = t->GetNode();
589 t->SetOwner({}, {});
590
591 std::shared_ptr<Track> holder;
592 if (!isNull(node)) {
593 holder = *node;
594
595 iter = getNext(node);
596 erase(node);
597 if (!isNull(iter))
598 RecalcPositions(iter);
599
600 DeletionEvent(t->shared_from_this(), false);
601 }
602 return holder;
603}

References DeletionEvent(), getEnd(), getNext(), isNull(), and RecalcPositions().

Referenced by PendingTracks::ClearPendingTracks(), and EffectOutputTracks::Commit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rend() [1/2]

reverse_iterator TrackList::rend ( )
inline

Definition at line 916 of file Track.h.

916{ return Any().rend(); }

◆ rend() [2/2]

const_reverse_iterator TrackList::rend ( ) const
inline

Definition at line 918 of file Track.h.

918{ return Any().rend(); }

◆ ReplaceOne()

Track::Holder TrackList::ReplaceOne ( Track t,
TrackList &&  with 
)

Replace track t with the first track in the given list, return the removed track, modify given list by removing first track

Give the replacements the same ids as the replaced

Precondition
t.GetOwner().get() == this
!with.empty()

Move one track to the temporary list

Redirect the list element of this

Definition at line 560 of file Track.cpp.

561{
562 assert(t.GetOwner().get() == this);
563 assert(!with.empty());
564
565 auto save = t.shared_from_this();
566
568 auto node = t.GetNode();
569 t.SetOwner({}, {});
570
572 const auto iter = with.ListOfTracks::begin();
573 const auto pTrack = *iter;
574 *node = pTrack;
575 with.erase(iter);
576 pTrack->SetOwner(shared_from_this(), node);
577 pTrack->SetId(save->GetId());
578 RecalcPositions(node);
579 DeletionEvent(save, true);
580 AdditionEvent(node);
581 return save;
582}
bool empty() const
Definition: Track.cpp:758

References AdditionEvent(), DeletionEvent(), Track::GetNode(), Track::GetOwner(), RecalcPositions(), and Track::SetOwner().

Referenced by PendingTracks::ApplyPendingTracks(), and EffectOutputTracks::Commit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResizingEvent()

void TrackList::ResizingEvent ( TrackNodePointer  node)
private

Definition at line 447 of file Track.cpp.

448{
450}
@ RESIZING
Posted when some track changed its height.
Definition: Track.h:816

References QueueEvent(), and TrackListEvent::RESIZING.

Here is the call graph for this function:

◆ Selected() [1/2]

template<typename TrackType = Track>
auto TrackList::Selected ( ) -> TrackIterRange<TrackType>
inline

◆ Selected() [2/2]

template<typename TrackType = const Track>
auto TrackList::Selected ( ) const -> std::enable_if_t<std::is_const_v<TrackType>, TrackIterRange<TrackType>>
inline

Definition at line 973 of file Track.h.

975 {
976 return Tracks<TrackType>(&Track::IsSelected);
977 }

References Track::IsSelected().

Here is the call graph for this function:

◆ SelectionEvent()

void TrackList::SelectionEvent ( Track track)
private

Definition at line 411 of file Track.cpp.

412{
413 for (auto channel : Channels(&track))
414 QueueEvent({
415 TrackListEvent::SELECTION_CHANGE, channel->shared_from_this() });
416}
@ SELECTION_CHANGE
Posted when the set of selected tracks changes.
Definition: Track.h:806

References Channels(), QueueEvent(), and TrackListEvent::SELECTION_CHANGE.

Here is the call graph for this function:

◆ SingletonRange()

template<typename TrackType >
static auto TrackList::SingletonRange ( TrackType *  pTrack) -> TrackIterRange< TrackType >
inlinestatic

Definition at line 981 of file Track.h.

983 {
984 return pTrack->GetOwner()->template Tracks<TrackType>()
985 .StartingWith( pTrack ).EndingAfter( pTrack );
986 }

References TrackIterRange< TrackType >::EndingAfter(), and TrackIterRange< TrackType >::StartingWith().

Referenced by TruncSilenceBase::ProcessIndependently(), and SelectionState::SelectTrackLength().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Size()

size_t TrackList::Size ( ) const
inline

Definition at line 1091 of file Track.h.

1091{ return Any().size(); }

References Track::Any().

Referenced by Insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Swap()

void TrackList::Swap ( TrackList that)
Precondition
!GetOwner() && !that.GetOwner()

Definition at line 346 of file Track.cpp.

347{
348 auto SwapLOTs = [](
349 ListOfTracks &a, const std::weak_ptr< TrackList > &aSelf,
350 ListOfTracks &b, const std::weak_ptr< TrackList > &bSelf )
351 {
352 a.swap(b);
353 for (auto it = a.begin(), last = a.end(); it != last; ++it)
354 (*it)->SetOwner(aSelf, it);
355 for (auto it = b.begin(), last = b.end(); it != last; ++it)
356 (*it)->SetOwner(bSelf, it);
357 };
358
359 const auto self = shared_from_this();
360 const auto otherSelf = that.shared_from_this();
361 SwapLOTs( *this, self, that, otherSelf );
362}

◆ SwapNodes()

void TrackList::SwapNodes ( TrackNodePointer  s1,
TrackNodePointer  s2 
)
private

Definition at line 685 of file Track.cpp.

686{
687 // if a null pointer is passed in, we want to know about it
688 wxASSERT(!isNull(s1));
689 wxASSERT(!isNull(s2));
690
691 // Safety check...
692 if (s1 == s2)
693 return;
694
695 // Be sure s1 is the earlier iterator
696 {
697 const auto begin = ListOfTracks::begin();
698 auto d1 = std::distance(begin, s1);
699 auto d2 = std::distance(begin, s2);
700 if (d1 > d2)
701 std::swap(s1, s2);
702 }
703
704 // For saving the removed tracks
705 using Saved = ListOfTracks::value_type;
706 Saved saved1, saved2;
707
708 auto doSave = [&](Saved &saved, TrackNodePointer &s) {
709 saved = *s, s = erase(s);
710 };
711
712 doSave(saved1, s1);
713 // The two ranges are assumed to be disjoint but might abut
714 const bool same = (s1 == s2);
715 doSave(saved2, s2);
716 if (same)
717 // Careful, we invalidated s1 in the second doSave!
718 s1 = s2;
719
720 // Reinsert them
721 auto doInsert = [&](Saved &saved, TrackNodePointer &s) {
722 const auto pTrack = saved.get();
723 // Insert before s, and reassign s to point at the new node before
724 // old s; which is why we saved pointers in backwards order
725 pTrack->SetOwner(shared_from_this(), s = insert(s, saved) );
726 };
727 // This does not invalidate s2 even when it equals s1:
728 doInsert(saved2, s1);
729 // Even if s2 was same as s1, this correctly inserts the saved1 range
730 // after the saved2 range, when done after:
731 doInsert(saved1, s2);
732
733 // Now correct the Index in the tracks, and other things
734 RecalcPositions(s1);
736}
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:634

References begin(), details::begin(), isNull(), PermutationEvent(), RecalcPositions(), and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by MoveDown(), and MoveUp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Temporary()

TrackListHolder TrackList::Temporary ( AudacityProject pProject,
const Track::Holder pTrack = {} 
)
static

Construct a temporary list owned by pProject (if that is not null) and owning pTrack TrackIds are not changed

Precondition
pTrack == nullptr || pTrack->GetOwner() == nullptr

Definition at line 858 of file Track.cpp.

860{
861 assert(pTrack == nullptr || pTrack->GetOwner() == nullptr);
862 // Make a well formed channel group from these tracks
863 auto tempList = Create(pProject);
864 if (pTrack)
865 tempList->Add(pTrack);
866 tempList->mAssignsIds = false;
867 return tempList;
868}
static TrackListHolder Create(AudacityProject *pOwner)
Definition: Track.cpp:330

References Create().

Referenced by PendingTracks::ApplyPendingTracks(), WaveTrackFactory::CreateMany(), ModifiedAnalysisTrack::ModifiedAnalysisTrack(), WaveTrack::MonoToStereo(), BenchmarkDialog::OnRun(), StereoToMono::ProcessOne(), PerTrackEffect::ProcessPass(), and ModifiedAnalysisTrack::~ModifiedAnalysisTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Tracks() [1/2]

template<typename TrackType = Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto TrackList::Tracks ( const Pred &  pred = {}) -> TrackIterRange< TrackType >
inlineprivate

Definition at line 1132 of file Track.h.

1132 {} )
1134 {
1135 auto b = getBegin(), e = getEnd();
1136 return { { b, b, e, pred }, { b, e, e, pred } };
1137 }
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Definition: Track.h:682

◆ Tracks() [2/2]

template<typename TrackType = const Track, typename Pred = typename TrackIterRange< TrackType >::iterator::FunctionType>
auto TrackList::Tracks ( const Pred &  pred = {}) const -> std::enable_if_t< std::is_const_v<TrackType>, TrackIterRange< TrackType > >
inlineprivate

Definition at line 1145 of file Track.h.

1145 {} ) const
1146 -> std::enable_if_t< std::is_const_v<TrackType>,
1148 >
1149 {
1150 auto b = const_cast<TrackList*>(this)->getBegin();
1151 auto e = const_cast<TrackList*>(this)->getEnd();
1152 return { { b, b, e, pred }, { b, e, e, pred } };
1153 }

Friends And Related Function Documentation

◆ Track

friend class Track
friend

Definition at line 1022 of file Track.h.

Member Data Documentation

◆ mAssignsIds

bool TrackList::mAssignsIds { true }
private

Whether the list assigns unique ids to added tracks; false for temporaries

Definition at line 1226 of file Track.h.

Referenced by DoAdd().

◆ mOwner

AudacityProject* TrackList::mOwner
private

Definition at line 1222 of file Track.h.

◆ sCounter

long TrackList::sCounter = -1
staticprivate

Definition at line 1220 of file Track.h.

Referenced by AssignUniqueId(), DoAdd(), and DoAddToHead().


The documentation for this class was generated from the following files: