Audacity  3.0.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Track Class Referenceabstract

Abstract base class for an object holding data associated with points on a time axis. More...

#include <Track.h>

Inheritance diagram for Track:
[legend]
Collaboration diagram for Track:
[legend]

Classes

struct  Dispatcher
 Helper for recursive case of metafunction implementing Track::TypeSwitch. More...
 
struct  Executor
 Variadic template implements metafunction with specializations, to dispatch Track::TypeSwitch. More...
 
struct  Executor< R, ConcreteType >
 Base case of metafunction implementing Track::TypeSwitch generates operator () with nonvoid return. More...
 
struct  Executor< R, ConcreteType, Function, Functions... >
 Implements Track::TypeSwitch, its operator() invokes the first function that can accept ConcreteType*. More...
 
struct  Executor< R, const ConcreteType, Function, Functions... >
 Implements const overload of Track::TypeSwitch, its operator() invokes the first function that can accept ConcreteType*. More...
 
struct  Executor< void, ConcreteType >
 Base case of metafunction implementing Track::TypeSwitch generates operator () with void return. More...
 

Public Types

using AttachedObjects = ::AttachedTrackObjects
 Alias for my base type. More...
 
using ChannelType = XMLValueChecker::ChannelType
 
using IntervalData = TrackIntervalData
 
using Interval = TrackInterval
 
using Intervals = std::vector< Interval >
 
using ConstInterval = ConstTrackInterval
 
using ConstIntervals = std::vector< ConstInterval >
 
using Holder = std::shared_ptr< Track >
 
template<typename R = void>
using Continuation = std::function< R() >
 Type of arguments passed as optional second parameter to TypeSwitch() cases. More...
 
using Fallthrough = Continuation<>
 Type of arguments passed as optional second parameter to TypeSwitch<void>() cases. More...
 
- Public Types inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
using DataType = ClientData
 
using DataPointer = Pointer< ClientData >
 
using DataFactory = std::function< DataPointer(Host &) >
 Type of function from which RegisteredFactory is constructed; it builds attachments. More...
 

Public Member Functions

TrackId GetId () const
 
template<typename Subclass = Track>
std::shared_ptr< Subclass > SharedPointer ()
 
template<typename Subclass = const Track>
auto SharedPointer () const -> typename std::enable_if< std::is_const< Subclass >::value, std::shared_ptr< Subclass > >::type
 
std::shared_ptr< TrackSubstitutePendingChangedTrack ()
 
std::shared_ptr< const TrackSubstitutePendingChangedTrack () const
 
std::shared_ptr< const TrackSubstituteOriginalTrack () const
 
virtual bool SupportsBasicEditing () const
 Whether this track type implements cut-copy-paste; by default, true. More...
 
virtual Holder PasteInto (AudacityProject &) const =0
 Find or create the destination track for a paste, maybe in a different project. More...
 
virtual ConstIntervals GetIntervals () const
 Report times on the track where important intervals begin and end, for UI to snap to. More...
 
virtual Intervals GetIntervals ()
 
const std::shared_ptr< CommonTrackCell > & GetTrackView ()
 
void SetTrackView (const std::shared_ptr< CommonTrackCell > &pView)
 
const std::shared_ptr< CommonTrackCell > & GetTrackControls ()
 
void SetTrackControls (const std::shared_ptr< CommonTrackCell > &pControls)
 
int GetIndex () const
 
void SetIndex (int index)
 
bool LinkConsistencyCheck ()
 
bool HasOwner () const
 
std::shared_ptr< TrackListGetOwner () const
 
 Track ()
 
 Track (const Track &orig)
 
virtual ~ Track ()
 
void Init (const Track &orig)
 
virtual Holder Duplicate () const
 
virtual void Merge (const Track &orig)
 
wxString GetName () const
 
void SetName (const wxString &n)
 
wxString GetDefaultName () const
 
void SetDefaultName (const wxString &n)
 
bool GetSelected () const
 
virtual void SetSelected (bool s)
 
void EnsureVisible (bool modifyState=false)
 
virtual ChannelType GetChannel () const
 
virtual double GetOffset () const =0
 
void Offset (double t)
 
virtual void SetOffset (double o)
 
virtual void SetPan (float)
 
virtual void SetPanFromChannelType ()
 
