Audacity  2.2.2
Public Member Functions | Protected Attributes | List of all members
TrackListIterator Class Reference

An iterator for a TrackList. More...

#include <Track.h>

Inheritance diagram for TrackListIterator:
SyncLockedTracksIterator TrackListCondIterator TrackListOfKindIterator VisibleTrackIterator SelectedTrackListOfKindIterator

Public Member Functions

 TrackListIterator ()
 
 TrackListIterator (TrackList *val)
 
 TrackListIterator (TrackList *val, TrackNodePointer p)
 
 TrackListIterator (const TrackListIterator &)=default
 
TrackListIteratoroperator= (const TrackListIterator &)=default
 
virtual ~TrackListIterator ()
 
virtual TrackFirst (TrackList *val=nullptr)
 
virtual TrackStartWith (Track *val)
 
virtual TrackNext (bool skiplinked=false)
 
virtual TrackPrev (bool skiplinked=false)
 
virtual TrackLast (bool skiplinked=false)
 
TrackRemoveCurrent ()
 
Trackoperator* () const
 
TrackListIteratoroperator++ ()
 
TrackListIterator operator++ (int)
 
bool operator== (const TrackListIterator &other) const
 
bool operator!= (const TrackListIterator &other) const
 

Protected Attributes

friend TrackList
 
TrackListl {}
 
TrackNodePointer cur {}
 

Detailed Description

An iterator for a TrackList.

Definition at line 402 of file Track.h.

Constructor & Destructor Documentation

TrackListIterator::TrackListIterator ( )
inline

Definition at line 408 of file Track.h.

408 {}
TrackListIterator::TrackListIterator ( TrackList val)
explicit

Definition at line 393 of file Track.cpp.

394  : l{ val }
395  , cur{}
396 {
397  if (l)
398  cur = l->getBegin();
399 }
TrackNodePointer cur
Definition: Track.h:442
TrackNodePointer getBegin() const
Definition: Track.h:767
TrackList * l
Definition: Track.h:441
TrackListIterator::TrackListIterator ( TrackList val,
TrackNodePointer  p 
)
explicit

Definition at line 387 of file Track.cpp.

388  : l{ val }
389  , cur{ p }
390 {
391 }
TrackNodePointer cur
Definition: Track.h:442
TrackList * l
Definition: Track.h:441
TrackListIterator::TrackListIterator ( const TrackListIterator )
default
virtual TrackListIterator::~TrackListIterator ( )
inlinevirtual

Definition at line 413 of file Track.h.

413 {}

Member Function Documentation

Track * TrackListIterator::First ( TrackList val = nullptr)
virtual

Reimplemented in TrackListCondIterator.

Definition at line 418 of file Track.cpp.

References cur, TrackList::getBegin(), TrackList::isNull(), and l.

