Audacity 3.2.0
Classes | Namespaces | Macros | Typedefs | Functions
Track.h File Reference

declares abstract base class Track, TrackList, and iterators over TrackList More...

#include <atomic>
#include <utility>
#include <vector>
#include <list>
#include <functional>
#include <wx/longlong.h>
#include "ClientData.h"
#include "Observer.h"
#include "TrackAttachment.h"
#include "XMLTagHandler.h"
Include dependency graph for Track.h:

Go to the source code of this file.

Classes

struct  anonymous_namespace{Track.h}::TrackTypeCountTag
 Empty class which will have subclasses. More...
 
class  anonymous_namespace{Track.h}::CountTrackTypes< Tag >
 Embedded value member counts track types so far declared in the compilation unit. More...
 
struct  anonymous_namespace{Track.h}::CountTrackTypes< Tag >::Stop< U >
 
struct  anonymous_namespace{Track.h}::CountTrackTypes< Tag >::Count< U >
 
class  anonymous_namespace{Track.h}::CollectTrackTypes< Tag >
 Embedded type member is the tuple of track types so far declared in the compilation unit. More...
 
struct  anonymous_namespace{Track.h}::CollectTrackTypes< Tag >::Stop< Types >
 
struct  anonymous_namespace{Track.h}::CollectTrackTypes< Tag >::AccumulateType< U, Type, Types >
 
struct  anonymous_namespace{Track.h}::CollectTrackTypes< Tag >::Accumulate< U, Types >
 
struct  anonymous_namespace{Track.h}::TrackTypeCounter< T >
 Implements the ENUMERATE_TRACK_TYPE macro. More...
 
struct  anonymous_namespace{Track.h}::TrackTypeCounter< T >::Tag
 
class  TrackId
 An in-session identifier of track objects across undo states. It does not persist between sessions. More...
 
struct  TrackIntervalData
 Optional extra information about an interval, appropriate to a subtype of Track. More...
 
class  ConstTrackInterval
 A start and an end time, and non-mutative access to optional extra information. More...
 
class  TrackInterval
 A start and an end time, and mutative access to optional extra information. More...
 
class  Track
 Abstract base class for an object holding data associated with points on a time axis. More...
 
struct  Track::ProtectedCreationArg
 Empty argument passed to some public constructors. More...
 
struct  Track::ChannelGroupData
 
struct  Track::TypeNames
 Names of a track type for various purposes. More...
 
struct  Track::TypeInfo
 
struct  Track::Executor< Params >
 Variadic template implements metafunction with specializations, to dispatch Track::TypeSwitch. More...
 
struct  Track::Dispatcher
 Helper for recursive case of metafunction implementing Track::TypeSwitch. More...
 
struct  Track::Dispatcher::inapplicable< Tag, R, ArgumentType, Function, Functions >
 First, recursive case of metafunction, defers generation of operator () More...
 
struct  Track::Dispatcher::applicable1< R, BaseClass, ArgumentType, Function >
 Second, nonrecursive case of metafunction, generates operator () that calls function without fallthrough. More...
 
struct  Track::Dispatcher::applicable2< Tag, R, BaseClass, ArgumentType, Function, Functions >
 Third, recursive case of metafunction, generates operator () that calls function with fallthrough. More...
 
struct  Track::Dispatcher::Switch<... >
 Variadic template implements metafunction with specializations, to choose among implementations of operator () More...
 
struct  Track::Dispatcher::Switch< Tag, R, ArgumentType, std::tuple<> >
 Base case, no more base classes of ArgumentType. More...
 
struct  Track::Dispatcher::Switch< Tag, R, ArgumentType, std::tuple< BaseClass, BaseClasses... > >
 Recursive case, tries to match function with one base class of ArgumentType. More...
 
struct  Track::Executor< Tag, R, ArgumentType >
 Base case of metafunction implementing Track::TypeSwitch. More...
 
struct  Track::Executor< Tag, R, ArgumentType, Function, Functions... >
 Implements Track::TypeSwitch, its operator() invokes the first function that can accept ArgumentType*. More...
 
class  AudioTrack
 Track subclass holding data representing sound (as notes, or samples, or ...) More...
 
class  PlayableTrack
 AudioTrack subclass that can also be audibly replayed by the program. More...
 
class  TrackIter< TrackType >
 Iterator over only members of a TrackList of the specified subtype, optionally filtered by a predicate; past-end value dereferenceable, to nullptr. More...
 
struct  TrackIterRange< TrackType >
 Range between two TrackIters, usable in range-for statements, and with Visit member functions. More...
 
struct  TrackListEvent
 Notification of changes in individual tracks of TrackList, or of TrackList's composition. More...
 
class  TrackList
 A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list of tracks, event notifications. More...
 

Namespaces

namespace  anonymous_namespace{Track.h}
 

Macros

#define ENUMERATE_TRACK_TYPE(T)
 This macro should be called immediately after each definition of a track subtype. More...
 

Typedefs

using TrackArray = std::vector< Track * >
 
using ListOfTracks = std::list< std::shared_ptr< Track > >
 
