kwave  18.07.70
Kwave::Stripe::MappedArray Class Reference
Inheritance diagram for Kwave::Stripe::MappedArray:
Inheritance graph
Collaboration diagram for Kwave::Stripe::MappedArray:
Collaboration graph

Public Member Functions

 MappedArray (Stripe &stripe)
 
virtual ~MappedArray ()
 
unsigned int copy (unsigned int dst, unsigned int src, unsigned int cnt)
 
unsigned int read (Kwave::SampleArray &buffer, unsigned int dstoff, unsigned int offset, unsigned int length)
 
- Public Member Functions inherited from Kwave::SampleArray
 SampleArray ()
 
 SampleArray (unsigned int size)
 
virtual ~SampleArray ()
 
const sample_tconstData () const
 
sample_tdata ()
 
void setRawData (sample_t *data, unsigned int size)
 
void resetRawData ()
 
void fill (sample_t value)
 
sample_toperator[] (unsigned int index)
 
const sample_toperator[] (unsigned int index) const
 
bool resize (unsigned int size) Q_REQUIRED_RESULT
 
unsigned int size () const
 
bool isEmpty () const
 

Private Attributes

Stripem_stripe
 
sample_tm_storage
 
unsigned int m_length
 

Detailed Description

Wrapper for mapping the storage into memory and accessing it like a normal QMemArray<sample_t>. Should be used like a guard, internally uses a MapStorageGuard.

Definition at line 247 of file Stripe.h.

Constructor & Destructor Documentation

◆ MappedArray()

Kwave::Stripe::MappedArray::MappedArray ( Stripe stripe)
explicit

Constructor

Parameters
stripeshould be *this of the stripe

Definition at line 32 of file Stripe.cpp.

References m_length, m_storage, m_stripe, Kwave::Stripe::mapStorage(), and Kwave::SampleArray::setRawData().

33  :m_stripe(stripe), m_storage(Q_NULLPTR), m_length(stripe.length())
34 {
36  if (!m_storage) m_length = 0;
38 }
unsigned int m_length
Definition: Stripe.h:295
sample_t * mapStorage()
Definition: Stripe.cpp:601
void setRawData(sample_t *data, unsigned int size)
Definition: SampleArray.cpp:47
Here is the call graph for this function:

◆ ~MappedArray()

Kwave::Stripe::MappedArray::~MappedArray ( )
virtual

Destructor

Definition at line 41 of file Stripe.cpp.

References m_length, m_storage, m_stripe, Kwave::SampleArray::resetRawData(), and Kwave::Stripe::unmapStorage().

42 {
43  if (m_length) resetRawData();
45 }
unsigned int m_length
Definition: Stripe.h:295
void unmapStorage()
Definition: Stripe.cpp:607
Here is the call graph for this function:

Member Function Documentation

◆ copy()

unsigned int Kwave::Stripe::MappedArray::copy ( unsigned int  dst,
unsigned int  src,
unsigned int  cnt 
)

Copy a portion of samples to another location, within the same storage.

Parameters
dstdestination index [samples]
srcsource index [samples]
cntnumber of samples
Returns
cnt if succeeded or zero if the mapping has failed
Note
this is optimized for speed, no range checks!

Definition at line 48 of file Stripe.cpp.

References m_length, and m_storage.

Referenced by Kwave::Stripe::deleteRange().

51 {
52 // qDebug(" Stripe::MappedArray::copy(%u, %u, %u)", dst, src, cnt);
53  if (!m_length) return 0;
54 
55 #ifdef STRICTLY_QT
56  unsigned int rest = cnt;
57  while (rest--) {
58  (*this)[dst++] = (*this)[src++];
59  }
60 #else
61  sample_t *_samples = m_storage;
62  if (!_samples) return 0;
63  // no MEMCPY here !
64  memmove(&(_samples[dst]), &(_samples[src]), cnt * sizeof(sample_t));
65 #endif
66 
67  return cnt;
68 }
unsigned int m_length
Definition: Stripe.h:295
qint32 sample_t
Definition: Sample.h:37
Here is the caller graph for this function:

◆ read()

unsigned int Kwave::Stripe::MappedArray::read ( Kwave::SampleArray buffer,
unsigned int  dstoff,
unsigned int  offset,
unsigned int  length 
)

Read a portion of samples into an array of samples.

Parameters
bufferarray for samples to be read (destination)
dstoffoffset within the destination buffer
offsetthe offset within the stripe (source)
lengthnumber of samples to read
Returns
length if succeeded or zero if the mapping has failed
Warning
this method is intended to be used only internally and lacks any error-checking in order to be fast!

Definition at line 71 of file Stripe.cpp.

References Kwave::Stripe::length(), m_length, m_storage, and MEMCPY.

73 {
74 // qDebug(" Stripe::MappedArray::read(..., %u, %u, %u)", dstoff,
75 // offset, length);
76  if (!m_length) return 0;
77 
78 #ifdef STRICTLY_QT
79  unsigned int cnt = length;
80  while (cnt--) {
81  buffer[dstoff++] = (*this)[offset++];
82  }
83 #else
84  sample_t *_samples = m_storage;
85  if (!_samples) return 0;
86  MEMCPY(&(buffer[dstoff]), &(_samples[offset]), length * sizeof(sample_t));
87 
88 #endif
89  return length;
90 }
unsigned int length() const
Definition: Stripe.cpp:276
unsigned int m_length
Definition: Stripe.h:295
#define MEMCPY
Definition: memcpy.h:37
qint32 sample_t
Definition: Sample.h:37
Here is the call graph for this function:

Member Data Documentation

◆ m_length

unsigned int Kwave::Stripe::MappedArray::m_length
private

length in samples

Definition at line 295 of file Stripe.h.

Referenced by copy(), MappedArray(), read(), and ~MappedArray().

◆ m_storage

sample_t* Kwave::Stripe::MappedArray::m_storage
private

pointer to the memory used for storage

Definition at line 292 of file Stripe.h.

Referenced by copy(), MappedArray(), read(), and ~MappedArray().

◆ m_stripe

Stripe& Kwave::Stripe::MappedArray::m_stripe
private

stripe which gets it's storage mapped

Definition at line 289 of file Stripe.h.

Referenced by MappedArray(), and ~MappedArray().


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