Referenced by SetLabelCommand::Apply(), SelectTracksCommand::Apply(), SelectionState::ChangeSelectionOnShiftClick(), ControlToolBar::ChooseExistingRecordingTracks(), AudacityProject::Clear(), LabelDefaultClickHandle::Click(), LabelTextHandle::Click(), AudacityProject::CountSelectedTracks(), AudacityProject::CountSelectedWaveTracks(), TimeShiftHandle::CreateListOfCapturedClips(), AudacityProject::DoAddLabel(), AudacityProject::DoEffect(), ControlToolBar::DoRecord(), AudacityProject::DoSave(), AudacityProject::DoZoomFitV(), TrackArtist::DrawTracks(), AudacityProject::EditByLabel(), AudacityProject::EditClipboardByLabel(), AudacityProject::EnqueueODTasks(), TrackPanel::EnsureVisible(), ExportMultiple::ExportMultipleByTrack(), LabelDialog::FindAllLabels(), DirManager::FindOrphanBlockFiles(), TrackListCondIterator::First(), GetAllSeqBlocks(), TrackPanel::GetFirstSelectedTrack(), AudacityProject::GetFirstVisible(), AudacityProject::GetRegionsByLabel(), AudacityProject::GetUpdateFlags(), AudacityProject::HandleAlign(), AudacityProject::HandleMixAndRender(), AudacityProject::HandlePasteNothingSelected(), AudacityProject::HandleTrackMute(), AudacityProject::HandleTrackSolo(), MixerBoard::HasSolo(), EffectAutoDuck::Init(), EffectEqualization::Init(), MacroCommands::IsMono(), ODTask::IsTaskAssociatedWithProject(), MixAndRender(), AudacityProject::NearestZeroCrossing(), AudacityProject::OnCollapseAllTracks(), AudacityProject::OnCopy(), AudacityProject::OnCursorTrackEnd(), AudacityProject::OnCursorTrackStart(), AudacityProject::OnCut(), AudacityProject::OnDisjoin(), AudacityProject::OnDuplicate(), AudacityProject::OnExpandAllTracks(), AudacityProject::OnExportLabels(), AudacityProject::OnFirstTrack(), AudacityProject::OnJoin(), LabelTrack::OnKeyDown(), AudacityProject::OnMuteAllTracks(), AudacityProject::OnNextTrack(), AudacityProject::OnPanTracks(), AudacityProject::OnPaste(), AudacityProject::OnPasteNewLabel(), AudacityProject::OnPrevTrack(), AudacityPrintout::OnPrintPage(), ControlToolBar::OnRecord(), AudacityProject::OnRemoveTracks(), AudacityProject::OnResample(), LabelDialog::OnSelectCell(), AudacityProject::OnSelectCursorEnd(), AudacityProject::OnSelectStartCursor(), AudacityProject::OnSelectSyncLockSel(), AudacityProject::OnSelectTimeAndTracks(), AudacityProject::OnSelectTrackStartToEnd(), AudacityProject::OnSilence(), AudacityProject::OnSplit(), AudacityProject::OnSplitCut(), AudacityProject::OnSplitDelete(), AudacityProject::OnSplitNew(), AudacityProject::OnTrim(), AudacityProject::OnUnmuteAllTracks(), AudacityProject::OpenFile(), ControlToolBar::PlayPlayRegion(), AudacityProject::PopState(), AudacityProject::ProjectHasTracks(), AudacityProject::RedrawProject(), AudacityProject::SaveCopyWaveTracks(), LabelDefaultClickHandle::SaveState(), SelectionState::SelectNone(), AudacityProject::SelectNone(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendTracks(), StartWith(), LabelDialog::TransferDataFromWindow(), MixerBoard::UpdateTrackClusters(), TrackPanel::UpdateVRulerSize(), TrackPanel::VerticalScroll(), and SelectionStateChanger::~SelectionStateChanger().

419 {
420  if (val != NULL) {
421  l = val;
422  }
423 
424  if (l == NULL) {
425  return NULL;
426  }
427 
428  cur = l->getBegin();
429 
430  if (!l->isNull(cur)) {
431  return cur.first->get();
432  }
433 
434  return nullptr;
435 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer cur
Definition: Track.h:442
TrackNodePointer getBegin() const
Definition: Track.h:767
TrackList * l
Definition: Track.h:441
Track * TrackListIterator::Last ( bool  skiplinked = false)
virtual

Reimplemented in SyncLockedTracksIterator, and TrackListCondIterator.

Definition at line 437 of file Track.cpp.

References cur, TrackList::getEnd(), TrackList::getPrev(), TrackList::isNull(), and l.

Referenced by TrackListCondIterator::Last(), AudacityProject::OnDuplicate(), AudacityProject::OnLastTrack(), AudacityProject::OnPrevTrack(), and AudacityProject::OnSplitNew().

438 {
439  if (l == NULL) {
440  return NULL;
441  }
442 
443  cur = l->getPrev( l->getEnd() );
444  if ( l->isNull( cur ) )
445  return nullptr;
446 
447  // With skiplinked set, we won't return the second channel of a linked pair
448  if (skiplinked) {
449  auto prev = l->getPrev( cur );
450  if ( !l->isNull( prev ) &&
451  !(*cur.first)->GetLinked() &&
452  (*cur.first)->GetLink()
453  )
454  cur = prev;
455  }
456 
457  return cur.first->get();
458 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
TrackNodePointer getEnd() const
Definition: Track.h:764
TrackNodePointer cur
Definition: Track.h:442
TrackList * l
Definition: Track.h:441
Track * TrackListIterator::Next ( bool  skiplinked = false)
virtual

Reimplemented in SyncLockedTracksIterator, and TrackListCondIterator.

Definition at line 460 of file Track.cpp.

References cur, TrackList::getNext(), TrackList::isNull(), and l.

Referenced by SetLabelCommand::Apply(), SelectTracksCommand::Apply(), SelectionState::ChangeSelectionOnShiftClick(), ControlToolBar::ChooseExistingRecordingTracks(), AudacityProject::Clear(), LabelDefaultClickHandle::Click(), LabelTextHandle::Click(), AudacityProject::CountSelectedTracks(), AudacityProject::CountSelectedWaveTracks(), TimeShiftHandle::CreateListOfCapturedClips(), AudacityProject::DoAddLabel(), AudacityProject::DoEffect(), ControlToolBar::DoRecord(), AudacityProject::DoSave(), AudacityProject::DoZoomFitV(), TrackArtist::DrawTracks(), AudacityProject::EditByLabel(), AudacityProject::EditClipboardByLabel(), AudacityProject::EnqueueODTasks(), TrackPanel::EnsureVisible(), ExportMultiple::ExportMultipleByTrack(), LabelDialog::FindAllLabels(), TrackListCondIterator::First(), GetAllSeqBlocks(), TrackPanel::GetFirstSelectedTrack(), AudacityProject::GetFirstVisible(), AudacityProject::GetRegionsByLabel(), AudacityProject::GetUpdateFlags(), AudacityProject::HandleAlign(), AudacityProject::HandleMixAndRender(), AudacityProject::HandlePasteNothingSelected(), AudacityProject::HandleTrackMute(), AudacityProject::HandleTrackSolo(), MixerBoard::HasSolo(), EffectAutoDuck::Init(), EffectEqualization::Init(), MacroCommands::IsMono(), ODTask::IsTaskAssociatedWithProject(), MixAndRender(), AudacityProject::NearestZeroCrossing(), TrackListCondIterator::Next(), SyncLockedTracksIterator::Next(), AudacityProject::OnCollapseAllTracks(), AudacityProject::OnCopy(), AudacityProject::OnCursorTrackEnd(), AudacityProject::OnCursorTrackStart(), AudacityProject::OnCut(), AudacityProject::OnDisjoin(), AudacityProject::OnDuplicate(), AudacityProject::OnExpandAllTracks(), AudacityProject::OnExportLabels(), AudacityProject::OnJoin(), LabelTrack::OnKeyDown(), AudacityProject::OnMuteAllTracks(), AudacityProject::OnPanTracks(), AudacityProject::OnPaste(), AudacityProject::OnPasteNewLabel(), AudacityProject::OnPrevTrack(), AudacityPrintout::OnPrintPage(), ControlToolBar::OnRecord(), AudacityProject::OnRemoveTracks(), AudacityProject::OnResample(), LabelDialog::OnSelectCell(), AudacityProject::OnSelectCursorEnd(), AudacityProject::OnSelectStartCursor(), AudacityProject::OnSelectSyncLockSel(), AudacityProject::OnSelectTimeAndTracks(), AudacityProject::OnSelectTrackStartToEnd(), AudacityProject::OnSilence(), AudacityProject::OnSplit(), AudacityProject::OnSplitCut(), AudacityProject::OnSplitDelete(), AudacityProject::OnSplitNew(), AudacityProject::OnTrim(), AudacityProject::OnUnmuteAllTracks(), AudacityProject::OpenFile(), ControlToolBar::PlayPlayRegion(), AudacityProject::PopState(), AudacityProject::RedrawProject(), AudacityProject::SaveCopyWaveTracks(), LabelDefaultClickHandle::SaveState(), SelectionState::SelectNone(), AudacityProject::SelectNone(), SelectionState::SelectRangeOfTracks(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendTracks(), LabelDialog::TransferDataFromWindow(), MixerBoard::UpdateTrackClusters(), TrackPanel::UpdateVRulerSize(), TrackPanel::VerticalScroll(), and SelectionStateChanger::~SelectionStateChanger().

461 {
462 #ifdef DEBUG_TLI // if we are debugging this bit
463  wxASSERT_MSG((!cur || (*l).Contains((*cur).t)), wxT("cur invalid at start of Next(). List changed since iterator created?")); // check that cur is in the list
464 #endif
465 
466  if (!l || l->isNull(cur))
467  return nullptr;
468 
469  if (skipLinked &&
470  (*cur.first)->GetLinked())
471  cur = l->getNext( cur );
472 
473  #ifdef DEBUG_TLI // if we are debugging this bit
474  wxASSERT_MSG((!cur || (*l).Contains((*cur).t)), wxT("cur invalid after skipping linked tracks.")); // check that cur is in the list
475  #endif
476 
477  if (!l->isNull(cur))
478  cur = l->getNext( cur );
479 
480  #ifdef DEBUG_TLI // if we are debugging this bit
481  wxASSERT_MSG((!cur || (*l).Contains((*cur).t)), wxT("cur invalid after moving to next track.")); // check that cur is in the list if it is not null
482  #endif
483 
484  if (!l->isNull(cur))
485  return cur.first->get();
486 
487  return nullptr;
488 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer cur
Definition: Track.h:442
TrackList * l
Definition: Track.h:441
TrackNodePointer getNext(TrackNodePointer p) const
Definition: Track.h:772
bool TrackListIterator::operator!= ( const TrackListIterator other) const
inline

Definition at line 435 of file Track.h.

436  { return !(*this == other); }
Track * TrackListIterator::operator* ( ) const

Definition at line 508 of file Track.cpp.

References cur, TrackList::isNull(), and l.

509 {
510  if ( !l || l->isNull( cur ) )
511  return nullptr;
512  else
513  return cur.first->get();
514 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer cur
Definition: Track.h:442
TrackList * l
Definition: Track.h:441
TrackListIterator& TrackListIterator::operator++ ( )
inline

Definition at line 430 of file Track.h.

430 { (void) Next(); return *this; }
virtual Track * Next(bool skiplinked=false)
Definition: Track.cpp:460
TrackListIterator TrackListIterator::operator++ ( int  )
inline

Definition at line 431 of file Track.h.

References operator++().

432  { auto copy = *this; operator++(); return copy; }
TrackListIterator & operator++()
Definition: Track.h:430
TrackListIterator& TrackListIterator::operator= ( const TrackListIterator )
default
bool TrackListIterator::operator== ( const TrackListIterator other) const

Definition at line 533 of file Track.cpp.

References cur, TrackList::isNull(), and l.

534 {
535  // Order these steps so as not to use operator == on default-constructed
536  // std::list::iterator -- that crashes in the MSVC 2013 standard library
537  bool isEnd = !l || l->isNull( cur );
538  bool otherIsEnd = !other.l || other.l->isNull( other.cur );
539 
540  return (isEnd == otherIsEnd && (isEnd || cur == other.cur));
541 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer cur
Definition: Track.h:442
TrackList * l
Definition: Track.h:441
Track * TrackListIterator::Prev ( bool  skiplinked = false)
virtual

Reimplemented in SyncLockedTracksIterator, and TrackListCondIterator.

Definition at line 490 of file Track.cpp.

References cur, TrackList::getPrev(), TrackList::isNull(), and l.

Referenced by TrackListCondIterator::Last(), TrackListCondIterator::Prev(), and SyncLockedTracksIterator::Prev().

491 {
492  if (!l || l->isNull(cur))
493  return nullptr;
494 
495  cur = l->getPrev( cur );
496  if ( l->isNull( cur ) )
497  return nullptr;
498 
499  if ( skiplinked ) {
500  auto prev = l->getPrev( cur );
501  if( !l->isNull( prev ) && (*prev.first)->GetLinked() )
502  cur = prev;
503  }
504 
505  return cur.first->get();
506 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer getPrev(TrackNodePointer p) const
Definition: Track.h:782
TrackNodePointer cur
Definition: Track.h:442
TrackList * l
Definition: Track.h:441
Track * TrackListIterator::RemoveCurrent ( )

Definition at line 516 of file Track.cpp.

References cur, TrackList::isNull(), l, and TrackList::Remove().

Referenced by AudacityProject::HandleMixAndRender(), and AudacityProject::OnRemoveTracks().

517 {
518  if ( !l || l->isNull( cur ) )
519  return nullptr;
520 
521  cur = l->Remove( cur.first->get() );
522 
523  #ifdef DEBUG_TLI // if we are debugging this bit
524  wxASSERT_MSG((!cur || (*l).Contains((*cur).t)), wxT("cur invalid after deletion of track.")); // check that cur is in the list
525  #endif
526 
527  if ( !l->isNull( cur ) )
528  return cur.first->get();
529 
530  return nullptr;
531 }
bool isNull(TrackNodePointer p) const
Definition: Track.h:761
TrackNodePointer cur
Definition: Track.h:442
TrackNodePointer Remove(Track *t)
Definition: Track.cpp:985
TrackList * l
Definition: Track.h:441
Track * TrackListIterator::StartWith ( Track val)
virtual

Reimplemented in SyncLockedTracksIterator, and TrackListCondIterator.

Definition at line 401 of file Track.cpp.

References cur, First(), Track::GetNode(), l, and Track::mList.

Referenced by AudacityProject::DoAddLabel(), TrackArtist::DrawTracks(), SelectionState::SelectRangeOfTracks(), and TrackListCondIterator::StartWith().

402 {
403  if (val == NULL) {
404  return First();
405  }
406 
407  if (l == NULL) {
408  return NULL;
409  }
410 
411  if (val->mList.lock() == NULL)
412  return nullptr;
413 
414  cur = val->GetNode();
415  return cur.first->get();
416 }
TrackNodePointer GetNode() const
Definition: Track.cpp:114
std::weak_ptr< TrackList > mList
Definition: Track.h:114
virtual Track * First(TrackList *val=nullptr)
Definition: Track.cpp:418
TrackNodePointer cur
Definition: Track.h:442
TrackList * l
Definition: Track.h:441

Member Data Documentation

TrackNodePointer TrackListIterator::cur {}
protected
TrackList* TrackListIterator::l {}
protected
friend TrackListIterator::TrackList
protected

Definition at line 439 of file Track.h.


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