Audacity 3.2.0
Public Types | Public Member Functions | Public Attributes | List of all members
anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator Struct Reference
Collaboration diagram for anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator:
[legend]

Public Types

using Type = unsigned long long
 
using SpaceArray = std::vector< Type >
 

Public Member Functions

Type CalculateUsage (const TrackList &tracks, SampleBlockIDSet &seen)
 
void Calculate (UndoManager &manager)
 

Public Attributes

SpaceArray space
 
Type clipboardSpaceUsage
 

Detailed Description

Definition at line 52 of file HistoryWindow.cpp.

Member Typedef Documentation

◆ SpaceArray

using anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator::SpaceArray = std::vector<Type>

Definition at line 54 of file HistoryWindow.cpp.

◆ Type

using anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator::Type = unsigned long long

Definition at line 53 of file HistoryWindow.cpp.

Member Function Documentation

◆ Calculate()

void anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator::Calculate ( UndoManager manager)
inline

Definition at line 71 of file HistoryWindow.cpp.

72 {
74
75 // After copies and pastes, a block file may be used in more than
76 // one place in one undo history state, and it may be used in more than
77 // one undo history state. It might even be used in two states, but not
78 // in another state that is between them -- as when you have state A,
79 // then make a cut to get state B, but then paste it back into state C.
80
81 // So be sure to count each block file once only, in the last undo item that
82 // contains it.
83
84 // Why the last and not the first? Because the user of the History dialog
85 // may DELETE undo states, oldest first. To reclaim disk space you must
86 // DELETE all states containing the block file. So the block file's
87 // contribution to space usage should be counted only in that latest
88 // state.
89
90 manager.VisitStates(
91 [this, &seen](const UndoStackElem &elem) {
92 // Scan all tracks at current level
93 if (auto pTracks = TrackList::FindUndoTracks(elem))
94 space.push_back(CalculateUsage(*pTracks, seen));
95 },
96 true // newest state first
97 );
98
99 // Count the usage of the clipboard separately, using another set. Do not
100 // multiple-count any block occurring multiple times within the clipboard.
101 seen.clear();
103 Clipboard::Get().GetTracks(), seen);
104
105 //TIMER_STOP( space_calc );
106 }
static const AttachedProjectObjects::RegisteredFactory manager
std::unordered_set< SampleBlockID > SampleBlockIDSet
Definition: WaveTrack.h:1261
static Clipboard & Get()
Definition: Clipboard.cpp:28
static TrackList * FindUndoTracks(const UndoStackElem &state)
Definition: Track.cpp:1406
Holds one item with description and time range for the UndoManager.
Definition: UndoManager.h:117
Type CalculateUsage(const TrackList &tracks, SampleBlockIDSet &seen)

References TrackList::FindUndoTracks(), Clipboard::Get(), and manager.

Here is the call graph for this function:

◆ CalculateUsage()

Type anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator::CalculateUsage ( const TrackList tracks,
SampleBlockIDSet seen 
)
inline

Definition at line 56 of file HistoryWindow.cpp.

57 {
58 Type result = 0;
59 //TIMER_START( "CalculateSpaceUsage", space_calc );
61 tracks,
63 &seen
64 );
65 return result;
66 }
std::function< void(const SampleBlock &) > BlockSpaceUsageAccumulator(unsigned long long &total)
Definition: SampleBlock.h:105
const auto tracks
void InspectBlocks(const TrackList &tracks, BlockInspector inspector, SampleBlockIDSet *pIDs)
Definition: WaveTrack.cpp:4512

References BlockSpaceUsageAccumulator(), InspectBlocks(), and tracks.

Here is the call graph for this function:

Member Data Documentation

◆ clipboardSpaceUsage

Type anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator::clipboardSpaceUsage

Definition at line 69 of file HistoryWindow.cpp.

◆ space

SpaceArray anonymous_namespace{HistoryWindow.cpp}::SpaceUsageCalculator::space

Definition at line 68 of file HistoryWindow.cpp.


The documentation for this struct was generated from the following file: