Audacity 3.2.0
PendingTracks.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file PendingTracks.h
6
7 Paul Licameli
8
9 **********************************************************************/
10#ifndef __AUDACITY_PENDING_TRACKS__
11#define __AUDACITY_PENDING_TRACKS__
12
13#include "ClientData.h"
14#include "Observer.h"
15
16class AudacityProject;
17class Channel;
18class Track;
19class TrackId;
20class TrackList;
21struct TrackListEvent;
22
23class TRACK_API PendingTracks final
24 : public ClientData::Base
25 , public Observer::Publisher<TrackListEvent>
26{
27public:
29 static const PendingTracks &Get(const AudacityProject &project);
30
32 PendingTracks(const PendingTracks&) = delete;
35
38
45 void RegisterPendingNewTracks(TrackList &&list);
46
49 Channel &SubstitutePendingChangedChannel(Channel &channel) const;
50 const Channel &SubstitutePendingChangedChannel(const Channel &channel) const;
51
54 Track &SubstitutePendingChangedTrack(Track &track) const;
55 const Track &SubstitutePendingChangedTrack(const Track &track) const;
56
59 const Channel &SubstituteOriginalChannel(const Channel &channel) const;
60
63 const Track &SubstituteOriginalTrack(const Track &track) const;
64
67 using Updater = std::function<void(Track &dest, const Track &src)>;
68
70 //
83 Track* RegisterPendingChangedTrack(
85 Track *src
86 );
87
90 void UpdatePendingTracks();
91
93
99 void ClearPendingTracks(
100 std::vector<std::shared_ptr<Track>> *pAdded = nullptr);
101
103 //
109 bool ApplyPendingTracks();
110
111 bool HasPendingTracks() const;
112
113private:
114 std::pair<Track *, Channel *>
115 DoSubstitutePendingChangedChannel(Track &track, size_t channelIndex) const;
116
117 std::pair<const Track *, const Channel*>
118 DoSubstituteOriginalChannel(const Track &track, size_t channelIndex) const;
119
122 std::vector<Updater> mUpdaters;
123 std::shared_ptr<TrackList> mPendingUpdates;
124};
125
126#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
const auto project
static CustomUpdaterValue updater
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
TrackList & mTracks
std::shared_ptr< TrackList > mPendingUpdates
std::vector< Updater > mUpdaters
PendingTracks(const PendingTracks &)=delete
Observer::Subscription mTrackListSubscription
std::function< void(Track &dest, const Track &src)> Updater
Definition: PendingTracks.h:67
PendingTracks & operator=(const PendingTracks &)=delete
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
An in-session identifier of track objects across undo states. It does not persist between sessions.
Definition: Track.h:79
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202
A convenient default parameter for class template Site.
Definition: ClientData.h:29
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
Definition: Track.h:803