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  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 = ListOfTracks::iterator
 
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

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

Typedef Documentation

◆ AttachedTrackObjects

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

Definition at line 100 of file Track.h.

◆ ListOfTracks

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

Definition at line 44 of file Track.h.

◆ ProgressReporter

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

Definition at line 48 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 = ListOfTracks::iterator

Definition at line 46 of file Track.h.

Function Documentation

◆ ENUMERATE_TRACK_TYPE()

ENUMERATE_TRACK_TYPE ( Track  )

◆ 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 497 of file Track.h.

498{
499 using BareType = std::remove_pointer_t< T >;
500 if (track &&
501 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
502 return reinterpret_cast<T>(track);
503 else
504 return nullptr;
505}
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 480 of file Track.h.

481{
482 using BareType = std::remove_pointer_t< T >;
483 if (track &&
484 BareType::ClassTypeInfo().IsBaseOf(track->GetTypeInfo() ))
485 return reinterpret_cast<T>(track);
486 else
487 return nullptr;
488}