semf
lastindmabuffer.h
Go to the documentation of this file.
1
10#ifndef SEMF_UTILS_CORE_BUFFER_LASTINDMABUFFER_H_
11#define SEMF_UTILS_CORE_BUFFER_LASTINDMABUFFER_H_
12
14
15namespace semf
16{
37template <typename T>
39{
40public:
41 using LastInBuffer<T>::LastInBuffer;
42
47 virtual void put(T data);
53 virtual T& operator[](size_t pos) const;
59 void setStride(size_t stride);
64 size_t size() const;
70 size_t count() const override;
71
72private:
74 size_t m_stride = 0;
75};
76
77template <typename T>
79{
82 LastInBuffer<T>::setPos(this->pos() + m_stride - 1);
84}
85
86template <typename T>
88{
89 return LastInBuffer<T>::operator[]((pos + 1) * (m_stride)-1);
90}
91
92template <typename T>
94{
95 m_stride = stride;
96}
97
98template <typename T>
100{
101 return LastInBuffer<T>::size() / (m_stride);
102}
103
104template <typename T>
106{
107 return size();
108}
109} /* namespace semf */
110#endif /* SEMF_UTILS_CORE_BUFFER_LASTINDMABUFFER_H_ */
T * data() const
Returns the pointer to the first element of the data array.
Definition: buffer.h:139
size_t size() const
Returns the size of the buffer.
Definition: buffer.h:127
The LastInBuffer class implements a kind of circular buffer.
Definition: lastinbuffer.h:40
void setPos(size_t pos)
Sets the write position of the buffer.
Definition: lastinbuffer.h:109
size_t pos() const
Returns the current write position.
Definition: lastinbuffer.h:115
virtual void put(T data)
Writes data in the buffer.
Definition: lastinbuffer.h:78
virtual T & operator[](size_t pos) const
Returns the entry from a specific position in the buffer.
Definition: lastinbuffer.h:98
The LastInDmaBuffer class implements a kind of circular buffer.
virtual void put(T data)
Write data in the buffer.
virtual T & operator[](size_t pos) const
Returns the entry from a specific position in the buffer.
size_t size() const
Returns the size of the buffer.
size_t count() const override
Returns the number of entries stored in the buffer.
void setStride(size_t stride)
Set the stride between to entries of the same input.