Audacity 3.2.0
Public Types | Public Member Functions | Public Attributes | List of all members
WaveCacheElement Struct Referencefinal

An element of a cache that contains the waveform data. More...

#include <WaveDataCache.h>

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

Public Types

using Columns = std::array< WaveDisplayColumn, GraphicsDataCacheBase::CacheElementWidth >
 

Public Member Functions

void Smooth (GraphicsDataCacheElementBase *prevElement) override
 This method is called during the lookup when new items are inserted. prevElement can be nullptr. Default implementation is empty. More...
 
- Public Member Functions inherited from GraphicsDataCacheElementBase
virtual ~GraphicsDataCacheElementBase ()=default
 
virtual void Dispose ()
 This method is called when the item is evicted from the cache. Default implementation is empty. More...
 
virtual void Smooth (GraphicsDataCacheElementBase *prevElement)
 This method is called during the lookup when new items are inserted. prevElement can be nullptr. Default implementation is empty. More...
 

Public Attributes

Columns Data
 
size_t AvailableColumns { 0 }
 
- Public Attributes inherited from GraphicsDataCacheElementBase
uint64_t LastCacheAccess { 0 }
 Index filled by GraphicsDataCacheBase to implement LRU eviction policy. More...
 
uint64_t LastUpdate { 0 }
 The last time the item was updated. If (!IsComplete && LastUpdate < LastCacheAccess) the item will be updated. More...
 
bool IsComplete { false }
 Cache implementation is responsible to set this flag when all the data of the item is filled. More...
 
bool AwaitsEviction { false }
 This flag is used to simplify the eviction algorithm. More...
 

Detailed Description

An element of a cache that contains the waveform data.

Definition at line 80 of file WaveDataCache.h.

Member Typedef Documentation

◆ Columns

Definition at line 82 of file WaveDataCache.h.

Member Function Documentation

◆ Smooth()

void WaveCacheElement::Smooth ( GraphicsDataCacheElementBase prevElement)
overridevirtual

This method is called during the lookup when new items are inserted. prevElement can be nullptr. Default implementation is empty.

Reimplemented from GraphicsDataCacheElementBase.

Definition at line 466 of file WaveDataCache.cpp.

467{
468 if (prevElement == nullptr||prevElement->AwaitsEviction || AvailableColumns == 0)
469 return;
470
471 const auto prev = static_cast<WaveCacheElement*>(prevElement);
472
473 if (prev->AvailableColumns == 0)
474 return;
475
476 const auto prevLastColumn = prev->Data[prev->AvailableColumns - 1];
477 auto& firstColumn = Data[0];
478
479 bool updated = false;
480
481 if (prevLastColumn.min > firstColumn.max)
482 {
483 firstColumn.max = prevLastColumn.min;
484 updated = true;
485 }
486
487 if (prevLastColumn.max < firstColumn.min)
488 {
489 firstColumn.min = prevLastColumn.max;
490 updated = true;
491 }
492
493 if (updated)
494 firstColumn.rms =
495 std::clamp(firstColumn.rms, firstColumn.min, firstColumn.max);
496}
bool AwaitsEviction
This flag is used to simplify the eviction algorithm.
An element of a cache that contains the waveform data.
Definition: WaveDataCache.h:81
size_t AvailableColumns
Definition: WaveDataCache.h:86

References AvailableColumns, GraphicsDataCacheElementBase::AwaitsEviction, and Data.

Member Data Documentation

◆ AvailableColumns

size_t WaveCacheElement::AvailableColumns { 0 }

Definition at line 86 of file WaveDataCache.h.

Referenced by WaveDataCache::InitializeElement(), and Smooth().

◆ Data

Columns WaveCacheElement::Data

Definition at line 85 of file WaveDataCache.h.

Referenced by WaveDataCache::InitializeElement(), and Smooth().


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