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

#include <Channel.h>

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

Classes

class  ChannelIterator
 

Public Member Functions

 WideChannelGroupInterval (const ChannelGroup &group, double start, double end)
 
 ~WideChannelGroupInterval () override
 
size_t NChannels () const
 Report the number of channels. More...
 
template<typename IntervalType = ChannelInterval>
std::shared_ptr< IntervalType > GetChannel (size_t iChannel)
 Retrieve a channel, cast to the given type. More...
 
template<typename IntervalType = const ChannelInterval>
auto GetChannel (size_t iChannel) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
 
template<typename IntervalType = ChannelInterval>
IteratorRange< ChannelIterator< IntervalType > > Channels ()
 Get range of ChannelInterval objects with mutative access. More...
 
template<typename IntervalType = const ChannelInterval>
auto Channels () const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< ChannelIterator< IntervalType > > >
 Get range of channels with read-only access. More...
 
- Public Member Functions inherited from ChannelGroupInterval
 ChannelGroupInterval (double start, double end)
 
virtual ~ChannelGroupInterval ()
 
double Start () const
 
double End () const
 

Protected Member Functions

virtual std::shared_ptr< ChannelIntervalDoGetChannel (size_t iChannel)=0
 Retrieve a channel. More...
 

Private Attributes

const size_t mNChannels
 

Detailed Description

Start and end time, and channel width, and whatever else subclasses associate with them

Start and end and number of channels are immutable, but subclasses may add other mutable data

Invariant
Start() <= End()

Definition at line 63 of file Channel.h.

Constructor & Destructor Documentation

◆ WideChannelGroupInterval()

WideChannelGroupInterval::WideChannelGroupInterval ( const ChannelGroup group,
double  start,
double  end 
)

Initialize immutable properties, constraining number of channels to equal that of the containing group

Precondition
group.IsLeader()
start <= end
Postcondition
NChannels() == group.NChannels()

Definition at line 21 of file Channel.cpp.

23 : ChannelGroupInterval{ start, end }
24 , mNChannels{ group.NChannels() }
25{
26 assert(group.IsLeader());
27 assert(mNChannels >= 1); // Post of ChannelGroup::NChannels
28}
virtual bool IsLeader() const =0
virtual size_t NChannels() const =0
Report the number of channels.
A start and an end time, and whatever else subclasses associate with them.
Definition: Channel.h:30
const size_t mNChannels
Definition: Channel.h:174
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References ChannelGroup::IsLeader(), and mNChannels.

Here is the call graph for this function:

◆ ~WideChannelGroupInterval()

WideChannelGroupInterval::~WideChannelGroupInterval ( )
overridedefault

Member Function Documentation

◆ Channels() [1/2]

template<typename IntervalType = ChannelInterval>
IteratorRange< ChannelIterator< IntervalType > > WideChannelGroupInterval::Channels ( )
inline

Get range of ChannelInterval objects with mutative access.

Definition at line 151 of file Channel.h.

152 {
153 return { { this, 0 }, { this, NChannels() } };
154 }
size_t NChannels() const
Report the number of channels.
Definition: Channel.h:80

◆ Channels() [2/2]

template<typename IntervalType = const ChannelInterval>
auto WideChannelGroupInterval::Channels ( ) const -> std::enable_if_t<std::is_const_v<IntervalType>, IteratorRange<ChannelIterator<IntervalType>> >
inline

Get range of channels with read-only access.

Definition at line 158 of file Channel.h.

162 {
163 return { { this, 0 }, { this, NChannels() } };
164 }

◆ DoGetChannel()

virtual std::shared_ptr< ChannelInterval > WideChannelGroupInterval::DoGetChannel ( size_t  iChannel)
protectedpure virtual

Retrieve a channel.

Postcondition
result: !(iChannel < NChannels()) || result

Implemented in NoteTrack::Interval, WaveTrack::Interval, and LabelTrack::Interval.

◆ GetChannel() [1/2]

template<typename IntervalType = ChannelInterval>
std::shared_ptr< IntervalType > WideChannelGroupInterval::GetChannel ( size_t  iChannel)
inline

Retrieve a channel, cast to the given type.

Postconditions imply that GetChannel(0) is always non-null

Postcondition
if IntervalType is default, then: result: !(iChannel < NChannels()) || result

Definition at line 90 of file Channel.h.

91 {
92 return
93 std::dynamic_pointer_cast<IntervalType>(DoGetChannel(iChannel));
94 }
virtual std::shared_ptr< ChannelInterval > DoGetChannel(size_t iChannel)=0
Retrieve a channel.

References anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel.

◆ GetChannel() [2/2]

template<typename IntervalType = const ChannelInterval>
auto WideChannelGroupInterval::GetChannel ( size_t  iChannel) const -> std::enable_if_t<std::is_const_v<IntervalType>, std::shared_ptr<IntervalType>>
inline

Postconditions imply that GetChannel(0) is always non-null

Postcondition
if IntervalType is default, then: result: !(iChannel < NChannels()) || result

Definition at line 100 of file Channel.h.

103 {
104 return std::dynamic_pointer_cast<IntervalType>(
105 const_cast<WideChannelGroupInterval*>(this)->DoGetChannel(iChannel));
106 }

References anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel.

◆ NChannels()

size_t WideChannelGroupInterval::NChannels ( ) const
inline

Report the number of channels.

Postcondition
result: result >= 1

Definition at line 80 of file Channel.h.

80{ return mNChannels; }

Member Data Documentation

◆ mNChannels

const size_t WideChannelGroupInterval::mNChannels
private

Definition at line 174 of file Channel.h.

Referenced by WideChannelGroupInterval().


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