SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Private Attributes | List of all members
DoubleBufferSimple< T > Class Template Reference

#include <doublebuffer.h>

Public Member Functions

 DoubleBufferSimple ()
 
 ~DoubleBufferSimple ()
 
 DoubleBufferSimple (const DoubleBufferSimple &other)
 
DoubleBufferSimpleoperator= (const DoubleBufferSimple &other)
 
void resize (int size)
 
void write (const typename std::vector< T >::const_iterator &begin, const typename std::vector< T >::const_iterator &cend)
 
std::vector< T >::iterator getCurrent () const
 
std::vector< T >::const_iterator begin () const
 
std::vector< T >::iterator begin ()
 
unsigned int absoluteFill () const
 
void reset ()
 
QByteArray serialize () const
 
bool deserialize (const QByteArray &data)
 

Private Attributes

int m_size
 
std::vector< T > m_data
 
std::vector< T >::iterator m_current
 

Detailed Description

template<typename T>
class DoubleBufferSimple< T >

Definition at line 29 of file doublebuffer.h.

Constructor & Destructor Documentation

◆ DoubleBufferSimple() [1/2]

template<typename T>
DoubleBufferSimple< T >::DoubleBufferSimple ( )
inline

Definition at line 32 of file doublebuffer.h.

33  {
34  m_size = 0;
35  m_current = m_data.end();
36  }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144

◆ ~DoubleBufferSimple()

template<typename T>
DoubleBufferSimple< T >::~DoubleBufferSimple ( )
inline

Definition at line 38 of file doublebuffer.h.

38 {}

◆ DoubleBufferSimple() [2/2]

template<typename T>
DoubleBufferSimple< T >::DoubleBufferSimple ( const DoubleBufferSimple< T > &  other)
inline

Definition at line 40 of file doublebuffer.h.

41  {
42  m_size = other.m_size;
43  m_data = other.m_data;
44  m_current = m_data.begin();
45  }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144

Member Function Documentation

◆ absoluteFill()

template<typename T>
unsigned int DoubleBufferSimple< T >::absoluteFill ( ) const
inline

Definition at line 96 of file doublebuffer.h.

Referenced by ScopeVis::TraceBackBuffer::absoluteFill().

96 { return m_current - m_data.begin(); }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144
+ Here is the caller graph for this function:

◆ begin() [1/2]

template<typename T>
std::vector<T>::const_iterator DoubleBufferSimple< T >::begin ( ) const
inline

Definition at line 94 of file doublebuffer.h.

Referenced by ScopeVis::TraceBackBuffer::deserialize(), ScopeVis::TraceBackBuffer::serialize(), and DoubleBufferSimple< Sample >::write().

94 { return m_data.begin(); }
std::vector< T > m_data
Definition: doublebuffer.h:143
+ Here is the caller graph for this function:

◆ begin() [2/2]

template<typename T>
std::vector<T>::iterator DoubleBufferSimple< T >::begin ( )
inline

Definition at line 95 of file doublebuffer.h.

95 { return m_data.begin(); }
std::vector< T > m_data
Definition: doublebuffer.h:143

◆ deserialize()

template<typename T>
bool DoubleBufferSimple< T >::deserialize ( const QByteArray &  data)
inline

Definition at line 111 of file doublebuffer.h.

Referenced by ScopeVis::TraceBackBuffer::deserialize().

112  {
113  SimpleDeserializer d(data);
114 
115  if(!d.isValid()) {
116  return false;
117  }
118 
119  if (d.getVersion() == 1)
120  {
121  unsigned int tmpUInt;
122  QByteArray buf;
123 
124  d.readS32(1, &m_size, m_data.size()/2);
125  m_data.resize(2*m_size);
126  d.readU32(2, &tmpUInt, 0);
127  m_current = m_data.begin() + tmpUInt;
128  d.readBlob(3, &buf);
129  //qDebug("DoubleBufferSimple::deserialize: m_data.size(): %u buf.size(): %d", m_data.size(), buf.size());
130  //std::copy(reinterpret_cast<char *>(m_data.data()), buf.data(), buf.data() + buf.size()); // bug
131  memcpy(reinterpret_cast<char *>(m_data.data()), buf.data(), buf.size());
132 
133  return true;
134  }
135  else
136  {
137  return false;
138  }
139  }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144
+ Here is the caller graph for this function:

◆ getCurrent()

template<typename T>
std::vector<T>::iterator DoubleBufferSimple< T >::getCurrent ( ) const
inline

Definition at line 93 of file doublebuffer.h.

Referenced by ScopeVis::TraceBackBuffer::current(), and ScopeVis::TraceBackBuffer::TraceBackBuffer().

93 { return m_current + m_size; }
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144
+ Here is the caller graph for this function:

◆ operator=()

template<typename T>
DoubleBufferSimple& DoubleBufferSimple< T >::operator= ( const DoubleBufferSimple< T > &  other)
inline

Definition at line 47 of file doublebuffer.h.

48  {
49  if (&other == this) {
50  return *this;
51  }
52 
53  m_size = other.m_size;
54  m_data = other.m_data;
55  m_current = m_data.begin();
56  return *this;
57  }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144

◆ reset()

template<typename T>
void DoubleBufferSimple< T >::reset ( )
inline

Definition at line 97 of file doublebuffer.h.

Referenced by ScopeVis::TraceBackBuffer::reset().

97 { m_current = m_data.begin(); }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144
+ Here is the caller graph for this function:

◆ resize()

template<typename T>
void DoubleBufferSimple< T >::resize ( int  size)
inline

Definition at line 59 of file doublebuffer.h.

Referenced by ScopeVis::TraceBackBuffer::resize().

60  {
61  m_size = size;
62  m_data.resize(2*size);
63  m_current = m_data.begin();
64  }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144
+ Here is the caller graph for this function:

◆ serialize()

template<typename T>
QByteArray DoubleBufferSimple< T >::serialize ( ) const
inline

Definition at line 99 of file doublebuffer.h.

Referenced by ScopeVis::TraceBackBuffer::serialize().

100  {
101  SimpleSerializer s(1);
102 
103  QByteArray buf(reinterpret_cast<const char*>(m_data.data()), m_data.size()*sizeof(T));
104  s.writeS32(1, m_size);
105  s.writeU32(2, m_current - m_data.begin());
106  s.writeBlob(3, buf);
107 
108  return s.final();
109  }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144
+ Here is the caller graph for this function:

◆ write()

template<typename T>
void DoubleBufferSimple< T >::write ( const typename std::vector< T >::const_iterator &  begin,
const typename std::vector< T >::const_iterator &  cend 
)
inline

Definition at line 66 of file doublebuffer.h.

Referenced by ScopeVis::TraceBackBuffer::write().

67  {
68  typename std::vector<T>::const_iterator end = cend;
69 
70  if ((end - begin) > m_size)
71  {
72  end = begin + m_size;
73  }
74 
75  int insize = end - begin;
76 
77  std::copy(begin, end, m_current);
78 
79  if (((m_current - m_data.begin()) + insize) > m_size)
80  {
81  int sizeLeft = m_size - (m_current - m_data.begin());
82  std::copy(begin, begin + sizeLeft, m_current + m_size);
83  std::copy(begin + sizeLeft, end, m_data.begin());
84  m_current = m_data.begin() + (insize - sizeLeft);
85  }
86  else
87  {
88  std::copy(begin, end, m_current + m_size);
89  m_current += insize;
90  }
91  }
std::vector< T > m_data
Definition: doublebuffer.h:143
std::vector< T >::const_iterator begin() const
Definition: doublebuffer.h:94
std::vector< T >::iterator m_current
Definition: doublebuffer.h:144
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_current

template<typename T>
std::vector<T>::iterator DoubleBufferSimple< T >::m_current
private

◆ m_data

template<typename T>
std::vector<T> DoubleBufferSimple< T >::m_data
private

◆ m_size

template<typename T>
int DoubleBufferSimple< T >::m_size
private

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