Audacity 3.2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
WaveTrackUtilities::AllClipsIterator Class Reference

#include <WaveTrackUtilities.h>

Inheritance diagram for WaveTrackUtilities::AllClipsIterator:
[legend]
Collaboration diagram for WaveTrackUtilities::AllClipsIterator:
[legend]

Public Member Functions

 AllClipsIterator ()
 
 AllClipsIterator (WaveTrack &track)
 
value_type operator* () const
 
AllClipsIteratoroperator++ ()
 

Private Types

using Stack = std::vector< std::pair< IntervalHolders, size_t > >
 

Private Member Functions

void Push (IntervalHolders clips)
 

Private Attributes

WaveTrackmpTrack {}
 
Stack mStack
 

Friends

bool operator== (const AllClipsIterator &a, const AllClipsIterator &b)
 Define == well enough to serve for loop termination test. More...
 
bool operator!= (const AllClipsIterator &a, const AllClipsIterator &b)
 

Additional Inherited Members

- Public Types inherited from ValueIterator< IntervalHolder >
using iterator_category = std::forward_iterator_tag
 
using value_type = IntervalHolder
 
using difference_type = ptrdiff_t
 
using pointer = void
 
using reference = const IntervalHolder
 

Detailed Description

Get mutative access to all clips (in some unspecified sequence), including those hidden in cutlines.

If clips are added to the track during the visit, not all may be visited. If a clip is removed from the track during the visit, there will not be dangling pointers, but a clip not in the track may be visited.

Definition at line 51 of file WaveTrackUtilities.h.

Member Typedef Documentation

◆ Stack

using WaveTrackUtilities::AllClipsIterator::Stack = std::vector<std::pair<IntervalHolders, size_t> >
private

Definition at line 74 of file WaveTrackUtilities.h.

Constructor & Destructor Documentation

◆ AllClipsIterator() [1/2]

WaveTrackUtilities::AllClipsIterator::AllClipsIterator ( )
inline

Definition at line 55 of file WaveTrackUtilities.h.

55{}

◆ AllClipsIterator() [2/2]

WaveTrackUtilities::AllClipsIterator::AllClipsIterator ( WaveTrack track)
explicit

Audacity: A Digital Audio Editor

WaveTrackUtilities.cpp

Paul Licameli

Definition at line 17 of file WaveTrackUtilities.cpp.

18 : mpTrack(&track)
19{
20 if (mpTrack) {
21 auto &&clips = mpTrack->Intervals();
22 Push({ clips.begin(), clips.end() });
23 }
24}
auto Intervals()
Definition: WaveTrack.h:671

References WaveTrack::Intervals(), mpTrack, and Push().

Here is the call graph for this function:

Member Function Documentation

◆ operator*()

auto WaveTrackUtilities::AllClipsIterator::operator* ( ) const

Definition at line 27 of file WaveTrackUtilities.cpp.

28{
29 if (mStack.empty())
30 return nullptr;
31 else {
32 auto &[intervals, ii] = mStack.back();
33 return intervals[ii];
34 }
35}

◆ operator++()

auto WaveTrackUtilities::AllClipsIterator::operator++ ( )

Definition at line 37 of file WaveTrackUtilities.cpp.

38{
39 // The unspecified sequence is a post-order, but there is no
40 // promise whether sister nodes are ordered in time.
41 if (mpTrack && !mStack.empty()) {
42 auto &[intervals, ii] = mStack.back();
43 if (++ii == intervals.size())
44 mStack.pop_back();
45 else
46 Push(intervals[ii]->GetCutLines());
47 }
48
49 return *this;
50}

◆ Push()

void WaveTrackUtilities::AllClipsIterator::Push ( IntervalHolders  clips)
private

Definition at line 52 of file WaveTrackUtilities.cpp.

53{
54 if (!mpTrack)
55 return;
56
57 // Go depth first while there are cutlines
58 while (!clips.empty()) {
59 auto nextClips = clips[0]->GetCutLines();
60 mStack.push_back({ move(clips), 0 });
61 clips = move(nextClips);
62 }
63}

Referenced by AllClipsIterator().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const AllClipsIterator a,
const AllClipsIterator b 
)
friend

Definition at line 69 of file WaveTrackUtilities.h.

71 { return !(a == b); }

◆ operator==

bool operator== ( const AllClipsIterator a,
const AllClipsIterator b 
)
friend

Define == well enough to serve for loop termination test.

Definition at line 65 of file WaveTrackUtilities.h.

67 { return a.mStack.empty() == b.mStack.empty(); }

Member Data Documentation

◆ mpTrack

WaveTrack* WaveTrackUtilities::AllClipsIterator::mpTrack {}
private

Definition at line 77 of file WaveTrackUtilities.h.

Referenced by AllClipsIterator().

◆ mStack

Stack WaveTrackUtilities::AllClipsIterator::mStack
private

Definition at line 78 of file WaveTrackUtilities.h.


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