12#ifndef __AUDACITY_TRACK__
13#define __AUDACITY_TRACK__
20#include <wx/longlong.h>
30#pragma warning(disable:4284)
48std::pair< ListOfTracks::iterator, ListOfTracks* >;
51{
return a.second == b.second && a.first == b.first; }
69 std::integral_constant<unsigned, U>{} ) ) >;
77 template<
unsigned U>
struct Stop{
78 static constexpr unsigned value = U; };
79 template<
unsigned U>
struct Count
81 std::is_void_v<EnumeratedTrackType<U, Tag>>,
102 : std::conditional_t< std::is_void_v<Type>,
104 Accumulate<U + 1, Type, Types...>
125#define ENUMERATE_TRACK_TYPE(T) namespace { auto enumerateTrackTypes(\
127 std::integral_constant<unsigned, TrackTypeCounter<T>::value>) -> T&; }
131 std::enable_if_t< std::is_pointer_v<T>, T >
136 std::is_pointer_v<T> &&
137 std::is_const_v< std::remove_pointer_t< T > >,
183 std::unique_ptr<TrackIntervalData>
pExtra = {} )
200 std::unique_ptr< TrackIntervalData >
pExtra;
224 ,
public std::enable_shared_from_this<Track>
242 struct ChannelGroupData;
296 template<
typename Sub
class = Track>
301 return std::static_pointer_cast<Subclass>( shared_from_this() );
304 template<
typename Sub
class = const Track>
307 std::is_const_v<Subclass>,
std::shared_ptr<Subclass>
312 return std::static_pointer_cast<Subclass>( shared_from_this() );
316 template<
typename Sub
class = Track>
318 {
return pTrack ? pTrack->
SharedPointer<Subclass>() :
nullptr; }
320 template<
typename Sub
class = const Track>
322 {
return pTrack ? pTrack->
SharedPointer<Subclass>() :
nullptr; }
326 std::shared_ptr<Track> SubstitutePendingChangedTrack();
327 std::shared_ptr<const Track> SubstitutePendingChangedTrack()
const;
331 std::shared_ptr<const Track> SubstituteOriginalTrack()
const;
348 bool concrete =
false;
353 for (
auto pInfo = &other;
361 static const TypeInfo &ClassTypeInfo();
363 {
return GetTypeInfo().names; }
366 virtual bool SupportsBasicEditing()
const;
388 int GetIndex()
const;
389 void SetIndex(
int index);
401 virtual bool LinkConsistencyFix(
bool doFix =
true,
bool completeList =
true);
405 {
return const_cast<Track*
>(
this)->LinkConsistencyFix(
false, completeList); }
407 bool HasOwner()
const {
return static_cast<bool>(GetOwner());}
409 std::shared_ptr<TrackList>
GetOwner()
const {
return mList.lock(); }
411 LinkType GetLinkType() const noexcept;
413 bool IsAlignedWithLeader() const;
415 ChannelGroupData &GetGroupData();
416 const ChannelGroupData &GetGroupData() const;
423 void SetLinkType(LinkType linkType,
bool completeList = true);
424 void SetChannel(ChannelType c) noexcept;
427 ChannelGroupData &MakeGroupData();
431 void DoSetLinkType(LinkType linkType,
bool completeList = true);
433 Track* GetLinkedTrack() const;
435 bool HasLinkedTrack() const noexcept;
460 virtual
Holder Duplicate() const;
464 virtual
void Merge(const
Track &orig);
466 wxString GetName()
const {
return mName; }
467 void SetName(
const wxString &n );
471 virtual void SetSelected(
bool s);
482 void Offset(
double t) { SetOffset(GetOffset() + t); }
491 virtual Holder Cut(
double WXUNUSED(t0),
double WXUNUSED(t1)) = 0;
500 (
double WXUNUSED(t0),
double WXUNUSED(t1),
bool forClipboard =
true)
const = 0;
503 virtual void Clear(
double WXUNUSED(t0),
double WXUNUSED(t1)) = 0;
505 virtual void Paste(
double WXUNUSED(t),
const Track * WXUNUSED(src)) = 0;
509 virtual void SyncLockAdjust(
double oldT1,
double newT1);
512 virtual void Silence(
double WXUNUSED(t0),
double WXUNUSED(t1)) = 0;
523 friend std::enable_if_t< std::is_pointer_v<T>, T >
526 friend std::enable_if_t<
527 std::is_pointer_v<T> &&
528 std::is_const_v< std::remove_pointer_t< T > >,
538 template <
typename R =
void >
545 template<
typename ...Params >
552 template<
typename Tag,
typename R,
typename ArgumentType,
553 typename Function,
typename ...Functions >
557 std::conditional_t< std::is_const_v<ArgumentType>,
563 enum :
unsigned { SetUsed = Tail::SetUsed << 1 };
568 const Function &,
const Functions &...functions)
const
569 {
return Tail{}( pTrack, functions... ); }
573 template<
typename R,
typename BaseClass,
typename ArgumentType,
578 std::conditional_t< std::is_const_v<ArgumentType>,
581 std::conditional_t< std::is_const_v<ArgumentType>,
582 const BaseClass, BaseClass >;
585 enum :
unsigned { SetUsed = 1u };
594 template<
typename Tag,
595 typename R,
typename BaseClass,
typename ArgumentType,
596 typename Function,
typename ...Functions >
600 std::conditional_t< std::is_const_v<ArgumentType>,
603 std::conditional_t< std::is_const_v<ArgumentType>,
604 const BaseClass, BaseClass >;
609 enum :
unsigned { SetUsed = (Tail::SetUsed << 1) | 1u };
614 const Functions &...functions)
const
617 return Tail{}( pTrack, functions... );
625 template<
typename ... >
struct Switch {};
629 template<
typename Tag,
typename R,
typename ArgumentType >
633 template<
typename Function,
typename ...Functions >
635 ->
inapplicable< Tag, R, ArgumentType, Function, Functions... >;
640 template<
typename Tag,
typename R,
typename ArgumentType,
641 typename BaseClass,
typename ...BaseClasses >
642 struct Switch< Tag, R, ArgumentType,
std::tuple<BaseClass, BaseClasses...> >
645 std::conditional_t< std::is_const_v<ArgumentType>,
646 const BaseClass, BaseClass >;
650 Switch< Tag, R, ArgumentType, std::tuple<BaseClasses...> >;
655 template<
typename Function,
typename ...Functions >
656 static auto test(
const void * )
657 ->
decltype( Retry::template test< Function, Functions... >() );
663 template<
typename Function,
typename ...Functions >
664 static auto test( std::true_type * )
666 (void) std::declval<Function>()
676 template<
typename Function,
typename ...Functions >
677 static auto test( std::true_type * )
679 (void) std::declval<Function>()
683 Function, Functions... >{}
687 static constexpr bool Compatible =
688 std::is_base_of_v<BaseClass, ArgumentType>;
690 template<
typename Function,
typename ...Functions >
693 test< Function, Functions... >(
694 (std::integral_constant<bool, Compatible>*)
nullptr) );
699 template<
typename Tag,
typename R,
typename ArgumentType >
704 enum :
unsigned { SetUsed = 0 };
706 R operator () (
const void *, ...)
708 if constexpr (std::is_void_v<R>)
717 template<
typename Tag,
typename R,
typename ArgumentType,
718 typename Function,
typename ...Functions >
719 struct Executor< Tag, R, ArgumentType, Function, Functions... >
721 Dispatcher::Switch< Tag, R, ArgumentType,
722 typename CollectTrackTypes<Tag>::type >
723 ::template test<Function, Functions... >())
730 template<
typename TrackType>
734 std::is_same_v<Track, TrackType> ||
735 std::is_same_v<const Track, TrackType>,
"Error" );
737 template<
typename R,
typename TrackType,
typename... Functions>
738 static R
CallExecutor(R*, std::tuple<>*, TrackType&,
const Functions&...)
744 checkTrackType<TrackType>();
745 if constexpr (std::is_void_v<R>)
751 typename R,
typename TrackType,
typename... Functions,
752 typename Executor,
typename... Executors>
754 R*, std::tuple<Executor, Executors...>*, TrackType &track,
755 const Functions &...functions)
757 checkTrackType<TrackType>();
758 const auto &info = Executor::NominalType::ClassTypeInfo();
762 if ( info.IsBaseOf(track.GetTypeInfo()) )
764 return Executor{}(&track, functions...);
767 return CallExecutor( (R*)
nullptr,
768 (std::tuple<Executors...>*)
nullptr, track, functions...);
771 template<
typename ...Executors>
772 static constexpr unsigned UsedCases(std::tuple<Executors...>*)
774 return (Executors::SetUsed | ...);
781 typename ...TrackTypes,
782 typename ...Functions
785 std::conditional_t<IsConst, const Track, Track> &track,
786 std::tuple<TrackTypes...>*,
787 const Functions &...functions )
792 using Executors = std::tuple<
Executor<
794 std::conditional_t<IsConst, const TrackTypes, TrackTypes>,
798 constexpr Executors *executors =
nullptr;
801 enum { All =
sizeof...( functions ) };
802 static_assert( (1u << All) - 1u == UsedCases(executors),
803 "Uncallable case in Track::TypeSwitch");
806 return CallExecutor((R *)
nullptr, executors, track, functions...);
830 typename ...Functions
834 struct Tag : TrackTypeCountTag {};
836 using TrackTypes =
typename CollectTrackTypes<Tag>::type;
837 TrackTypes *
const trackTypes =
nullptr;
839 return DoTypeSwitch<Tag, false, R>(*
this, trackTypes, functions...);
847 typename ...Functions
851 struct Tag : TrackTypeCountTag {};
853 using TrackTypes =
typename CollectTrackTypes<Tag>::type;
854 TrackTypes *
const trackTypes =
nullptr;
856 return DoTypeSwitch<Tag, true, R>(*
this, trackTypes, functions...);
872 void Notify(
int code = -1 );
878 bool IsSelected()
const;
879 bool IsLeader()
const;
880 bool IsSelectedLeader()
const;
883 void AdjustPositions();
886 void WriteCommonXMLAttributes(
887 XMLWriter &xmlFile,
bool includeNameAndSelected =
true)
const;
902 static const TypeInfo &ClassTypeInfo();
921 static const TypeInfo &ClassTypeInfo();
927 void SetMute (
bool m);
928 void SetSolo (
bool s);
931 void Merge(
const Track &init )
override;
934 void WriteXMLAttributes(
XMLWriter &xmlFile)
const;
941 bool DoGetMute()
const;
942 void DoSetMute(
bool value);
943 bool DoGetSolo()
const;
944 void DoSetSolo(
bool value);
947 std::atomic<bool> mMute {
false };
949 std::atomic<bool> mSolo {
false };
964 inline std::enable_if_t< std::is_pointer_v<T>, T >
967 using BareType = std::remove_pointer_t< T >;
969 BareType::ClassTypeInfo().IsBaseOf(track->
GetTypeInfo() ))
970 return reinterpret_cast<T
>(track);
978 inline std::enable_if_t<
979 std::is_pointer_v<T> && std::is_const_v< std::remove_pointer_t< T > >,
984 using BareType = std::remove_pointer_t< T >;
986 BareType::ClassTypeInfo().IsBaseOf(track->
GetTypeInfo() ))
987 return reinterpret_cast<T
>(track);
1005 :
public ValueIterator< TrackType *, std::bidirectional_iterator_tag >
1010 std::add_pointer_t< std::add_const_t< std::remove_pointer_t<TrackType> > >
1021 ,
mPred( std::move(pred) )
1031 template <
typename Predicate2 >
1040 template <
typename TrackType2 >
1042 ->
std::enable_if_t<
1043 std::is_base_of_v< TrackType, TrackType2 > &&
1044 (!
std::is_const_v<TrackType> ||
1045 std::is_const_v<TrackType2>),
1053 {
return this->
mPred; }
1061 ++this->
mIter.first;
1084 --this->
mIter.first;
1107 return static_cast< TrackType *
>( &**this->
mIter.first );
1116 std::advance( copy, amount );
1146 const auto pTrack = track_cast< TrackType * >( &**this->
mIter.first );
1149 return !this->
mPred || this->
mPred( pTrack );
1177 template<
typename Predicate2 >
1180 const auto &pred1 = this->first.GetPredicate();
1182 const auto &newPred = pred1
1183 ? Function{ [=] (
typename Function::argument_type track) {
1184 return pred1(track) && pred2(track);
1186 : Function{ pred2 };
1188 this->first.Filter( newPred ),
1189 this->second.Filter( newPred )
1195 template<
typename R,
typename C >
1198 return this->
operator + ( std::mem_fn( pmf ) );
1203 template<
typename Predicate2 >
1206 using ArgumentType =
1207 typename TrackIterRange::iterator::FunctionType::argument_type;
1208 auto neg = [=] (ArgumentType track) {
return !pred2( track ); };
1214 template<
typename R,
typename C >
1217 return this->
operator + ( std::not1( std::mem_fn( pmf ) ) );
1220 template<
typename TrackType2 >
1224 this-> first.template Filter< TrackType2 >(),
1225 this->second.template Filter< TrackType2 >()
1231 auto newBegin = this->
find( pTrack );
1236 { newBegin.mIter, newBegin.mIter, this->second.mEnd,
1237 this->first.GetPredicate() },
1238 { newBegin.mIter, this->second.mIter, this->second.mEnd,
1239 this->second.GetPredicate() }
1245 const auto newEnd = this->
reversal().find( pTrack ).base();
1250 { this->first.mBegin, this->first.mIter, newEnd.mIter,
1251 this->first.GetPredicate() },
1252 { this->first.mBegin, newEnd.mIter, newEnd.mIter,
1253 this->second.GetPredicate() }
1261 [=](
const Track *pTrack){
return pExcluded == pTrack; } );
1265 template<
typename ...Functions >
1266 void Visit(
const Functions &...functions)
1268 for (
auto track : *
this)
1269 track->TypeSwitch(functions...);
1274 template<
typename Flag,
typename ...Functions >
1277 if (
flag )
for (
auto track : *
this) {
1278 track->TypeSwitch(functions...);
1317 const std::weak_ptr<Track> &pTrack = {},
int extra = -1)
1336 ,
public std::enable_shared_from_this<TrackList>
1340 using ListOfTracks::push_back;
1382 wxString MakeUniqueTrackName(
const wxString& baseTrackName)
const;
1398 template <
typename TrackType = Track >
1402 if (!pTrack || pTrack->GetOwner().get() !=
this)
1403 return EndIterator<TrackType>();
1405 return MakeTrackIterator<TrackType>( pTrack->GetNode() );
1410 template <
typename TrackType = const Track >
1412 -> std::enable_if_t< std::is_const_v<TrackType>,
1416 if (!pTrack || pTrack->GetOwner().get() !=
this)
1417 return EndIterator<TrackType>();
1419 return MakeTrackIterator<TrackType>( pTrack->GetNode() );
1432 FindLeader(
const_cast<Track*
>(pTrack) ).Filter< const Track >();
1436 template <
typename TrackType = Track >
1440 return Tracks< TrackType >();
1443 template <
typename TrackType = const Track >
1445 ->
std::enable_if_t<
std::is_const_v<TrackType>,
1449 return Tracks< TrackType >();
1453 template <
typename TrackType = Track >
1460 template <
typename TrackType = const Track >
1462 ->
std::enable_if_t<
std::is_const_v<TrackType>,
1470 template <
typename TrackType = Track >
1477 template <
typename TrackType = const Track >
1479 ->
std::enable_if_t<
std::is_const_v<TrackType>,
1487 template <
typename TrackType = Track >
1494 template <
typename TrackType = const Track >
1496 ->
std::enable_if_t<
std::is_const_v<TrackType>,
1504 template<
typename TrackType>
1508 return pTrack->GetOwner()->template Any<TrackType>()
1514 Track *DoAddToHead(
const std::shared_ptr<Track> &t);
1515 Track *DoAdd(
const std::shared_ptr<Track> &t);
1517 template<
typename TrackType,
typename InTrackType >
1525 .template Filter<TrackType>(),
1527 .template Filter<TrackType>()
1533 iter1.template Filter<TrackType>(),
1534 iter1.template Filter<TrackType>()
1540 template<
typename TrackType >
1544 return Channels_<TrackType>( pTrack->GetOwner()->FindLeader(pTrack) );
1549 static bool SwapChannels(
Track &track);
1554 void Permute(
const std::vector<TrackNodePointer> &permutation);
1559 template<
typename TrackKind>
1560 TrackKind *
AddToHead(
const std::shared_ptr< TrackKind > &t )
1561 {
return static_cast< TrackKind*
>( DoAddToHead( t ) ); }
1563 template<
typename TrackKind>
1564 TrackKind *
Add(
const std::shared_ptr< TrackKind > &t )
1565 {
return static_cast< TrackKind*
>( DoAdd( t ) ); }
1568 void UnlinkChannels(
Track& track);
1577 bool MakeMultiChannelTrack(
Track& first,
int nChannels,
bool aligned);
1581 ListOfTracks::value_type Replace(
1582 Track * t,
const ListOfTracks::value_type &with);
1588 void Clear(
bool sendEvent =
true);
1590 bool CanMoveUp(
Track * t)
const;
1591 bool CanMoveDown(
Track * t)
const;
1593 bool MoveUp(
Track * t);
1594 bool MoveDown(
Track * t);
1595 bool Move(
Track * t,
bool up) {
return up ? MoveUp(t) : MoveDown(t); }
1598 bool Contains(
const Track * t)
const;
1602 template <
typename Sub
class>
1603 std::shared_ptr<Subclass>
Lock(
const std::weak_ptr<Subclass> &wTrack)
1605 auto pTrack = wTrack.lock();
1607 auto pList = pTrack->mList.lock();
1608 if (pTrack &&
this == pList.get())
1615 size_t size()
const;
1620 double GetMinOffset()
const;
1626 typename TrackType =
Track,
1633 auto b = getBegin(), e = getEnd();
1634 return { { b, b, e, pred }, { b, e, e, pred } };
1639 typename TrackType =
const Track,
1644 -> std::enable_if_t< std::is_const_v<TrackType>,
1648 auto b =
const_cast<TrackList*
>(
this)->getBegin();
1649 auto e =
const_cast<TrackList*
>(
this)->getEnd();
1650 return { { b, b, e, pred }, { b, e, e, pred } };
1653 Track *GetPrev(
Track * t,
bool linked =
false)
const;
1654 Track *GetNext(
Track * t,
bool linked =
false)
const;
1656 template <
typename TrackType >
1660 auto b =
const_cast<TrackList*
>(
this)->getBegin();
1661 auto e =
const_cast<TrackList*
>(
this)->getEnd();
1662 return { b, iter, e };
1665 template <
typename TrackType >
1669 auto e =
const_cast<TrackList*
>(
this)->getEnd();
1677 || (p.second == &mPendingUpdates && p.first == mPendingUpdates.end()); }
1698 if (p == getBegin())
1709 void SelectionEvent(
const std::shared_ptr<Track> &pTrack );
1711 void DataEvent(
const std::shared_ptr<Track> &pTrack,
int code );
1712 void EnsureVisibleEvent(
1713 const std::shared_ptr<Track> &pTrack,
bool modifyState );
1714 void DeletionEvent(std::weak_ptr<Track> node,
bool duringReplace);
1741 std::shared_ptr<Track> RegisterPendingChangedTrack(
1752 void RegisterPendingNewTrack(
const std::shared_ptr<Track> &pTrack );
1756 void UpdatePendingTracks();
1760 void ClearPendingTracks(
ListOfTracks *pAdded =
nullptr );
1766 bool ApplyPendingTracks();
1768 bool HasPendingTracks()
const;
Utility ClientData::Site to register hooks into a host class that attach client data.
std::vector< Track * > TrackArray
ClientData::Site< Track, TrackAttachment, ClientData::ShallowCopying, std::shared_ptr > AttachedTrackObjects
Template generated base class for Track lets it host opaque UI related objects.
#define ENUMERATE_TRACK_TYPE(T)
This macro should be called immediately after each definition of a track subtype.
bool operator==(const TrackNodePointer &a, const TrackNodePointer &b)
bool operator!=(const TrackNodePointer &a, const TrackNodePointer &b)
std::pair< ListOfTracks::iterator, ListOfTracks * > TrackNodePointer
Pairs a std::list iterator and a pointer to a list, for comparison purposes.
std::list< std::shared_ptr< Track > > ListOfTracks
std::enable_if_t< std::is_pointer_v< T >, T > track_cast(Track *track)
Encapsulate the checked down-casting of track pointers.
abstract base class for structures that user interface associates with tracks
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Track subclass holding data representing sound (as notes, or samples, or ...)
bool HandleXMLAttribute(const std::string_view &, const XMLAttributeValueView &)
void WriteXMLAttributes(XMLWriter &WXUNUSED(xmlFile)) const
Utility to register hooks into a host class that attach client data.
A start and an end time, and non-mutative access to optional extra information.
ConstTrackInterval(ConstTrackInterval &&)=default
std::unique_ptr< TrackIntervalData > pExtra
ConstTrackInterval(double start, double end, std::unique_ptr< TrackIntervalData > pExtra={})
const TrackIntervalData * Extra() const
ConstTrackInterval & operator=(ConstTrackInterval &&)=default
An object that sends messages to an open-ended list of subscribed callbacks.
AudioTrack subclass that can also be audibly replayed by the program.
Holds various per-project settings values, and sends events to the project when certain values change...
Abstract base class for an object holding data associated with points on a time axis.
static void checkTrackType()
std::function< R() > Continuation
Type of arguments passed as optional second parameter to TypeSwitch() cases.
virtual void SetPan(float)
virtual void SetOffset(double o)
static R DoTypeSwitch(std::conditional_t< IsConst, const Track, Track > &track, std::tuple< TrackTypes... > *, const Functions &...functions)
bool SameKindAs(const Track &track) const
static R CallExecutor(R *, std::tuple<> *, TrackType &, const Functions &...)
virtual void Paste(double WXUNUSED(t), const Track *WXUNUSED(src))=0
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual Holder PasteInto(AudacityProject &) const =0
Find or create the destination track for a paste, maybe in a different project.
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual const TypeInfo & GetTypeInfo() const =0
virtual double GetStartTime() const =0
virtual Holder Clone() const =0
bool IsSelectedLeader() const
virtual Holder Copy(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
static R CallExecutor(R *, std::tuple< Executor, Executors... > *, TrackType &track, const Functions &...functions)
std::pair< int, int > vrulerSize
std::shared_ptr< TrackList > GetOwner() const
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
static std::shared_ptr< Subclass > SharedPointer(Track *pTrack)
virtual const TypeNames & GetTypeNames() const
auto SharedPointer() const -> std::enable_if_t< std::is_const_v< Subclass >, std::shared_ptr< Subclass > >
std::shared_ptr< Subclass > SharedPointer()
std::shared_ptr< Track > Holder
bool LinkConsistencyCheck(bool completeList)
Do the non-mutating part of consistency fix only and return status.
virtual void SetPanFromChannelType()
virtual void WriteXML(XMLWriter &xmlFile) const =0
R TypeSwitch(const Functions &...functions) const
Use this function rather than testing track type explicitly and making down-casts.
virtual void Silence(double WXUNUSED(t0), double WXUNUSED(t1))=0
virtual ChannelType GetChannel() const
Continuation<> Fallthrough
Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.
std::weak_ptr< TrackList > mList
virtual double GetOffset() const =0
virtual double GetEndTime() const =0
std::vector< Interval > Intervals
virtual void InsertSilence(double WXUNUSED(t), double WXUNUSED(len))=0
static constexpr unsigned UsedCases(std::tuple< Executors... > *)
LinkType
For two tracks describes the type of the linkage.
virtual bool GetErrorOpening()
int mIndex
0-based position of this track in its TrackList
static std::shared_ptr< Subclass > SharedPointer(const Track *pTrack)
std::unique_ptr< ChannelGroupData > mpGroupData
std::vector< ConstInterval > ConstIntervals
TrackId mId
Identifies the track only in-session, not persistently.
An in-session identifier of track objects across undo states. It does not persist between sessions.
bool operator!=(const TrackId &other) const
bool operator<(const TrackId &other) const
bool operator==(const TrackId &other) const
A start and an end time, and mutative access to optional extra information.
TrackIntervalData * Extra() const
TrackInterval(TrackInterval &&)=default
TrackInterval & operator=(TrackInterval &&)=default
Iterator over only members of a TrackList of the specified subtype, optionally filtered by a predicat...
const FunctionType & GetPredicate() const
TrackNodePointer mIter
Current position.
TrackType * operator*() const
Safe to call even when at the end.
TrackIter & operator--()
Safe to call even when at the beginning.
friend bool operator!=(TrackIter a, TrackIter b)
Compares only current positions, assuming same beginnings and ends.
auto Filter() const -> std::enable_if_t< std::is_base_of_v< TrackType, TrackType2 > &&(!std::is_const_v< TrackType >||std::is_const_v< TrackType2 >), TrackIter< TrackType2 > >
Return an iterator for a subclass of TrackType (and not removing const) with same predicate.
TrackNodePointer mBegin
Allows end of reverse iteration to be detected without comparison to other TrackIter.
friend bool operator==(TrackIter a, TrackIter b)
Compares only current positions, assuming same beginnings and ends.
TrackIter Filter(const Predicate2 &pred2) const
Return an iterator that replaces the predicate.
TrackIter & operator++()
Safe to call even when at the end.
std::function< bool(std::add_pointer_t< std::add_const_t< std::remove_pointer_t< TrackType > > >) > FunctionType
Type of predicate taking pointer to const TrackType.
TrackIter advance(long amount) const
This might be called operator + , but it's not constant-time as with a random access iterator.
FunctionType mPred
Optional filter
TrackIter(TrackNodePointer begin, TrackNodePointer iter, TrackNodePointer end, FunctionType pred={})
Constructor, usually not called directly except by methods of TrackList.
bool valid() const
Test satisfaction of the invariant, while initializing, incrementing, or decrementing.
TrackNodePointer mEnd
Allows end of iteration to be detected without comparison to other TrackIter.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
static auto SingletonRange(TrackType *pTrack) -> TrackIterRange< TrackType >
auto Selected() const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
bool Move(Track *t, bool up)
const_iterator begin() const
auto Find(const Track *pTrack) const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIter< TrackType > >
Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.
auto SelectedLeaders() -> TrackIterRange< TrackType >
std::vector< Updater > mUpdaters
This is in correspondence with mPendingUpdates.
TrackNodePointer getBegin() const
auto Tracks(const Pred &pred={}) const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
TrackIter< const Track > FindLeader(const Track *pTrack) const
auto Leaders() -> TrackIterRange< TrackType >
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
auto Tracks(const Pred &pred={}) -> TrackIterRange< TrackType >
bool isNull(TrackNodePointer p) const
TrackNodePointer getNext(TrackNodePointer p) const
Move an iterator to the next node, if any; else stay at end.
auto Find(Track *pTrack) -> TrackIter< TrackType >
Turn a pointer into a TrackIter (constant time); get end iterator if this does not own the track.
auto Any() -> TrackIterRange< TrackType >
TrackNodePointer getEnd() const
std::function< void(Track &dest, const Track &src) > Updater
TrackIter< TrackType > EndIterator() const
auto Any() const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
auto Leaders() const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
static TrackIterRange< TrackType > Channels_(TrackIter< InTrackType > iter1)
const AudacityProject * GetOwner() const
const_iterator cend() const
auto Selected() -> TrackIterRange< TrackType >
const_iterator cbegin() const
AudacityProject * GetOwner()
TrackIter< TrackType > MakeTrackIterator(TrackNodePointer iter) const
TrackList(const TrackList &that)=delete
TrackList(TrackList &&that)=delete
TrackNodePointer getPrev(TrackNodePointer p) const
Move an iterator to the previous node, if any; else wrap to end.
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
ListOfTracks mPendingUpdates
Shadow tracks holding append-recording in progress; need to put them into a list so that GetLink() wo...
TrackKind * AddToHead(const std::shared_ptr< TrackKind > &t)
Add a Track, giving it a fresh id.
const_iterator end() const
auto SelectedLeaders() const -> std::enable_if_t< std::is_const_v< TrackType >, TrackIterRange< TrackType > >
Holds a msgid for the translation catalog; may also bind format arguments.
A view into an attribute value. The class does not take the ownership of the data.
This class is an interface which should be implemented by classes which wish to be able to load and s...
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Embedded type member is the tuple of track types so far declared in the compilation unit.
typename Accumulate< 0 >::type type
Embedded value member counts track types so far declared in the compilation unit.
void Remove(const FilePath &path)
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
@ ShallowCopying
copy pointers only; won't compile for std::unique_ptr
@ DeepCopying
point to new sub-objects; these must define a Clone() member; won't compile for std::weak_ptr
std::vector< Type > Types
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
void Notify(AudacityProject &project, ProjectSettings::EventCode code, long previousValue)
auto enumerateTrackTypes(TrackTypeCountTag,...) -> void
std::remove_reference_t< decltype(enumerateTrackTypes(Tag{}, std::integral_constant< unsigned, U >{})) > EnumeratedTrackType
What type is associated with U (at the point of instantiation for Tag)?
A convenient default parameter for class template Site.
A convenient base class defining abstract virtual Clone() for a given kind of pointer.
A convenience for use with range-for.
iterator find(const T &t) const
IteratorRange< reverse_iterator > reversal() const
TrackIter< TrackType > end() const
TrackIter< TrackType > begin() const
static auto test() -> inapplicable< Tag, R, ArgumentType, Function, Functions... >
No BaseClass of ArgumentType is acceptable to Function.
std::conditional_t< std::is_const_v< ArgumentType >, const BaseClass, BaseClass > QualifiedBaseClass
static auto test(const void *) -> decltype(Retry::template test< Function, Functions... >())
Catch-all overload of undefined function used in decltype only.
static auto test(std::true_type *) -> decltype((void) std::declval< Function >()((QualifiedBaseClass *) nullptr), applicable1< R, BaseClass, ArgumentType, Function >{})
overload when upcast of ArgumentType* works, with sfinae'd return type
static auto test() -> decltype(test< Function, Functions... >((std::integral_constant< bool, Compatible > *) nullptr))
undefined function used in decltype only to compute a type, using other overloads
static auto test(std::true_type *) -> decltype((void) std::declval< Function >()((QualifiedBaseClass *) nullptr, std::declval< Continuation< R > >()), applicable2< Tag, R, BaseClass, ArgumentType, Function, Functions... >{})
overload when upcast of ArgumentType* works, with sfinae'd return type
Variadic template implements metafunction with specializations, to choose among implementations of op...
Second, nonrecursive case of metafunction, generates operator () that calls function without fallthro...
std::conditional_t< std::is_const_v< ArgumentType >, const BaseClass, BaseClass > QualifiedBaseClass
std::conditional_t< std::is_const_v< ArgumentType >, const Track, Track > QualifiedTrackType
Third, recursive case of metafunction, generates operator () that calls function with fallthrough.
std::conditional_t< std::is_const_v< ArgumentType >, const Track, Track > QualifiedTrackType
std::conditional_t< std::is_const_v< ArgumentType >, const BaseClass, BaseClass > QualifiedBaseClass
First, recursive case of metafunction, defers generation of operator ()
std::conditional_t< std::is_const_v< ArgumentType >, const Track, Track > QualifiedTrackType
Helper for recursive case of metafunction implementing Track::TypeSwitch.
Variadic template implements metafunction with specializations, to dispatch Track::TypeSwitch.
Empty argument passed to some public constructors.
bool IsBaseOf(const TypeInfo &other) const
const TypeInfo * pBaseInfo
Names of a track type for various purposes.
wxString info
short, like "wave", in macro output, not internationalized
TranslatableString name
long, like "Wave Track"
wxString property
short, like "wave", as a Lisp symbol property, not internationalized
Optional extra information about an interval, appropriate to a subtype of Track.
virtual ~TrackIntervalData()
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
TrackIterRange EndingAfter(const Track *pTrack) const
void VisitWhile(Flag &flag, const Functions &...functions)
See Track::TypeSwitch.
TrackIterRange operator+(const Predicate2 &pred2) const
TrackIterRange(const TrackIter< TrackType > &begin, const TrackIter< TrackType > &end)
void Visit(const Functions &...functions)
See Track::TypeSwitch.
TrackIterRange< TrackType2 > Filter() const
TrackIterRange Excluding(const TrackType *pExcluded) const
TrackIterRange operator-(const Predicate2 &pred2) const
TrackIterRange StartingWith(const Track *pTrack) const
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
TrackListEvent(const TrackListEvent &)=default
const std::weak_ptr< Track > mpTrack
@ RESIZING
Posted when some track changed its height.
@ SELECTION_CHANGE
Posted when the set of selected tracks changes.
@ DELETION
Posted when a track has been deleted from a tracklist. Also posted when one track replaces another.
@ ADDITION
Posted when a track has been added to a tracklist. Also posted when one track replaces another.
@ PERMUTED
Posted when tracks are reordered but otherwise unchanged.
@ TRACK_REQUEST_VISIBLE
Posted when a track needs to be scrolled into view.
@ TRACK_DATA_CHANGE
Posted when certain fields of a track change.
TrackListEvent(Type type, const std::weak_ptr< Track > &pTrack={}, int extra=-1)
A convenience for defining iterators that return rvalue types, so that they cooperate correctly with ...
std::tuple< Types... > type
Empty class which will have subclasses.
Implements the ENUMERATE_TRACK_TYPE macro.