15#ifndef __AUDACITY_CHANNEL__
16#define __AUDACITY_CHANNEL__
36 virtual double Start()
const = 0;
38 virtual double End()
const = 0;
73 template<
typename IntervalType = ChannelInterval>
77 std::dynamic_pointer_cast<IntervalType>(DoGetChannel(
iChannel));
83 template<
typename IntervalType = const ChannelInterval>
85 -> std::enable_if_t<std::is_const_v<IntervalType>,
86 std::shared_ptr<IntervalType>>
88 return std::dynamic_pointer_cast<IntervalType>(
94 template<
typename IntervalType>
97 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
100 using GroupType = std::conditional_t<std::is_const_v<IntervalType>,
105 : mpGroup{ pGroup }, mIndex{ index }
110 if (!mpGroup || mIndex >= mpGroup->NChannels())
112 return mpGroup->template GetChannel<IntervalType>(mIndex);
117 {
auto copy{ *
this }; operator ++();
return copy; }
121 {
auto copy{ *
this }; operator --();
return copy; }
126 {
return !(a == b); }
134 template<
typename IntervalType = ChannelInterval>
137 return { {
this, 0 }, {
this, NChannels() } };
141 template<
typename IntervalType = const ChannelInterval>
143 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
147 return { {
this, 0 }, {
this, NChannels() } };
173 size_t GetChannelIndex()
const;
183 size_t NIntervals()
const;
190 template<
typename IntervalType = Interval>
191 std::shared_ptr<IntervalType> GetInterval(
size_t iInterval);
196 template<
typename IntervalType = const Interval>
197 auto GetInterval(
size_t iInterval)
const
198 -> std::enable_if_t<std::is_const_v<IntervalType>,
199 std::shared_ptr<IntervalType>>;
207 template<
typename IntervalType>
210 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
213 using ChannelType = std::conditional_t<std::is_const_v<IntervalType>,
218 : mpChannel{ pChannel }, mIndex{ index }
223 if (!mpChannel || mIndex >= mpChannel->NIntervals())
225 return mpChannel->template GetInterval<IntervalType>(mIndex);
230 {
auto copy{ *
this }; operator ++();
return copy; }
234 {
auto copy{ *
this }; operator --();
return copy; }
239 {
return !(a == b); }
247 template<
typename IntervalType = Interval>
250 return { {
this, 0 }, {
this, NIntervals() } };
254 template<
typename IntervalType = const Interval>
256 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
260 return { {
this, 0 }, {
this, NIntervals() } };
291 double GetStartTime()
const;
293 double GetEndTime()
const;
296 void ShiftBy(
double t) { MoveTo(GetStartTime() + t); }
299 virtual void ShiftBy(
double t0,
double delta) = 0;
322 template<
typename ChannelType = Channel>
326 std::dynamic_pointer_cast<ChannelType>(DoGetChannel(
iChannel));
332 template<
typename ChannelType = const Channel>
334 -> std::enable_if_t<std::is_const_v<ChannelType>,
335 std::shared_ptr<ChannelType>>
337 return std::dynamic_pointer_cast<ChannelType>(
343 template<
typename ChannelType>
346 std::shared_ptr<ChannelType>, std::bidirectional_iterator_tag
349 using GroupType = std::conditional_t<std::is_const_v<ChannelType>,
354 : mpGroup{ pGroup }, mIndex{ index }
359 if (!mpGroup || mIndex >= mpGroup->NChannels())
361 return mpGroup->template GetChannel<ChannelType>(mIndex);
366 {
auto copy{ *
this }; operator ++();
return copy; }
370 {
auto copy{ *
this }; operator --();
return copy; }
375 {
return !(a == b); }
383 template<
typename ChannelType = Channel>
386 return { {
this, 0 }, {
this, NChannels() } };
390 template<
typename ChannelType = const Channel>
396 return { {
this, 0 }, {
this, NChannels() } };
401 auto iter = Channels().begin();
402 std::advance(iter, nChannel);
406 std::shared_ptr<const Channel>
NthChannel(
size_t nChannel)
const
408 auto iter = Channels().begin();
409 std::advance(iter, nChannel);
429 template<
typename IntervalType = Interval>
433 std::dynamic_pointer_cast<IntervalType>(DoGetInterval(iInterval));
439 template<
typename IntervalType = const Interval>
441 -> std::enable_if_t<std::is_const_v<IntervalType>,
442 std::shared_ptr<IntervalType>>
444 return std::dynamic_pointer_cast<IntervalType>(
445 const_cast<ChannelGroup*
>(
this)->DoGetInterval(iInterval));
454 template<
typename IntervalType>
457 std::shared_ptr<IntervalType>, std::bidirectional_iterator_tag
460 using GroupType = std::conditional_t<std::is_const_v<IntervalType>,
465 : mpGroup{ pGroup }, mIndex{ index }
470 if (!mpGroup || mIndex >= mpGroup->NIntervals())
472 return mpGroup->template GetInterval<IntervalType>(mIndex);
477 {
auto copy{ *
this }; operator ++();
return copy; }
481 {
auto copy{ *
this }; operator --();
return copy; }
486 {
return !(a == b); }
494 template<
typename IntervalType = Interval>
497 return { {
this, 0 }, {
this, NIntervals() } };
501 template<
typename IntervalType = const Interval>
503 ->
std::enable_if_t<
std::is_const_v<IntervalType>,
507 return { {
this, 0 }, {
this, NIntervals() } };
545template<
typename IntervalType>
552template<
typename IntervalType>
554 -> std::enable_if_t<std::is_const_v<IntervalType>,
555 std::shared_ptr<IntervalType>>
557 return DoGetChannelGroup().GetInterval(iInterval)
558 ->template GetChannel<IntervalType>(GetChannelIndex());
ClientData::Site< ChannelGroup, ClientData::Cloneable<>, ClientData::DeepCopying > ChannelGroupAttachments
Hosting of objects attached by higher level code.
Utility ClientData::Site to register hooks into a host class that attach client data.
auto operator*(PffftAlignedCount x, Integral y) -> std::enable_if_t< std::is_unsigned_v< Integral > &&sizeof(Integral)<=sizeof(size_t), PffftAlignedCount >
bool operator==(const WaveTrackLocation &a, const WaveTrackLocation &b)
bool operator!=(const WaveTrackLocation &a, const WaveTrackLocation &b)
IntervalIterator(ChannelType *pChannel, size_t index)
IntervalIterator()=default
std::conditional_t< std::is_const_v< IntervalType >, const Channel, Channel > ChannelType
std::conditional_t< std::is_const_v< ChannelType >, const ChannelGroup, ChannelGroup > GroupType
ChannelIterator(GroupType *pGroup, size_t index)
ChannelIterator()=default
std::conditional_t< std::is_const_v< IntervalType >, const ChannelGroup, ChannelGroup > GroupType
IntervalIterator(GroupType *pGroup, size_t index)
IntervalIterator()=default
auto Channels() const -> std::enable_if_t< std::is_const_v< ChannelType >, IteratorRange< ChannelIterator< ChannelType > > >
Get range of channels with read-only access.
auto Intervals() const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
Get range of intervals with read-only access.
virtual void MoveTo(double o)=0
Change start time to given time point.
LinkType
For two tracks describes the type of the linkage.
virtual size_t NIntervals() const =0
Report the number of intervals.
IteratorRange< ChannelIterator< ChannelType > > Channels()
Get range of channels with mutative access.
auto GetChannel(size_t iChannel) const -> std::enable_if_t< std::is_const_v< ChannelType >, std::shared_ptr< ChannelType > >
void ShiftBy(double t)
Change start time by given duration.
virtual std::shared_ptr< Interval > DoGetInterval(size_t iInterval)=0
Retrieve an interval.
auto GetInterval(size_t iInterval) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
std::shared_ptr< const Channel > NthChannel(size_t nChannel) const
virtual void ShiftBy(double t0, double delta)=0
Shift all intervals that starts after t0 by delta seconds.
virtual size_t NChannels() const =0
Report the number of channels.
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
virtual std::shared_ptr< Channel > DoGetChannel(size_t iChannel)=0
std::shared_ptr< Channel > NthChannel(size_t nChannel)
A start and an end time, and whatever else subclasses associate with them.
virtual ~ChannelGroupInterval()
virtual double Start() const =0
ChannelGroupInterval()=default
virtual double End() const =0
auto Intervals() const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< IntervalIterator< IntervalType > > >
Get range of intervals with read-only access.
size_t NIntervals() const
Report the number of intervals.
std::shared_ptr< IntervalType > GetInterval(size_t iInterval)
Retrieve an interval, cast to the given type.
IteratorRange< IntervalIterator< IntervalType > > Intervals()
Get range of intervals with mutative access.
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
virtual ChannelGroup & DoGetChannelGroup() const =0
Subclass must override.
size_t GetChannelIndex() const
The intersection of a Channel and a WideChannelGroupInterval.
virtual ~ChannelInterval()
Utility to register hooks into a host class that attach client data.
ChannelIterator()=default
std::conditional_t< std::is_const_v< IntervalType >, const WideChannelGroupInterval, WideChannelGroupInterval > GroupType
ChannelIterator(GroupType *pGroup, size_t index)
IteratorRange< ChannelIterator< IntervalType > > Channels()
Get range of ChannelInterval objects with mutative access.
virtual size_t NChannels() const =0
Report the number of channels.
auto GetChannel(size_t iChannel) const -> std::enable_if_t< std::is_const_v< IntervalType >, std::shared_ptr< IntervalType > >
~WideChannelGroupInterval() override
auto Channels() const -> std::enable_if_t< std::is_const_v< IntervalType >, IteratorRange< ChannelIterator< IntervalType > > >
Get range of channels with read-only access.
std::shared_ptr< IntervalType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
virtual std::shared_ptr< ChannelInterval > DoGetChannel(size_t iChannel)=0
Retrieve a channel.
ChannelType
Mutually exclusive channel classifications.
@ DeepCopying
point to new sub-objects; these must define a Clone() member; won't compile for std::weak_ptr
void copy(const T *src, T *dst, int32_t n)
A convenient base class defining abstract virtual Clone() for a given kind of pointer.
A convenience for use with range-for.
A convenience for defining iterators that return rvalue types, so that they cooperate correctly with ...