83 [[nodiscard]]
bool empty()
const;
95 return (_valid) ? (_bufSize - 1) : 0;
188void TFifoClass<T>::initialize()
195 memset(&_zero, 0,
sizeof(T));
211 _buffer =
new T[_bufSize];
212 memset(_buffer, 0,
sizeof(T) * _bufSize);
220 if ((((_tail + 1) % _bufSize)) == _head)
224 _buffer[_tail++] = item;
232 if (sizeRemain() < count)
236 for (size_type i = 0; i < count; push(item[i++]))
255 return _buffer[_head];
265 return _buffer[(((_tail + _bufSize - 1) % _bufSize))];
275 T tmp = _buffer[_head++];
288 item = _buffer[_head++];
302 return (_tail < _head) ? (_bufSize + (_tail - _head)) : (_tail - _head);
308 return _buffer[(pos + _head) % _bufSize];
314 return _buffer[(pos + _head) % _bufSize];
320 return &_buffer[pos];
Fifo template for classes and structure pointers.
Definition TFifoClass.h:14
size_type size() const
Returns current buffer contained data size.
size_type sizeMax() const
Returns maximum containable size.
Definition TFifoClass.h:93
bool isValid() const
Returns 1 if object is valid else 0.
Definition TFifoClass.h:109
bool empty() const
Returns if current contained buffer data size is zero.
const T & operator[](size_type pos) const
Const array operator offset from head of buffer.
size_type getHead() const
Access function for private member.
size_type sizeRemain() const
Returns remaining available size.
Definition TFifoClass.h:101
bool push(const T *item, size_type count)
Pushes multiple items if possible else it returns '0' and no items are inserted at all.
void clear()
Resets instance to the initial state.
Definition TFifoClass.h:125
T & operator[](size_type pos)
Array operator offset from head of buffer.
TFifoClass(size_type size)
Constructor that will setup the object immediately.
Definition TFifoClass.h:32
const T & latest() const
Gives latest item pushed into the fifo.
const T * getBuffer(size_type pos=0) const
Access function for private member.
TFifoClass()
Default constructor which needs Set() to validate object.
Definition TFifoClass.h:24
bool isFull() const
Returns '1' if object is full else 0.
Definition TFifoClass.h:117
bool push()
Push item of zero in fifo.
bool push(const T &item)
Pushes item into buffer.
int size_type
Definition TFifoClass.h:19
bool pop(T &item)
Same as pop(void) but returns 'false' when the buffer is empty.
T pop()
Read item at head of buffer and removes it.
const T & peek() const
Returns next item without removing it.
bool set(size_type size)
InitializeBase object after default construction or to increase size.
size_type getTail() const
Access function for private member.
Definition Application.h:10