Audacity  3.0.3
ODWaveTrackTaskQueue.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ODWaveTrackTaskQueue.h
6 
7  Created by Michael Chinen (mchinen)
8  Audacity(R) is copyright (c) 1999-2008 Audacity Team.
9  License: GPL v2. See License.txt.
10 
11 ******************************************************************//*******************************************************************/
18 
19 
20 
21 
22 #ifndef __AUDACITY_ODWAVETRACKTASKQUEUE__
23 #define __AUDACITY_ODWAVETRACKTASKQUEUE__
24 
25 #include <vector>
26 #include "ODTaskThread.h"
27 #include "../Internat.h" // for TranslatableString
28 class Track;
29 class WaveTrack;
30 class ODTask;
33 {
34  public:
35 
36  // Constructor / Destructor
37 
40 
41  virtual ~ODWaveTrackTaskQueue();
42 
43 
44 
46  void AddWaveTrack( const std::shared_ptr< WaveTrack > &track);
47 
49  void DemandTrackUpdate(WaveTrack* track, double seconds);
50 
52  void ReplaceWaveTrack(Track *oldTrack,
53  const std::shared_ptr<Track> &newTrack);
54 
55  //if the wavetrack is in this queue, and is not the only wavetrack, clones the tasks and schedules it.
56  void MakeWaveTrackIndependent( const std::shared_ptr< WaveTrack > &track);
57 
59  bool CanMergeWith(ODWaveTrackTaskQueue* otherQueue);
60  void MergeWaveTrack( const std::shared_ptr< WaveTrack > &track);
61 
62 
63  //returns true if the argument is in the WaveTrack list.
64  bool ContainsWaveTrack(const WaveTrack* track);
65 
67  int GetNumWaveTracks();
68 
70  void AddTask(std::unique_ptr<ODTask> &&mtask);
71 
72  //returns true if either tracks or tasks are empty
73  bool IsEmpty();
74 
75  //returns true if the foremost task exists and is empty.
76  bool IsFrontTaskComplete();
77 
79  void RemoveFrontTask();
80 
83 
85  int GetNumTasks();
86 
88  ODTask* GetTask(size_t x);
89 
91  void FillTipForWaveTrack( const WaveTrack * t, TranslatableString &tip );
92 
93  protected:
94 
95  // Remove expired weak pointers to tracks
96  void Compress();
97 
98  //because we need to save this around for the tool tip.
100 
101 
103  std::vector< std::weak_ptr< WaveTrack > > mTracks;
105 
107  std::vector<std::unique_ptr<ODTask>> mTasks;
109 
110 };
111 
112 #endif
113 
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
ODWaveTrackTaskQueue::GetTask
ODTask * GetTask(size_t x)
returns a ODTask at position x
Definition: ODWaveTrackTaskQueue.cpp:233
ODWaveTrackTaskQueue::mTasks
std::vector< std::unique_ptr< ODTask > > mTasks
the list of tasks associated with the tracks. This class owns these tasks.
Definition: ODWaveTrackTaskQueue.h:107
ODWaveTrackTaskQueue::GetFrontTask
ODTask * GetFrontTask()
Schedules the front task for immediate execution.
Definition: ODWaveTrackTaskQueue.cpp:294
ODWaveTrackTaskQueue::GetNumWaveTracks
int GetNumWaveTracks()
returns the number of wavetracks in this queue.
Definition: ODWaveTrackTaskQueue.cpp:211
ODWaveTrackTaskQueue::FillTipForWaveTrack
void FillTipForWaveTrack(const WaveTrack *t, TranslatableString &tip)
fills in the status bar message for a given track
Definition: ODWaveTrackTaskQueue.cpp:307
ODWaveTrackTaskQueue::Compress
void Compress()
Definition: ODWaveTrackTaskQueue.cpp:327
ODWaveTrackTaskQueue::AddTask
void AddTask(std::unique_ptr< ODTask > &&mtask)
Add a task to the queue.
Definition: ODWaveTrackTaskQueue.cpp:108
ODWaveTrackTaskQueue::~ODWaveTrackTaskQueue
virtual ~ODWaveTrackTaskQueue()
Definition: ODWaveTrackTaskQueue.cpp:30
ODWaveTrackTaskQueue::IsFrontTaskComplete
bool IsFrontTaskComplete()
Definition: ODWaveTrackTaskQueue.cpp:263
ODWaveTrackTaskQueue::mTracks
std::vector< std::weak_ptr< WaveTrack > > mTracks
the list of tracks associated with this queue.
Definition: ODWaveTrackTaskQueue.h:103
ODWaveTrackTaskQueue::ContainsWaveTrack
bool ContainsWaveTrack(const WaveTrack *track)
returns true if the argument is in the WaveTrack list.
Definition: ODWaveTrackTaskQueue.cpp:82
ODWaveTrackTaskQueue::mTasksMutex
ODLock mTasksMutex
Definition: ODWaveTrackTaskQueue.h:108
ODWaveTrackTaskQueue::mTracksMutex
ODLock mTracksMutex
Definition: ODWaveTrackTaskQueue.h:104
ODWaveTrackTaskQueue::ReplaceWaveTrack
void ReplaceWaveTrack(Track *oldTrack, const std::shared_ptr< Track > &newTrack)
replaces all instances of a WaveTrack within this task with another.
Definition: ODWaveTrackTaskQueue.cpp:192
ODWaveTrackTaskQueue::MakeWaveTrackIndependent
void MakeWaveTrackIndependent(const std::shared_ptr< WaveTrack > &track)
Definition: ODWaveTrackTaskQueue.cpp:131
ODWaveTrackTaskQueue::RemoveFrontTask
void RemoveFrontTask()
Removes and deletes the front task from the list.
Definition: ODWaveTrackTaskQueue.cpp:282
ODWaveTrackTaskQueue::CanMergeWith
bool CanMergeWith(ODWaveTrackTaskQueue *otherQueue)
returns whether or not this queue's task list and another's can merge together, as when we make two m...
Definition: ODWaveTrackTaskQueue.cpp:44
ODWaveTrackTaskQueue
A class representing a modular task to be used with the On-Demand structures.
Definition: ODWaveTrackTaskQueue.h:33
ODTask
A class representing a modular task to be used with the On-Demand structures.
Definition: ODTask.h:40
ODWaveTrackTaskQueue::MergeWaveTrack
void MergeWaveTrack(const std::shared_ptr< WaveTrack > &track)
Definition: ODWaveTrackTaskQueue.cpp:67
ODLock
Definition: ODTaskThread.h:89
ODWaveTrackTaskQueue::ODWaveTrackTaskQueue
ODWaveTrackTaskQueue()
Constructs an ODWaveTrackTaskQueue.
Definition: ODWaveTrackTaskQueue.cpp:26
ODWaveTrackTaskQueue::IsEmpty
bool IsEmpty()
Definition: ODWaveTrackTaskQueue.cpp:246
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:239
ODTaskThread.h
ODWaveTrackTaskQueue::GetNumTasks
int GetNumTasks()
returns the number of ODTasks in this queue
Definition: ODWaveTrackTaskQueue.cpp:223
ODWaveTrackTaskQueue::mTipMsg
TranslatableString mTipMsg
Definition: ODWaveTrackTaskQueue.h:99
ODWaveTrackTaskQueue::AddWaveTrack
void AddWaveTrack(const std::shared_ptr< WaveTrack > &track)
Adds a track to the associated list.
Definition: ODWaveTrackTaskQueue.cpp:97
ODWaveTrackTaskQueue::DemandTrackUpdate
void DemandTrackUpdate(WaveTrack *track, double seconds)
changes the tasks associated with this Waveform to process the task from a different point in the tra...
Definition: ODWaveTrackTaskQueue.cpp:176