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

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

#include <algorithm>
#include <atomic>
#include <utility>
#include <list>
#include <optional>
#include <functional>
#include <wx/longlong.h>
#include "Channel.h"
#include "Observer.h"
#include "TrackAttachment.h"
#include "TypeEnumerator.h"
#include "TypeSwitch.h"
#include "XMLTagHandler.h"
Include dependency graph for Track.h:

Go to the source code of this file.

Classes

class  TrackId
 An in-session identifier of track objects across undo states. It does not persist between sessions. 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::TypeNames
 Names of a track type for various purposes. More...
 
struct  Track::TypeInfo
 
struct  Track::DuplicateOptions
 Choices when duplicating a track. More...
 
class  UniqueChannelTrack< Base >
 Generates overrides of channel-related functions. More...
 
class  ChannelAttachmentsBase
 Holds multiple objects as a single attachment to Track. More...
 
class  ChannelAttachments< Attachment >
 Holds multiple objects of the parameter type as a single attachment to Track. 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...
 

Macros

#define ENUMERATE_TRACK_TYPE(T)   ENUMERATE_TYPE(TrackTypeTag, T)
 Empty class which will have subclasses. More...
 

Typedefs

using TrackArray = std::vector< Track * >
 
using TrackListHolder = std::shared_ptr< TrackList >
 
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...
 
using ProgressReporter = std::function< void(double)>
 
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)
 
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)
 

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)    ENUMERATE_TYPE(TrackTypeTag, T)

Empty class which will have subclasses.

This macro should be called immediately after the definition of each Track subclass

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

Definition at line 67 of file Track.h.

Typedef Documentation

◆ AttachedTrackObjects

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

Definition at line 112 of file Track.h.

◆ ListOfTracks

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

Definition at line 45 of file Track.h.

◆ ProgressReporter

using ProgressReporter = std::function<void(double)>

Definition at line 53 of file Track.h.

◆ TrackArray

using TrackArray = std::vector< Track* >

Definition at line 39 of file Track.h.

◆ TrackListHolder

using TrackListHolder = std::shared_ptr<TrackList>

Definition at line 42 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 50 of file Track.h.

Function Documentation

◆ ENUMERATE_TRACK_TYPE()

ENUMERATE_TRACK_TYPE ( Track  )

◆ operator!=()

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

Definition at line 58 of file Track.h.

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

◆ operator==()

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

Definition at line 55 of file Track.h.

56{ 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 640 of file Track.h.

641{
642 using BareType = std::remove_pointer_t< T >;
643 if (track &&
644 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
645 return reinterpret_cast<T>(track);
646 else
647 return nullptr;
648}
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 623 of file Track.h.

624{
625 using BareType = std::remove_pointer_t< T >;
626 if (track &&
627 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
628 return reinterpret_cast<T>(track);
629 else
630 return nullptr;
631}