Audacity 3.2.0
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Channel Class Referenceabstract

#include <Channel.h>

Inheritance diagram for Channel:
[legend]

Classes

class  IntervalIterator
 

Public Member Functions

virtual ~Channel ()
 
ChannelGroupGetChannelGroup ()
 Channel object's lifetime is assumed to be nested in its Track's. More...
 
const ChannelGroupGetChannelGroup () const
 Channel object's lifetime is assumed to be nested in its Track's. More...
 
size_t GetChannelIndex () const
 
size_t ReallyGetChannelIndex () const
 

Protected Member Functions

virtual ChannelGroupDoGetChannelGroup () const =0
 Subclass must override. More...
 
virtual ChannelGroupReallyDoGetChannelGroup () const
 This is temporary! It defaults to call the above. More...
 

Private Member Functions

int FindChannelIndex () const
 

Acesss to intervals

using Interval = ChannelInterval
 
size_t NIntervals () const
 Report the number of intervals. More...
 
template<typename IntervalType = Interval>
std::shared_ptr< IntervalType > GetInterval (size_t iInterval)
 Retrieve an interval, cast to the given type. More...
 
template<typename IntervalType = const Interval>
auto GetInterval (size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
 
template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > Intervals ()
 Get range of intervals with mutative access. More...
 
template<typename IntervalType = const Interval>
auto Intervals () const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
 Get range of intervals with read-only access. More...
 

Detailed Description

Definition at line 177 of file Channel.h.

Member Typedef Documentation

◆ Interval

Definition at line 201 of file Channel.h.

Constructor & Destructor Documentation

◆ ~Channel()

Channel::~Channel ( )
virtualdefault

Member Function Documentation

◆ DoGetChannelGroup()

virtual ChannelGroup & Channel::DoGetChannelGroup ( ) const
protectedpure virtual

Subclass must override.

Postcondition
result: for some ii less than result.NChannels(), this == result.GetChannel(ii).get()

Implemented in UniqueChannelTrack< Base >, UniqueChannelTrack< NoteTrackBase >, and WaveTrack.

Referenced by FindChannelIndex(), GetChannelGroup(), WaveChannel::GetTrack(), ReallyDoGetChannelGroup(), and NoteTrack::Interval::WideChannelGroupInterval().

Here is the caller graph for this function:

◆ FindChannelIndex()

int Channel::FindChannelIndex ( ) const
private

Definition at line 34 of file Channel.cpp.

35{
36 auto &group = DoGetChannelGroup();
37 int index = -1;
38 for (size_t ii = 0, nn = group.NChannels(); ii < nn; ++ii)
39 if (group.GetChannel(ii).get() == this) {
40 index = ii;
41 break;
42 }
43 // post of DoGetChannelGroup
44 assert(index >= 0);
45
46 // TODO wide wave tracks -- remove this stronger assertion
47 assert(index == 0);
48
49 return index;
50}
virtual ChannelGroup & DoGetChannelGroup() const =0
Subclass must override.

References DoGetChannelGroup().

Referenced by GetChannelGroup(), GetChannelIndex(), and NoteTrack::Interval::WideChannelGroupInterval().

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

◆ GetChannelGroup() [1/2]

ChannelGroup & Channel::GetChannelGroup ( )

Channel object's lifetime is assumed to be nested in its Track's.

Definition at line 71 of file Channel.cpp.

72{
73 assert(FindChannelIndex() >= 0);
74 return DoGetChannelGroup();
75}
int FindChannelIndex() const
Definition: Channel.cpp:34

Referenced by ChannelView::Find(), TrackPanelResizerCell::Get(), ChannelView::Get(), anonymous_namespace{TrackPanel.cpp}::GetTrack(), TrackPanelResizeHandle::GetTrack(), and NIntervals().

Here is the caller graph for this function:

◆ GetChannelGroup() [2/2]

const ChannelGroup & Channel::GetChannelGroup ( ) const

Channel object's lifetime is assumed to be nested in its Track's.

Definition at line 65 of file Channel.cpp.

66{
67 assert(FindChannelIndex() >= 0);
68 return DoGetChannelGroup();
69}

References DoGetChannelGroup(), and FindChannelIndex().

Here is the call graph for this function:

◆ GetChannelIndex()

size_t Channel::GetChannelIndex ( ) const
Returns
ii such that this == GetChannelGroup().GetChannel(ii).get()

Definition at line 77 of file Channel.cpp.

78{
79 return FindChannelIndex();
80}

References FindChannelIndex().

Referenced by ChannelView::Find(), TrackPanelResizerCell::Get(), and ChannelView::Get().

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

◆ GetInterval() [1/2]

template<typename IntervalType >
std::shared_ptr< IntervalType > Channel::GetInterval ( size_t  iInterval)

Retrieve an interval, cast to the given type.

Postcondition
if IntervalType is default, then: result: !(iInterval < NIntervals()) || result

Definition at line 614 of file Channel.h.

615{
616 return ReallyDoGetChannelGroup().GetInterval(iInterval)
617 ->template GetChannel<IntervalType>(ReallyGetChannelIndex());
618}
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
Definition: Channel.h:445
virtual ChannelGroup & ReallyDoGetChannelGroup() const
This is temporary! It defaults to call the above.
Definition: Channel.cpp:82
size_t ReallyGetChannelIndex() const
Definition: Channel.cpp:52

References ChannelGroup::GetInterval(), ReallyDoGetChannelGroup(), and ReallyGetChannelIndex().

Here is the call graph for this function:

◆ GetInterval() [2/2]

template<typename IntervalType >
auto Channel::GetInterval ( size_t  iInterval) const -> std::enable_if_t<std::is_const_v<IntervalType>, std::shared_ptr<IntervalType>>
Postcondition
if IntervalType is default, then: result: !(iInterval < NIntervals()) || result

Definition at line 621 of file Channel.h.

624{
625 return ReallyDoGetChannelGroup().GetInterval(iInterval)
626 ->template GetChannel<IntervalType>(ReallyGetChannelIndex());
627}

◆ Intervals() [1/2]

template<typename IntervalType = Interval>
IteratorRange< IntervalIterator< IntervalType > > Channel::Intervals ( )
inline

Get range of intervals with mutative access.

Definition at line 269 of file Channel.h.

270 {
271 return { { this, 0 }, { this, NIntervals() } };
272 }
size_t NIntervals() const
Report the number of intervals.
Definition: Channel.h:608

Referenced by EffectRepeat::Process().

Here is the caller graph for this function:

◆ Intervals() [2/2]

template<typename IntervalType = const Interval>
auto Channel::Intervals ( ) const -> std::enable_if_t<std::is_const_v<IntervalType>, IteratorRange<IntervalIterator<IntervalType>> >
inline

Get range of intervals with read-only access.

Definition at line 276 of file Channel.h.

280 {
281 return { { this, 0 }, { this, NIntervals() } };
282 }

◆ NIntervals()

size_t Channel::NIntervals ( ) const
inline

Report the number of intervals.

Definition at line 608 of file Channel.h.

609{
610 return GetChannelGroup().NIntervals();
611}
virtual size_t NIntervals() const =0
Report the number of intervals.
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
Definition: Channel.cpp:71

References GetChannelGroup(), and ChannelGroup::NIntervals().

Here is the call graph for this function:

◆ ReallyDoGetChannelGroup()

ChannelGroup & Channel::ReallyDoGetChannelGroup ( ) const
protectedvirtual

This is temporary! It defaults to call the above.

Reimplemented in WaveTrack.

Definition at line 82 of file Channel.cpp.

83{
84 return DoGetChannelGroup();
85}

References DoGetChannelGroup().

Referenced by GetInterval(), and ReallyGetChannelIndex().

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

◆ ReallyGetChannelIndex()

size_t Channel::ReallyGetChannelIndex ( ) const

Definition at line 52 of file Channel.cpp.

53{
54 auto &group = ReallyDoGetChannelGroup();
55 int index = -1;
56 for (size_t ii = 0, nn = group.NChannels(); ii < nn; ++ii)
57 if (group.GetChannel(ii).get() == this) {
58 index = ii;
59 break;
60 }
61 assert(index >= 0);
62 return index;
63}

References ReallyDoGetChannelGroup().

Referenced by GetInterval().

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

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