using TrackNodePointer = std::pair< ListOfTracks::iterator, ListOfTracks * >
 Pairs a std::list iterator and a pointer to a list, for comparison purposes. More...
 
template<unsigned U, typename Tag >
using anonymous_namespace{Track.h}::EnumeratedTrackType = std::remove_reference_t< decltype(enumerateTrackTypes(Tag{}, std::integral_constant< unsigned, U >{})) >
 What type is associated with U (at the point of instantiation for Tag)? More...
 
using AttachedTrackObjects = ClientData::Site< Track, TrackAttachment, ClientData::ShallowCopying, std::shared_ptr >
 Template generated base class for Track lets it host opaque UI related objects. More...
 

Functions

bool operator== (const TrackNodePointer &a, const TrackNodePointer &b)
 
bool operator!= (const TrackNodePointer &a, const TrackNodePointer &b)
 
auto anonymous_namespace{Track.h}::enumerateTrackTypes (TrackTypeCountTag,...) -> void
 
template<typename T >
std::enable_if_t< std::is_pointer_v< T >, T > track_cast (Track *track)
 Encapsulate the checked down-casting of track pointers. More...
 
template<typename T >
std::enable_if_t< std::is_pointer_v< T > &&std::is_const_v< std::remove_pointer_t< T > >, T > track_cast (const Track *track)
 Encapsulate the checked down-casting of track pointers. More...
 
 ENUMERATE_TRACK_TYPE (Track)
 
 ENUMERATE_TRACK_TYPE (AudioTrack)
 
 ENUMERATE_TRACK_TYPE (PlayableTrack)
 

Detailed Description

declares abstract base class Track, TrackList, and iterators over TrackList


Audacity: A Digital Audio Editor

Dominic Mazzoni

Definition in file Track.h.

Macro Definition Documentation

◆ ENUMERATE_TRACK_TYPE

#define ENUMERATE_TRACK_TYPE (   T)
Value:
namespace { auto enumerateTrackTypes(\
TrackTypeCountTag, \
std::integral_constant<unsigned, TrackTypeCounter<T>::value>) -> T&; }
auto enumerateTrackTypes(TrackTypeCountTag,...) -> void

This macro should be called immediately after each definition of a track subtype.

It must occur at file scope, not within any other namespace

Definition at line 126 of file Track.h.

Typedef Documentation

◆ AttachedTrackObjects

Template generated base class for Track lets it host opaque UI related objects.

Definition at line 217 of file Track.h.

◆ ListOfTracks

using ListOfTracks = std::list< std::shared_ptr< Track > >

Definition at line 43 of file Track.h.

◆ TrackArray

using TrackArray = std::vector< Track* >

Definition at line 38 of file Track.h.

◆ TrackNodePointer

using TrackNodePointer = std::pair< ListOfTracks::iterator, ListOfTracks* >

Pairs a std::list iterator and a pointer to a list, for comparison purposes.

Compare owning lists first, and only if same, then the iterators; else MSVC debug runtime complains.

Definition at line 48 of file Track.h.

Function Documentation

◆ ENUMERATE_TRACK_TYPE() [1/3]

ENUMERATE_TRACK_TYPE ( AudioTrack  )

◆ ENUMERATE_TRACK_TYPE() [2/3]

ENUMERATE_TRACK_TYPE ( PlayableTrack  )

◆ ENUMERATE_TRACK_TYPE() [3/3]

ENUMERATE_TRACK_TYPE ( Track  )

◆ operator!=()

bool operator!= ( const TrackNodePointer a,
const TrackNodePointer b 
)
inline

Definition at line 54 of file Track.h.

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

◆ operator==()

bool operator== ( const TrackNodePointer a,
const TrackNodePointer b 
)
inline

Definition at line 51 of file Track.h.

52{ return a.second == b.second && a.first == b.first; }

◆ track_cast() [1/2]

template<typename T >
std::enable_if_t< std::is_pointer_v< T > &&std::is_const_v< std::remove_pointer_t< T > >, T > track_cast ( const Track track)
inline

Encapsulate the checked down-casting of track pointers.

Eliminates possibility of error – and not quietly casting away const

Typical usage:

if (auto wt = track_cast<const WaveTrack*>(track)) { ... }

This overload for const pointers can cast only to other const pointer types.

Definition at line 983 of file Track.h.

984{
985 using BareType = std::remove_pointer_t< T >;
986 if (track &&
987 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
988 return reinterpret_cast<T>(track);
989 else
990 return nullptr;
991}
virtual const TypeInfo & GetTypeInfo() const =0

◆ track_cast() [2/2]

template<typename T >
std::enable_if_t< std::is_pointer_v< T >, T > track_cast ( Track track)
inline

Encapsulate the checked down-casting of track pointers.

Eliminates possibility of error – and not quietly casting away const

Typical usage:

if (auto wt = track_cast<const WaveTrack*>(track)) { ... }

Definition at line 966 of file Track.h.

967{
968 using BareType = std::remove_pointer_t< T >;
969 if (track &&
970 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
971 return reinterpret_cast<T>(track);
972 else
973 return nullptr;
974}