virtual Holder Cut (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual Holder Copy (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
 
virtual void Clear (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void Paste (double WXUNUSED(t), const Track *WXUNUSED(src))=0
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void InsertSilence (double WXUNUSED(t), double WXUNUSED(len))=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 Use this function rather than testing track type explicitly and making down-casts. More...
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 Use this function rather than testing track type explicitly and making down-casts. More...
 
virtual void WriteXML (XMLWriter &xmlFile) const =0
 
virtual bool GetErrorOpening ()
 
virtual double GetStartTime () const =0
 
virtual double GetEndTime () const =0
 
bool IsSyncLockSelected () const
 
void Notify (int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsSelectedOrSyncLockSelected () const
 
bool IsLeader () const
 
bool IsSelectedLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const wxChar *attr, const wxChar *value)
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual bool HandleXMLTag (const wxChar *tag, const wxChar **attrs)=0
 
virtual void HandleXMLEndTag (const wxChar *WXUNUSED(tag))
 
virtual void HandleXMLContent (const wxString &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const wxChar *tag)=0
 
bool ReadXMLTag (const char *tag, const char **attrs)
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 
- Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
Siteoperator= (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
template<typename Subclass = ClientData>
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = const ClientData>
auto Get (const RegisteredFactory &key) const -> typename std::enable_if< std::is_const< Subclass >::value, Subclass & >::type
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = ClientData>
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename Subclass = const ClientData>
auto Find (const RegisteredFactory &key) const -> typename std::enable_if< std::is_const< Subclass >::value, Subclass * >::type
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename ReplacementPointer >
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 

Static Public Member Functions

template<typename Subclass = Track>
static std::shared_ptr< Subclass > SharedPointer (Track *pTrack)
 
template<typename Subclass = const Track>
static std::shared_ptr< Subclass > SharedPointer (const Track *pTrack)
 
static void FinishCopy (const Track *n, Track *dest)
 
- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t slots ()
 How many static factories have been registered with this specialization of Site. More...
 

Public Attributes

wxSize vrulerSize
 

Static Public Attributes

static const auto LeftChannel = XMLValueChecker::LeftChannel
 
static const auto RightChannel = XMLValueChecker::RightChannel
 
static const auto MonoChannel = XMLValueChecker::MonoChannel
 

Protected Attributes

std::weak_ptr< TrackListmList
 
TrackNodePointer mNode {}
 Holds iterator to self, so that TrackList::Find can be constant-time. More...
 
int mIndex
 0-based position of this track in its TrackList More...
 
wxString mName
 
wxString mDefaultName
 
bool mLinked
 
ChannelType mChannel
 
double mOffset
 
std::shared_ptr< CommonTrackCellmpView
 
std::shared_ptr< CommonTrackCellmpControls
 

Private Member Functions

void SetId (TrackId id)
 
TrackGetLink () const
 
bool GetLinked () const
 
void SetLinked (bool l)
 
void SetChannel (ChannelType c)
 
void DoSetLinked (bool l)
 
TrackNodePointer GetNode () const
 Retrieve mNode with debug checks. More...
 
void SetOwner (const std::weak_ptr< TrackList > &list, TrackNodePointer node)
 Update mNode when Track is added to TrackList, or removed from it. More...
 
virtual Holder Clone () const =0
 
virtual TrackKind GetKind () const
 

Private Attributes

TrackId mId
 Identifies the track only in-session, not persistently. More...
 
bool mSelected
 
friend WaveTrack
 

Friends

class TrackList
 
template<typename T >
std::enable_if< std::is_pointer< T >::value, T >::type track_cast (Track *track)
 Encapsulate the checked down-casting of track pointers. More...
 
template<typename T >
std::enable_if< std::is_pointer< T >::value &&std::is_const< typename std::remove_pointer< T >::type >::value, T >::type track_cast (const Track *track)
 Encapsulate the checked down-casting of track pointers. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 

Detailed Description

Abstract base class for an object holding data associated with points on a time axis.

Fundamental data object of Audacity, displayed in the TrackPanel. Classes derived form it include the WaveTrack, NoteTrack, LabelTrack and TimeTrack.

Definition at line 234 of file Track.h.

Member Typedef Documentation

◆ AttachedObjects

Alias for my base type.

Definition at line 262 of file Track.h.

◆ ChannelType

Definition at line 263 of file Track.h.

◆ ConstInterval

Definition at line 318 of file Track.h.

◆ ConstIntervals

using Track::ConstIntervals = std::vector< ConstInterval >

Definition at line 319 of file Track.h.

◆ Continuation

template<typename R = void>
using Track::Continuation = std::function< R() >

Type of arguments passed as optional second parameter to TypeSwitch() cases.

Definition at line 485 of file Track.h.

◆ Fallthrough

Type of arguments passed as optional second parameter to TypeSwitch<void>() cases.

Definition at line 487 of file Track.h.

◆ Holder

using Track::Holder = std::shared_ptr<Track>

Definition at line 324 of file Track.h.

◆ Interval

Definition at line 316 of file Track.h.

◆ IntervalData

Definition at line 315 of file Track.h.

◆ Intervals

using Track::Intervals = std::vector< Interval >

Definition at line 317 of file Track.h.

Constructor & Destructor Documentation

◆ Track() [1/2]

Track::Track ( )

Definition at line 49 of file Track.cpp.

50 : vrulerSize(36,0)
51 {
52  mSelected = false;
53  mLinked = false;
54 
55  mIndex = 0;
56 
57  mOffset = 0.0;
58 
60 }

References mChannel, mIndex, mLinked, mOffset, MonoChannel, and mSelected.

◆ Track() [2/2]

Track::Track ( const Track orig)

Definition at line 62 of file Track.cpp.

63 : vrulerSize( orig.vrulerSize )
64 {
65  mIndex = 0;
66  Init(orig);
67  mOffset = orig.mOffset;
68 }

References Init(), mIndex, and mOffset.

Here is the call graph for this function:

◆ ~ Track()

virtual Track::~ Track ( )
virtual

Member Function Documentation

◆ AdjustPositions()

void Track::AdjustPositions ( )

Definition at line 1278 of file Track.cpp.

1279 {
1280  auto pList = mList.lock();
1281  if (pList) {
1282  pList->RecalcPositions(mNode);
1283  pList->ResizingEvent(mNode);
1284  }
1285 }

References mList, and mNode.

◆ Any()

bool Track::Any ( ) const

◆ Clear()

virtual void Track::Clear ( double   WXUNUSEDt0,
double   WXUNUSEDt1 
)
pure virtual

Referenced by LabelEditActions::Handler::OnDeleteLabels(), and SyncLockAdjust().

Here is the caller graph for this function:

◆ Clone()

virtual Holder Track::Clone ( ) const
privatepure virtual

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Referenced by Duplicate(), and TrackList::RegisterPendingChangedTrack().

Here is the caller graph for this function:

◆ Copy()

virtual Holder Track::Copy ( double   WXUNUSEDt0,
double   WXUNUSEDt1,
bool  forClipboard = true 
) const
pure virtual

◆ Cut()

virtual Holder Track::Cut ( double   WXUNUSEDt0,
double   WXUNUSEDt1 
)
pure virtual

Referenced by SyncLockAdjust().

Here is the caller graph for this function:

◆ DoSetLinked()

void Track::DoSetLinked ( bool  l)
private

Definition at line 194 of file Track.cpp.

195 {
196  mLinked = l;
197 }

References mLinked.

Referenced by SetLinked().

Here is the caller graph for this function:

◆ Duplicate()

Track::Holder Track::Duplicate ( ) const
virtual

Definition at line 113 of file Track.cpp.

114 {
115  // invoke "virtual constructor" to copy track object proper:
116  auto result = Clone();
117 
118  if (mpView)
119  // Copy view state that might be important to undo/redo
120  mpView->CopyTo( *result );
121 
122  return result;
123 }

References Clone(), and mpView.

Referenced by WaveTrackFactory::DuplicateWaveTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnsureVisible()

void Track::EnsureVisible ( bool  modifyState = false)

Definition at line 101 of file Track.cpp.

102 {
103  auto pList = mList.lock();
104  if (pList)
105  pList->EnsureVisibleEvent( SharedPointer(), modifyState );
106 }

References mList, and SharedPointer().

Referenced by anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), EffectUI::DoEffect(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), anonymous_namespace{NavigationMenus.cpp}::DoPrevTrack(), TrackUtilities::DoRemoveTracks(), TrackPanel::OnMouseEvent(), TrackActions::Handler::OnNewLabelTrack(), TrackActions::Handler::OnNewStereoTrack(), TrackActions::Handler::OnNewTimeTrack(), TrackActions::Handler::OnNewWaveTrack(), LabelEditActions::Handler::OnPasteNewLabel(), EditActions::Handler::OnRedo(), NavigationActions::Handler::OnToggle(), EditActions::Handler::OnUndo(), TrackPanel::ProcessUIHandleResult(), and ProjectWindow::ZoomAfterImport().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FinishCopy()

void Track::FinishCopy ( const Track n,
Track dest 
)
static

Definition at line 376 of file Track.cpp.

378 {
379  if (dest) {
380  dest->SetChannel(n->GetChannel());
381  dest->SetLinked(n->GetLinked());
382  dest->SetName(n->GetName());
383  }
384 }

References GetChannel(), GetLinked(), GetName(), SetChannel(), SetLinked(), and SetName().

Referenced by anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), anonymous_namespace{LabelMenus.cpp}::EditClipboardByLabel(), anonymous_namespace{EditMenus.cpp}::FinishCopy(), and anonymous_namespace{ProjectFileManager.cpp}::ImportProject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChannel()

virtual ChannelType Track::GetChannel ( ) const
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 424 of file Track.h.

424 { return mChannel;}

Referenced by FinishCopy(), LinkConsistencyCheck(), and anonymous_namespace{NoteTrackControls.cpp}::MidiControlsDrawFunction().

Here is the caller graph for this function:

◆ GetDefaultName()

wxString Track::GetDefaultName ( ) const
inline

Definition at line 411 of file Track.h.

411 { return mDefaultName; }

Referenced by TimeTrack::CleanState(), TimeTrack::Init(), WaveTrack::Init(), LabelTrack::LabelTrack(), NoteTrack::NoteTrack(), and WaveTrack::WaveTrack().

Here is the caller graph for this function:

◆ GetEndTime()

virtual double Track::GetEndTime ( ) const
pure virtual

◆ GetErrorOpening()

virtual bool Track::GetErrorOpening ( )
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 782 of file Track.h.

782 { return false; }

◆ GetId()

TrackId Track::GetId ( ) const
inline

Definition at line 269 of file Track.h.

269 { return mId; }

Referenced by TrackList::HasPendingTracks(), TrackPanelAx::IsFocused(), SetLinked(), SubstituteOriginalTrack(), and SubstitutePendingChangedTrack().

Here is the caller graph for this function:

◆ GetIndex()

int Track::GetIndex ( ) const

Definition at line 165 of file Track.cpp.

166 {
167  return mIndex;
168 }

References mIndex.

Referenced by SelectionState::ChangeSelectionOnShiftClick(), TrackList::RecalcPositions(), and SelectionState::SelectRangeOfTracks().

Here is the caller graph for this function:

◆ GetIntervals() [1/2]

auto Track::GetIntervals ( )
virtual

This overload exposes the extra data of the intervals as non-const This overload exposes the extra data of the intervals as non-const

Reimplemented in WaveTrack, NoteTrack, and LabelTrack.

Definition at line 1237 of file Track.cpp.

1238 {
1239  return {};
1240 }

◆ GetIntervals() [2/2]

auto Track::GetIntervals ( ) const
virtual

Report times on the track where important intervals begin and end, for UI to snap to.

Some intervals may be empty, and no ordering of the intervals is assumed.

Reimplemented in WaveTrack, NoteTrack, and LabelTrack.

Definition at line 1232 of file Track.cpp.

1233 {
1234  return {};
1235 }

Referenced by TrackShifter::InitIntervals().

Here is the caller graph for this function:

◆ GetKind()

virtual TrackKind Track::GetKind ( ) const
inlineprivatevirtual

Reimplemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Definition at line 466 of file Track.h.

466 { return TrackKind::None; }

References None.

Referenced by SameKindAs(), and track_cast().

Here is the caller graph for this function:

◆ GetLink()

Track * Track::GetLink ( ) const
private

Definition at line 199 of file Track.cpp.

200 {
201  auto pList = mList.lock();
202  if (!pList)
203  return nullptr;
204 
205  if (!pList->isNull(mNode)) {
206  if (mLinked) {
207  auto next = pList->getNext( mNode );
208  if ( !pList->isNull( next ) )
209  return next.first->get();
210  }
211 
212  if (mNode.first != mNode.second->begin()) {
213  auto prev = pList->getPrev( mNode );
214  if ( !pList->isNull( prev ) ) {
215  auto track = prev.first->get();
216  if (track && track->GetLinked())
217  return track;
218  }
219  }
220  }
221 
222  return nullptr;
223 }

References mLinked, mList, and mNode.

Referenced by GetInfoCommand::ExploreTrackPanel(), TrackList::GetPrev(), IsLeader(), and LinkConsistencyCheck().

Here is the caller graph for this function:

◆ GetLinked()

bool Track::GetLinked ( ) const
inlineprivate

Definition at line 371 of file Track.h.

371 { return mLinked; }

Referenced by FinishCopy(), TrackList::GetNext(), TrackList::GetPrev(), IsLeader(), and LinkConsistencyCheck().

Here is the caller graph for this function:

◆ GetName()

wxString Track::GetName ( ) const
inline

◆ GetNode()

TrackNodePointer Track::GetNode ( ) const
private

Retrieve mNode with debug checks.

Definition at line 130 of file Track.cpp.

131 {
132  wxASSERT(mList.lock() == NULL || this == mNode.first->get());
133  return mNode;
134 }

References mList, and mNode.

Referenced by TrackList::GetNext(), TrackList::GetPrev(), TrackList::MoveDown(), TrackList::MoveUp(), and TrackList::Remove().

Here is the caller graph for this function:

◆ GetOffset()

virtual double Track::GetOffset ( ) const
pure virtual

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Referenced by anonymous_namespace{TrackMenus.cpp}::DoAlign(), TrackList::GetMinOffset(), SelectActions::Handler::OnCursorTrackStart(), and SelectionState::SelectTrackLength().

Here is the caller graph for this function:

◆ GetOwner()

std::shared_ptr<TrackList> Track::GetOwner ( ) const
inline

Definition at line 367 of file Track.h.

367 { return mList.lock(); }

Referenced by TrackShifter::CommonMayMigrateTo().

Here is the caller graph for this function:

◆ GetSelected()

bool Track::GetSelected ( ) const
inline

◆ GetStartTime()

virtual double Track::GetStartTime ( ) const
pure virtual

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Referenced by anonymous_namespace{TrackMenus.cpp}::DoAlign(), ExportMultipleDialog::ExportMultipleByTrack(), TrackList::GetStartTime(), StretchHandle::GetT0(), SelectActions::Handler::OnSelectStartCursor(), SelectActions::Handler::OnSelectTrackStartToEnd(), and NyquistEffect::ProcessOne().

Here is the caller graph for this function:

◆ GetTrackControls()

const std::shared_ptr< CommonTrackCell > & Track::GetTrackControls ( )

Definition at line 155 of file Track.cpp.

156 {
157  return mpControls;
158 }

References mpControls.

Referenced by CommonTrackControls::TrackControls().

Here is the caller graph for this function:

◆ GetTrackView()

const std::shared_ptr< CommonTrackCell > & Track::GetTrackView ( )

Definition at line 145 of file Track.cpp.

146 {
147  return mpView;
148 }

References mpView.

Referenced by TrackView::Get().

Here is the caller graph for this function:

◆ HandleCommonXMLAttribute()

bool Track::HandleCommonXMLAttribute ( const wxChar *  attr,
const wxChar *  value 
)

Definition at line 1257 of file Track.cpp.

1258 {
1259  long nValue = -1;
1260  wxString strValue( value );
1261  if ( mpView && mpView->HandleXMLAttribute( attr, value ) )
1262  ;
1263  else if ( mpControls && mpControls->HandleXMLAttribute( attr, value ) )
1264  ;
1265  else if (!wxStrcmp(attr, wxT("name")) &&
1266  XMLValueChecker::IsGoodString(strValue)) {
1267  SetName( strValue );
1268  return true;
1269  }
1270  else if (!wxStrcmp(attr, wxT("isSelected")) &&
1271  XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
1272  this->SetSelected(nValue != 0);
1273  return true;
1274  }
1275  return false;
1276 }

References XMLValueChecker::IsGoodInt(), XMLValueChecker::IsGoodString(), mpControls, mpView, SetName(), and SetSelected().

Referenced by LabelTrack::HandleXMLTag(), NoteTrack::HandleXMLTag(), TimeTrack::HandleXMLTag(), and WaveTrack::HandleXMLTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasOwner()

bool Track::HasOwner ( ) const
inline

Definition at line 365 of file Track.h.

365 { return static_cast<bool>(GetOwner());}

References TrackList::GetOwner().

Here is the call graph for this function:

◆ Init()

void Track::Init ( const Track orig)

Definition at line 71 of file Track.cpp.

72 {
73  mId = orig.mId;
74 
76  mName = orig.mName;
77 
78  mSelected = orig.mSelected;
79  mLinked = orig.mLinked;
80  mChannel = orig.mChannel;
81 }

References mChannel, mDefaultName, mId, mLinked, mName, and mSelected.

Referenced by PlayableTrack::Init(), TimeTrack::Init(), and Track().

Here is the caller graph for this function:

◆ InsertSilence()

virtual void Track::InsertSilence ( double   WXUNUSEDt,
double   WXUNUSEDlen 
)
pure virtual

◆ IsLeader()

bool Track::IsLeader ( ) const

Definition at line 370 of file Track.cpp.

371  { return !GetLink() || GetLinked(); }

References GetLink(), and GetLinked().

Referenced by anonymous_namespace{FileMenus.cpp}::DoExport(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{TrackPanel.cpp}::DrawTrackName(), AudioIoCallback::FillOutputBuffers(), TrackList::FindLeader(), IsSelectedLeader(), TrackList::Leaders(), EffectLoudness::Process(), EffectNormalize::Process(), NyquistEffect::Process(), and StereoRequiredFlag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsSelected()

bool Track::IsSelected ( ) const

Definition at line 364 of file Track.cpp.

365  { return GetSelected(); }

References GetSelected().

Referenced by ProjectAudioManager::ChooseExistingRecordingTracks(), ExportPlugin::CreateMixer(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), Exporter::ExamineTracks(), ExportMixerDialog::ExportMixerDialog(), ProjectAudioManager::GetAllPlaybackTracks(), IsSelectedLeader(), IsSyncLockSelected(), ProjectAudioManager::OnRecord(), SelectActions::Handler::OnSelectSyncLockSel(), EffectTruncSilence::ProcessIndependently(), and TrackList::Selected().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsSelectedLeader()

bool Track::IsSelectedLeader ( ) const

Definition at line 373 of file Track.cpp.

374  { return IsSelected() && IsLeader(); }

References IsLeader(), and IsSelected().

Referenced by TrackList::SelectedLeaders().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsSelectedOrSyncLockSelected()

bool Track::IsSelectedOrSyncLockSelected ( ) const

Definition at line 367 of file Track.cpp.

368  { return GetSelected() || IsSyncLockSelected(); }

References GetSelected(), and IsSyncLockSelected().

Referenced by anonymous_namespace{TrackMenus.cpp}::DoAlign(), EffectTruncSilence::DoRemoval(), EditActions::Handler::OnCut(), and EffectReverse::Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsSyncLockSelected()

bool Track::IsSyncLockSelected ( ) const

Definition at line 245 of file Track.cpp.

246 {
247 #ifdef EXPERIMENTAL_SYNC_LOCK
248  auto pList = mList.lock();
249  if (!pList)
250  return false;
251 
252  auto p = pList->GetOwner();
253  if (!p || !ProjectSettings::Get( *p ).IsSyncLocked())
254  return false;
255 
256  auto shTrack = this->SubstituteOriginalTrack();
257  if (!shTrack)
258  return false;
259 
260  const auto pTrack = shTrack.get();
261  auto trackRange = TrackList::SyncLockGroup( pTrack );
262 
263  if (trackRange.size() <= 1) {
264  // Not in a sync-locked group.
265  // Return true iff selected and of a sync-lockable type.
266  return (IsSyncLockableNonLabelTrack( pTrack ) ||
267  track_cast<const LabelTrack*>( pTrack )) && GetSelected();
268  }
269 
270  // Return true iff any track in the group is selected.
271  return *(trackRange + &Track::IsSelected).begin();
272 #endif
273 
274  return false;
275 }

References ProjectSettings::Get(), GetSelected(), IsSelected(), anonymous_namespace{Track.cpp}::IsSyncLockableNonLabelTrack(), ProjectSettings::IsSyncLocked(), mList, SubstituteOriginalTrack(), and TrackList::SyncLockGroup().

Referenced by ClipParameters::ClipParameters(), TrackArt::DrawBackgroundWithSelection(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), IsSelectedOrSyncLockSelected(), TrackInfo::MinimizeSyncLockDrawFunction(), EditActions::Handler::OnPaste(), SelectActions::Handler::OnSelectSyncLockSel(), EffectChangeSpeed::Process(), EffectRepeat::Process(), and EffectSBSMS::Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LinkConsistencyCheck()

bool Track::LinkConsistencyCheck ( )

Definition at line 386 of file Track.cpp.

387 {
388  // Sanity checks for linked tracks; unsetting the linked property
389  // doesn't fix the problem, but it likely leaves us with orphaned
390  // sample blocks instead of much worse problems.
391  bool err = false;
392  if (GetLinked())
393  {
394  Track *l = GetLink();
395  if (l)
396  {
397  // A linked track's partner should never itself be linked
398  if (l->GetLinked())
399  {
400  wxLogWarning(
401  wxT("Left track %s had linked right track %s with extra right track link.\n Removing extra link from right track."),
402  GetName(), l->GetName());
403  err = true;
404  l->SetLinked(false);
405  }
406 
407  // Channels should be left and right
408  if ( !( (GetChannel() == Track::LeftChannel &&
409  l->GetChannel() == Track::RightChannel) ||
411  l->GetChannel() == Track::LeftChannel) ) )
412  {
413  wxLogWarning(
414  wxT("Track %s and %s had left/right track links out of order. Setting tracks to not be linked."),
415  GetName(), l->GetName());
416  err = true;
417  SetLinked(false);
418  }
419  }
420  else
421  {
422  wxLogWarning(
423  wxT("Track %s had link to NULL track. Setting it to not be linked."),
424  GetName());
425  err = true;
426  SetLinked(false);
427  }
428  }
429 
430  return ! err;
431 }

References GetChannel(), GetLink(), GetLinked(), GetName(), LeftChannel, RightChannel, and SetLinked().

Here is the call graph for this function:

◆ Merge()

void Track::Merge ( const Track orig)
virtual

Reimplemented in WaveTrack, and PlayableTrack.

Definition at line 108 of file Track.cpp.

109 {
110  mSelected = orig.mSelected;
111 }

References mSelected.

Referenced by PlayableTrack::Merge().

Here is the caller graph for this function:

◆ Notify()

void Track::Notify ( int  code = -1)

Definition at line 277 of file Track.cpp.

278 {
279  auto pList = mList.lock();
280  if (pList)
281  pList->DataEvent( SharedPointer(), code );
282 }

References mList, and SharedPointer().

Referenced by WaveTrack::SetGain(), PlayableTrack::SetMute(), SetName(), WaveTrack::SetPan(), and PlayableTrack::SetSolo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Offset()

void Track::Offset ( double  t)
inline

Definition at line 427 of file Track.h.

427 { SetOffset(GetOffset() + t); }

Referenced by TrackShifter::DoHorizontalOffset(), Effect::Preview(), and StretchHandle::Stretch().

Here is the caller graph for this function:

◆ Paste()

virtual void Track::Paste ( double   WXUNUSEDt,
const Track WXUNUSEDsrc 
)
pure virtual

Referenced by SyncLockAdjust().

Here is the caller graph for this function:

◆ PasteInto()

virtual Holder Track::PasteInto ( AudacityProject ) const
pure virtual

Find or create the destination track for a paste, maybe in a different project.

Returns
A smart pointer to the track; its use_count() can tell whether it is new

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Referenced by anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected().

Here is the caller graph for this function:

◆ SameKindAs()

bool Track::SameKindAs ( const Track track) const
inline

Definition at line 480 of file Track.h.

481  { return GetKind() == track.GetKind(); }

References GetKind().

Referenced by TrackShifter::CommonMayMigrateTo(), and anonymous_namespace{TimeShiftHandle.cpp}::FindCorrespondence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetChannel()

void Track::SetChannel ( ChannelType  c)
inlineprivate

Definition at line 376 of file Track.h.

376 { mChannel = c; }

Referenced by FinishCopy().

Here is the caller graph for this function:

◆ SetDefaultName()

void Track::SetDefaultName ( const wxString &  n)
inline

Definition at line 412 of file Track.h.

412 { mDefaultName = n; }

Referenced by TimeTrack::CleanState(), TimeTrack::Init(), WaveTrack::Init(), LabelTrack::LabelTrack(), NoteTrack::NoteTrack(), and WaveTrack::WaveTrack().

Here is the caller graph for this function:

◆ SetId()

void Track::SetId ( TrackId  id)
inlineprivate

Definition at line 271 of file Track.h.

271 { mId = id; }

References id.

Referenced by TrackList::DoAdd(), TrackList::DoAddToHead(), TrackList::RegisterPendingNewTrack(), and TrackList::Replace().

Here is the caller graph for this function:

◆ SetIndex()

void Track::SetIndex ( int  index)

Definition at line 170 of file Track.cpp.

171 {
172  mIndex = index;
173 }

References mIndex.

Referenced by TrackList::RecalcPositions().

Here is the caller graph for this function:

◆ SetLinked()

void Track::SetLinked ( bool  l)
private

Definition at line 175 of file Track.cpp.

176 {
177  auto pList = mList.lock();
178  if (pList && !pList->mPendingUpdates.empty()) {
179  auto orig = pList->FindById( GetId() );
180  if (orig && orig != this) {
181  orig->SetLinked(l);
182  return;
183  }
184  }
185 
186  DoSetLinked(l);
187 
188  if (pList) {
189  pList->RecalcPositions(mNode);
190  pList->ResizingEvent(mNode);
191  }
192 }

References DoSetLinked(), GetId(), mList, and mNode.

Referenced by FinishCopy(), WaveTrack::HandleXMLTag(), and LinkConsistencyCheck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetName()

void Track::SetName ( const wxString &  n)

Definition at line 83 of file Track.cpp.

84 {
85  if ( mName != n ) {
86  mName = n;
87  Notify();
88  }
89 }

References mName, and Notify().

Referenced by Effect::AddedAnalysisTrack::AddedAnalysisTrack(), SetTrackStatusCommand::ApplyInner(), TimeTrack::CleanState(), FinishCopy(), HandleCommonXMLAttribute(), ImportMIDI(), TimeTrack::Init(), WaveTrack::Init(), LabelTrack::LabelTrack(), Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(), NoteTrack::NoteTrack(), and WaveTrack::WaveTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOffset()

virtual void Track::SetOffset ( double  o)
inlinevirtual

Reimplemented in TimeTrack, WaveTrack, and LabelTrack.

Definition at line 428 of file Track.h.

428 { mOffset = o; }

Referenced by NoteTrack::Clear(), NoteTrack::HandleXMLTag(), ImportMIDI(), NoteTrack::Paste(), and NoteTrack::Trim().

Here is the caller graph for this function:

◆ SetOwner()

void Track::SetOwner ( const std::weak_ptr< TrackList > &  list,
TrackNodePointer  node 
)
private

Update mNode when Track is added to TrackList, or removed from it.

Definition at line 136 of file Track.cpp.

138 {
139  // BUG: When using this function to clear an owner, we may need to clear
140  // focused track too. Otherwise focus could remain on an invisible (or deleted) track.
141  mList = list;
142  mNode = node;
143 }

References mList, and mNode.

Referenced by TrackList::DoAdd(), TrackList::DoAddToHead(), TrackList::Permute(), TrackList::RegisterPendingChangedTrack(), TrackList::Remove(), TrackList::Replace(), and TrackList::SwapNodes().

Here is the caller graph for this function:

◆ SetPan()

virtual void Track::SetPan ( float  )
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 430 of file Track.h.

430 { ;}

Referenced by SetTrackAudioCommand::ApplyInner().

Here is the caller graph for this function:

◆ SetPanFromChannelType()

virtual void Track::SetPanFromChannelType ( )
inlinevirtual

Reimplemented in WaveTrack.

Definition at line 431 of file Track.h.

431 { ;};

◆ SetSelected()

void Track::SetSelected ( bool  s)
virtual

Reimplemented in LabelTrack.

Definition at line 91 of file Track.cpp.

92 {
93  if (mSelected != s) {
94  mSelected = s;
95  auto pList = mList.lock();
96  if (pList)
97  pList->SelectionEvent( SharedPointer() );
98  }
99 }

References mList, mSelected, and SharedPointer().

Referenced by SetTrackStatusCommand::ApplyInner(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), HandleCommonXMLAttribute(), LabelEditActions::Handler::OnPasteNewLabel(), and LabelTrack::SetSelected().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTrackControls()

void Track::SetTrackControls ( const std::shared_ptr< CommonTrackCell > &  pControls)

Definition at line 160 of file Track.cpp.

161 {
162  mpControls = pControls;
163 }

References mpControls.

Referenced by CommonTrackControls::TrackControls().

Here is the caller graph for this function:

◆ SetTrackView()

void Track::SetTrackView ( const std::shared_ptr< CommonTrackCell > &  pView)

Definition at line 150 of file Track.cpp.

151 {
152  mpView = pView;
153 }

References mpView.

Referenced by TrackView::Get().

Here is the caller graph for this function:

◆ SharedPointer() [1/4]

template<typename Subclass = Track>
std::shared_ptr<Subclass> Track::SharedPointer ( )
inline

Definition at line 279 of file Track.h.

280  {
281  // shared_from_this is injected into class scope by base class
282  // std::enable_shared_from_this<Track>
283  return std::static_pointer_cast<Subclass>( shared_from_this() );
284  }

Referenced by SelectHandle::AdjustSelection(), SelectionState::ChangeSelectionOnShiftClick(), CoarseTrackShifter::CoarseTrackShifter(), SpectrumView::DoDraw(), TimeShiftHandle::Drag(), EnsureVisible(), TrackPanelAx::GetFocus(), SelectHandle::HandleCenterFrequencyClick(), ClipMoveState::Init(), LabelTrackShifter::LabelTrackShifter(), SelectHandle::MoveSnappingFreqSelection(), NoteTrackShifter::NoteTrackShifter(), Notify(), TimeTrack::PasteInto(), EffectStereoToMono::ProcessOne(), SelectionState::SelectTrack(), TrackFocus::Set(), TrackPanelAx::SetFocus(), SetSelected(), SharedPointer(), SubstituteOriginalTrack(), SubstitutePendingChangedTrack(), and WaveTrackShifter::WaveTrackShifter().

Here is the caller graph for this function:

◆ SharedPointer() [2/4]

template<typename Subclass = const Track>
auto Track::SharedPointer ( ) const -> typename std::enable_if< std::is_const<Subclass>::value, std::shared_ptr<Subclass> >::type
inline

Definition at line 287 of file Track.h.

291  {
292  // shared_from_this is injected into class scope by base class
293  // std::enable_shared_from_this<Track>
294  return std::static_pointer_cast<Subclass>( shared_from_this() );
295  }

◆ SharedPointer() [3/4]

template<typename Subclass = const Track>
static std::shared_ptr<Subclass> Track::SharedPointer ( const Track pTrack)
inlinestatic

Definition at line 303 of file Track.h.

304  { return pTrack ? pTrack->SharedPointer<Subclass>() : nullptr; }

References SharedPointer().

Here is the call graph for this function:

◆ SharedPointer() [4/4]

template<typename Subclass = Track>
static std::shared_ptr<Subclass> Track::SharedPointer ( Track pTrack)
inlinestatic

Definition at line 299 of file Track.h.

300  { return pTrack ? pTrack->SharedPointer<Subclass>() : nullptr; }

References SharedPointer().

Here is the call graph for this function:

◆ Silence()

virtual void Track::Silence ( double   WXUNUSEDt0,
double   WXUNUSEDt1 
)
pure virtual

◆ SubstituteOriginalTrack()

std::shared_ptr< const Track > Track::SubstituteOriginalTrack ( ) const

Definition at line 1207 of file Track.cpp.

1208 {
1209  auto pList = mList.lock();
1210  if (pList) {
1211  const auto id = GetId();
1212  const auto pred = [=]( const ListOfTracks::value_type &ptr ) {
1213  return ptr->GetId() == id; };
1214  const auto end = pList->mPendingUpdates.end();
1215  const auto it = std::find_if( pList->mPendingUpdates.begin(), end, pred );
1216  if (it != end) {
1217  const auto &list2 = (const ListOfTracks &) *pList;
1218  const auto end2 = list2.end();
1219  const auto it2 = std::find_if( list2.begin(), end2, pred );
1220  if ( it2 != end2 )
1221  return *it2;
1222  }
1223  }
1224  return SharedPointer();
1225 }

References GetId(), id, mList, and SharedPointer().

Referenced by IsSyncLockSelected().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SubstitutePendingChangedTrack() [1/2]

std::shared_ptr< Track > Track::SubstitutePendingChangedTrack ( )

Definition at line 1186 of file Track.cpp.

1187 {
1188  // Linear search. Tracks in a project are usually very few.
1189  auto pList = mList.lock();
1190  if (pList) {
1191  const auto id = GetId();
1192  const auto end = pList->mPendingUpdates.end();
1193  auto it = std::find_if(
1194  pList->mPendingUpdates.begin(), end,
1195  [=](const ListOfTracks::value_type &ptr){ return ptr->GetId() == id; } );
1196  if (it != end)
1197  return *it;
1198  }
1199  return SharedPointer();
1200 }

References GetId(), mList, and SharedPointer().

Referenced by TrackPanel::DrawTracks(), SubstitutePendingChangedTrack(), and ProjectFileIO::WriteXML().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SubstitutePendingChangedTrack() [2/2]

std::shared_ptr< const Track > Track::SubstitutePendingChangedTrack ( ) const

Definition at line 1202 of file Track.cpp.

1203 {
1204  return const_cast<Track*>(this)->SubstitutePendingChangedTrack();
1205 }

References SubstitutePendingChangedTrack().

Here is the call graph for this function:

◆ SupportsBasicEditing()

bool Track::SupportsBasicEditing ( ) const
virtual

Whether this track type implements cut-copy-paste; by default, true.

Reimplemented in TimeTrack.

Definition at line 1227 of file Track.cpp.

1228 {
1229  return true;
1230 }

Referenced by SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), EditActions::Handler::OnCut(), SelectActions::Handler::OnSelectSyncLockSel(), and EditActions::Handler::OnSplitCut().

Here is the caller graph for this function:

◆ SyncLockAdjust()

void Track::SyncLockAdjust ( double  oldT1,
double  newT1 
)
virtual

Reimplemented in WaveTrack, and LabelTrack.

Definition at line 284 of file Track.cpp.

285 {
286  if (newT1 > oldT1) {
287  // Insert space within the track
288 
289  if (oldT1 > GetEndTime())
290  return;
291 
292  auto tmp = Cut(oldT1, GetEndTime());
293 
294  Paste(newT1, tmp.get());
295  }
296  else if (newT1 < oldT1) {
297  // Remove from the track
298  Clear(newT1, oldT1);
299  }
300 }

References Clear(), Cut(), GetEndTime(), and Paste().

Referenced by EditActions::Handler::OnPaste().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TypeSwitch() [1/2]

template<typename R = void, typename ... Functions>
R Track::TypeSwitch ( const Functions &...  functions)
inline

Use this function rather than testing track type explicitly and making down-casts.

A variadic function taking any number of function objects, each taking a pointer to Track or a subclass, maybe const-qualified, and maybe a second argument which is a fall-through continuation.

Each of the function objects (and supplied continuations) returns R (or a type convertible to R). Calls the first in the sequence that accepts the actual type of the track.

If no function accepts the track, do nothing and return R{} if R is not void.

If one of the functions invokes the call-through, then the next following applicable function is called.

Template Parameters
RReturn type of this function and each function argument
Functionscallable types deduced from arguments
Parameters
functionstypically lambdas, taking a pointer to a track subclass, and optionally a fall-through call-back

Definition at line 692 of file Track.h.

693  {
694  using WaveExecutor =
695  Executor< R, WaveTrack, Functions... >;
696  using NoteExecutor =
697  Executor< R, NoteTrack, Functions... >;
698  using LabelExecutor =
699  Executor< R, LabelTrack, Functions... >;
700  using TimeExecutor =
701  Executor< R, TimeTrack, Functions... >;
702  using DefaultExecutor =
703  Executor< R, Track >;
704  enum { All = sizeof...( functions ) };
705 
706  static_assert(
707  (1u << All) - 1u ==
708  (WaveExecutor::SetUsed |
709  NoteExecutor::SetUsed |
710  LabelExecutor::SetUsed |
711  TimeExecutor::SetUsed),
712  "Uncallable case in Track::TypeSwitch"
713  );
714 
715  switch (GetKind()) {
716  case TrackKind::Wave:
717  return WaveExecutor{} (this, functions...);
718 #if defined(USE_MIDI)
719  case TrackKind::Note:
720  return NoteExecutor{} (this, functions...);
721 #endif
722  case TrackKind::Label:
723  return LabelExecutor{}(this, functions...);
724  case TrackKind::Time:
725  return TimeExecutor{} (this, functions...);
726  default:
727  return DefaultExecutor{} (this);
728  }
729  }

References All, Label, Note, Time, and Wave.

Referenced by SetClipCommand::ApplyInner(), SetEnvelopeCommand::ApplyInner(), WaveTrack::Merge(), LabelEditActions::Handler::OnCopyLabels(), LabelEditActions::Handler::OnCutLabels(), LabelEditActions::Handler::OnDisjoinLabels(), LabelEditActions::Handler::OnJoinLabels(), LabelEditActions::Handler::OnSilenceLabels(), LabelEditActions::Handler::OnSplitCutLabels(), LabelEditActions::Handler::OnSplitDeleteLabels(), LabelEditActions::Handler::OnSplitLabels(), LabelTrack::Paste(), NoteTrack::Paste(), TimeTrack::Paste(), WaveTrack::Paste(), LabelTrack::PasteOver(), NyquistEffect::ProcessOne(), and StretchHandle::Stretch().

Here is the caller graph for this function:

◆ TypeSwitch() [2/2]

template<typename R = void, typename ... Functions>
R Track::TypeSwitch ( const Functions &...  functions) const
inline

Use this function rather than testing track type explicitly and making down-casts.

A variadic function taking any number of function objects, each taking a pointer to Track or a subclass, maybe const-qualified, and maybe a second argument which is a fall-through continuation.

Each of the function objects (and supplied continuations) returns R (or a type convertible to R). Calls the first in the sequence that accepts the actual type of the track.

If no function accepts the track, do nothing and return R{} if R is not void.

If one of the functions invokes the call-through, then the next following applicable function is called.

Template Parameters
RReturn type of this function and each function argument
Functionscallable types deduced from arguments
Parameters
functionstypically lambdas, taking a pointer to a track subclass, and optionally a fall-through call-back

This is the overload for const tracks, only taking callable arguments that accept first arguments that are pointers to const.

Definition at line 738 of file Track.h.

739  {
740  using WaveExecutor =
741  Executor< R, const WaveTrack, Functions... >;
742  using NoteExecutor =
743  Executor< R, const NoteTrack, Functions... >;
744  using LabelExecutor =
745  Executor< R, const LabelTrack, Functions... >;
746  using TimeExecutor =
747  Executor< R, const TimeTrack, Functions... >;
748  using DefaultExecutor =
749  Executor< R, const Track >;
750  enum { All = sizeof...( functions ) };
751 
752  static_assert(
753  (1u << All) - 1u ==
754  (WaveExecutor::SetUsed |
755  NoteExecutor::SetUsed |
756  LabelExecutor::SetUsed |
757  TimeExecutor::SetUsed),
758  "Uncallable case in Track::TypeSwitch"
759  );
760 
761  switch (GetKind()) {
762  case TrackKind::Wave:
763  return WaveExecutor{} (this, functions...);
764 #if defined(USE_MIDI)
765  case TrackKind::Note:
766  return NoteExecutor{} (this, functions...);
767 #endif
768  case TrackKind::Label:
769  return LabelExecutor{}(this, functions...);
770  case TrackKind::Time:
771  return TimeExecutor{} (this, functions...);
772  default:
773  return DefaultExecutor{} (this);
774  }
775  }

References All, Label, Note, Time, and Wave.

◆ WriteCommonXMLAttributes()

void Track::WriteCommonXMLAttributes ( XMLWriter xmlFile,
bool  includeNameAndSelected = true 
) const

Definition at line 1243 of file Track.cpp.

1245 {
1246  if (includeNameAndSelected) {
1247  xmlFile.WriteAttr(wxT("name"), GetName());
1248  xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
1249  }
1250  if ( mpView )
1251  mpView->WriteXMLAttributes( xmlFile );
1252  if ( mpControls )
1253  mpControls->WriteXMLAttributes( xmlFile );
1254 }

References GetName(), GetSelected(), mpControls, mpView, and XMLWriter::WriteAttr().

Referenced by LabelTrack::WriteXML(), TimeTrack::WriteXML(), and WaveTrack::WriteXML().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteXML()

virtual void Track::WriteXML ( XMLWriter xmlFile) const
pure virtual

Implemented in WaveTrack, TimeTrack, NoteTrack, and LabelTrack.

Friends And Related Function Documentation

◆ track_cast [1/2]

template<typename T >
std::enable_if< std::is_pointer<T>::value && std::is_const< typename std::remove_pointer< T >::type >::value, T >::type track_cast ( const Track track)
friend

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

893 {
894  using BareType = typename std::remove_pointer< T >::type;
895  if (track &&
896  CompatibleTrackKinds( track_kind<BareType>(), track->GetKind() ))
897  return reinterpret_cast<T>(track);
898  else
899  return nullptr;
900 }

◆ track_cast [2/2]

template<typename T >
std::enable_if< std::is_pointer<T>::value, T >::type track_cast ( Track track)
friend

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

875 {
876  using BareType = typename std::remove_pointer< T >::type;
877  if (track &&
878  CompatibleTrackKinds( track_kind<BareType>(), track->GetKind() ))
879  return reinterpret_cast<T>(track);
880  else
881  return nullptr;
882 }

◆ TrackList

friend class TrackList
friend

Definition at line 239 of file Track.h.

Member Data Documentation

◆ LeftChannel

const auto Track::LeftChannel = XMLValueChecker::LeftChannel
static

◆ mChannel

ChannelType Track::mChannel
protected

◆ mDefaultName

wxString Track::mDefaultName
protected

Definition at line 251 of file Track.h.

Referenced by Init().

◆ mId

TrackId Track::mId
private

Identifies the track only in-session, not persistently.

Definition at line 242 of file Track.h.

Referenced by Init().

◆ mIndex

int Track::mIndex
protected

0-based position of this track in its TrackList

Definition at line 249 of file Track.h.

Referenced by GetIndex(), SetIndex(), and Track().

◆ mLinked

bool Track::mLinked
protected

Definition at line 257 of file Track.h.

Referenced by DoSetLinked(), GetLink(), Init(), and Track().

◆ mList

std::weak_ptr<TrackList> Track::mList
protected

◆ mName

wxString Track::mName
protected

Definition at line 250 of file Track.h.

Referenced by Init(), and SetName().

◆ mNode

TrackNodePointer Track::mNode {}
protected

Holds iterator to self, so that TrackList::Find can be constant-time.

mNode's pointer to std::list might not be this TrackList, if it's a pending update track

Definition at line 248 of file Track.h.

Referenced by AdjustPositions(), GetLink(), GetNode(), TrackList::GroupChannels(), SetLinked(), and SetOwner().

◆ mOffset

double Track::mOffset
protected

◆ MonoChannel

const auto Track::MonoChannel = XMLValueChecker::MonoChannel
static

◆ mpControls

std::shared_ptr<CommonTrackCell> Track::mpControls
protected

◆ mpView

std::shared_ptr<CommonTrackCell> Track::mpView
protected

◆ mSelected

bool Track::mSelected
private

Definition at line 254 of file Track.h.

Referenced by Init(), Merge(), SetSelected(), and Track().

◆ RightChannel

const auto Track::RightChannel = XMLValueChecker::RightChannel
static

◆ vrulerSize

wxSize Track::vrulerSize
mutable

◆ WaveTrack

friend Track::WaveTrack
private

Definition at line 373 of file Track.h.


The documentation for this class was generated from the following files:
Track::SubstituteOriginalTrack
std::shared_ptr< const Track > SubstituteOriginalTrack() const
Definition: Track.cpp:1207
Track::mChannel
ChannelType mChannel
Definition: Track.h:390
Track::mOffset
double mOffset
Definition: Track.h:391
Track::RightChannel
static const auto RightChannel
Definition: Track.h:266
Track::mSelected
bool mSelected
Definition: Track.h:254
TrackKind::None
@ None
no class
XMLValueChecker::IsGoodInt
static bool IsGoodInt(const wxString &strInt)
Check that the supplied string can be converted to a long (32bit) integer.
Definition: XMLTagHandler.cpp:158
Track::GetEndTime
virtual double GetEndTime() const =0
Track::GetName
wxString GetName() const
Definition: Track.h:409
Track::GetLinked
bool GetLinked() const
Definition: Track.h:371
Track::SharedPointer
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:279
Track::Cut
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1))=0
anonymous_namespace{Track.cpp}::IsSyncLockableNonLabelTrack
bool IsSyncLockableNonLabelTrack(const Track *pTrack)
Definition: Track.cpp:226
Track::GetOwner
std::shared_ptr< TrackList > GetOwner() const
Definition: Track.h:367
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:39
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
Track::mNode
TrackNodePointer mNode
Holds iterator to self, so that TrackList::Find can be constant-time.
Definition: Track.h:248
Track::Paste
virtual void Paste(double WXUNUSED(t), const Track *WXUNUSED(src))=0
Track::SetOffset
virtual void SetOffset(double o)
Definition: Track.h:428
Track::IsSyncLockSelected
bool IsSyncLockSelected() const
Definition: Track.cpp:245
Track::mDefaultName
wxString mDefaultName
Definition: Track.h:251
Track::mpControls
std::shared_ptr< CommonTrackCell > mpControls
Definition: Track.h:816
XMLValueChecker::IsGoodString
static bool IsGoodString(const wxString &str)
Definition: XMLTagHandler.cpp:39
Track::mLinked
bool mLinked
Definition: Track.h:257
TrackKind::All
@ All
the root class
Track::mName
wxString mName
Definition: Track.h:250
Track::SetSelected
virtual void SetSelected(bool s)
Definition: Track.cpp:91
ProjectSettings::IsSyncLocked
bool IsSyncLocked() const
Definition: ProjectSettings.cpp:190
Track::mList
std::weak_ptr< TrackList > mList
Definition: Track.h:245
Track::SubstitutePendingChangedTrack
std::shared_ptr< Track > SubstitutePendingChangedTrack()
Definition: Track.cpp:1186
Track::mId
TrackId mId
Identifies the track only in-session, not persistently.
Definition: Track.h:242
Track::GetId
TrackId GetId() const
Definition: Track.h:269
TrackKind::Time
@ Time
ListOfTracks
std::list< std::shared_ptr< Track > > ListOfTracks
Definition: Track.h:52
Track::WaveTrack
friend WaveTrack
Definition: Track.h:373
Track::MonoChannel
static const auto MonoChannel
Definition: Track.h:267
Track::GetOffset
virtual double GetOffset() const =0
Track::mpView
std::shared_ptr< CommonTrackCell > mpView
Definition: Track.h:815
Track::GetLink
Track * GetLink() const
Definition: Track.cpp:199
Track::GetKind
virtual TrackKind GetKind() const
Definition: Track.h:466
Track::Clone
virtual Holder Clone() const =0
CompatibleTrackKinds
constexpr bool CompatibleTrackKinds(TrackKind desired, TrackKind actual)
Compile-time function on enum values.
Definition: Track.h:82
Track::IsSelected
bool IsSelected() const
Definition: Track.cpp:364
Track::SetLinked
void SetLinked(bool l)
Definition: Track.cpp:175
Track::LeftChannel
static const auto LeftChannel
Definition: Track.h:265
Track::SetChannel
void SetChannel(ChannelType c)
Definition: Track.h:376
Track::GetSelected
bool GetSelected() const
Definition: Track.h:414
Track::mIndex
int mIndex
0-based position of this track in its TrackList
Definition: Track.h:249
id
int id
Definition: WaveTrackControls.cpp:589
Track::SetName
void SetName(const wxString &n)
Definition: Track.cpp:83
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:238
Track::IsLeader
bool IsLeader() const
Definition: Track.cpp:370
Track::Notify
void Notify(int code=-1)
Definition: Track.cpp:277
Track::DoSetLinked
void DoSetLinked(bool l)
Definition: Track.cpp:194
Track::Init
void Init(const Track &orig)
Definition: Track.cpp:71
TrackKind::Wave
@ Wave
Track::GetChannel
virtual ChannelType GetChannel() const
Definition: Track.h:424
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
Track::Clear
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1))=0
TrackKind::Label
@ Label
TrackList::SyncLockGroup
static TrackIterRange< Track > SyncLockGroup(Track *pTrack)
Definition: Track.cpp:639
TimeTrack
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24
NoteTrack
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:66
TrackKind::Note
@ Note
Track::vrulerSize
wxSize vrulerSize
Definition: Track.h:342