Beatmup
Beatmup::Fragments::Fragment Class Referenceabstract

Represents a continuous set of data samples. More...

#include <fragment.h>

Inheritance diagram for Beatmup::Fragments::Fragment:
Beatmup::Audio::SignalFragment

Public Member Functions

const int getSampleCount () const
 
virtual Fragmentclone () const =0
 
Fragmentedit ()
 Enables editing of the current frame. More...
 
Fragmentuse ()
 References the frame when it is used one more time. More...
 
void drop ()
 Dereferences the frame when it is not used any more. More...
 

Protected Member Functions

 Fragment ()
 
virtual ~Fragment ()
 

Protected Attributes

int sampleCount
 number of samples within this frame More...
 

Private Member Functions

 Fragment (const Fragment &)=delete
 disabling copying constructor More...
 

Private Attributes

std::mutex access
 exclusive access More...
 
unsigned int referenceCount
 number of occurrences of this frame in sequences More...
 

Detailed Description

Represents a continuous set of data samples.

Definition at line 31 of file fragment.h.

Constructor & Destructor Documentation

◆ Fragment() [1/2]

Beatmup::Fragments::Fragment::Fragment ( const Fragment )
privatedelete

disabling copying constructor

◆ Fragment() [2/2]

Fragment::Fragment ( )
protected

Definition at line 24 of file fragment.cpp.

24 : referenceCount(0), sampleCount(0) {};
unsigned int referenceCount
number of occurrences of this frame in sequences
Definition: fragment.h:36
int sampleCount
number of samples within this frame
Definition: fragment.h:39

◆ ~Fragment()

virtual Beatmup::Fragments::Fragment::~Fragment ( )
inlineprotectedvirtual

Definition at line 41 of file fragment.h.

41 {};

Member Function Documentation

◆ getSampleCount()

const int Beatmup::Fragments::Fragment::getSampleCount ( ) const
inline

Definition at line 44 of file fragment.h.

44 { return sampleCount; }

◆ clone()

virtual Fragment* Beatmup::Fragments::Fragment::clone ( ) const
pure virtual

◆ edit()

Fragment * Fragment::edit ( )

Enables editing of the current frame.

Definition at line 27 of file fragment.cpp.

27  {
28  std::lock_guard<std::mutex> lock(access);
29  if (referenceCount > 1) {
31  Fragment* copy = clone();
32  copy->referenceCount = 1;
33  return copy;
34  }
35  return this;
36 }
Represents a continuous set of data samples.
Definition: fragment.h:31
std::mutex access
exclusive access
Definition: fragment.h:35
virtual Fragment * clone() const =0
Beatmup::AbstractBitmap * copy

◆ use()

Fragment * Fragment::use ( )

References the frame when it is used one more time.

Definition at line 39 of file fragment.cpp.

39  {
40  std::lock_guard<std::mutex> lock(access);
42  return this;
43 }

◆ drop()

void Fragment::drop ( )

Dereferences the frame when it is not used any more.

Definition at line 46 of file fragment.cpp.

46  {
47  std::unique_lock<std::mutex> lock(access);
48  if (referenceCount <= 1) {
49  lock.unlock();
50  delete this;
51  return;
52  }
54  lock.unlock();
55 }

Member Data Documentation

◆ access

std::mutex Beatmup::Fragments::Fragment::access
private

exclusive access

Definition at line 35 of file fragment.h.

◆ referenceCount

unsigned int Beatmup::Fragments::Fragment::referenceCount
private

number of occurrences of this frame in sequences

Definition at line 36 of file fragment.h.

◆ sampleCount

int Beatmup::Fragments::Fragment::sampleCount
protected

number of samples within this frame

Definition at line 39 of file fragment.h.


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