Queue 2.0
Queue handling library
Loading...
Searching...
No Matches
cppQueue.h
Go to the documentation of this file.
1
8/****************************************************************/
9#ifndef CPPQUEUE_H_
10 #define CPPQUEUE_H_
11
12#include <inttypes.h>
13#include <stddef.h>
14/****************************************************************/
15
16
20typedef enum enumcppQueueType {
21 FIFO = 0,
22 LIFO = 1
24
25
30{
31private:
32 cppQueueType impl;
33 bool ovw;
34 bool dynamic;
35 size_t queue_sz;
36 size_t rec_sz;
37 uint16_t rec_nb;
38 uint8_t * queue;
39
40 uint16_t in;
41 uint16_t out;
42 uint16_t cnt;
43 uint16_t init;
44
45 inline bool _isInitialized(void) __attribute__((always_inline));
46 inline bool _isEmpty(void) __attribute__((always_inline));
47 inline bool _isFull(void) __attribute__((always_inline));
48 inline uint16_t _getCount(void) __attribute__((always_inline));
49public:
59 cppQueue(const size_t size_rec, const uint16_t nb_recs=20, const cppQueueType type=FIFO, const bool overwrite=false, void * const pQDat=NULL, const size_t lenQDat=0);
60
64
67 void flush(void);
68
72 inline void clean(void) __attribute__((always_inline)) {
73 flush(); }
74
80 bool isInitialized(void);
81
87 bool isEmpty(void);
88
94 bool isFull(void);
95
100 uint32_t sizeOf(void);
101
105 uint16_t getCount(void);
106
111 inline uint16_t nbRecs(void) __attribute__((always_inline)) {
112 return getCount(); }
113
117 uint16_t getRemainingCount(void);
118
125 bool push(const void * const record) __attribute__((nonnull));
126
135 bool pop(void * const record) __attribute__((nonnull));
136
146 inline bool pull(void * const record) __attribute__((nonnull,always_inline)) {
147 return pop(record); }
148
158 bool peek(void * const record) __attribute__((nonnull));
159
168 bool drop(void);
169
180 bool peekIdx(void * const record, const uint16_t idx) __attribute__((nonnull));
181
191 bool peekPrevious(void * const record) __attribute__((nonnull));
192};
193
194
195/****************************************************************/
196#endif /* CPPQUEUE_H_ */
197/****************************************************************/
Class containing the required methods for handling the queue.
Definition cppQueue.h:30
uint32_t sizeOf(void)
get size of queue
bool always_inline
Definition cppQueue.h:146
bool isInitialized(void)
get initialization state of the queue
void clean(void) __attribute__((always_inline))
Clean queue, restarting from empty queue.
Definition cppQueue.h:72
bool peekIdx(void *const record, const uint16_t idx) __attribute__((nonnull))
Peek record at index from queue.
bool pop(void *const record) __attribute__((nonnull))
Pop record from queue.
uint16_t nbRecs(void) __attribute__((always_inline))
get number of records in the queue (same as getCount)
Definition cppQueue.h:111
bool isEmpty(void)
get emptiness state of the queue
cppQueue(const size_t size_rec, const uint16_t nb_recs=20, const cppQueueType type=FIFO, const bool overwrite=false, void *const pQDat=NULL, const size_t lenQDat=0)
cppQueue constructor
bool pull(void *const record) __attribute__((nonnull
Pull record from queue (same as pop)
bool isFull(void)
get fullness state of the queue
uint16_t getRemainingCount(void)
get number of records left in the queue
bool drop(void)
Drop current record from queue.
void flush(void)
Flush queue, restarting from empty queue.
bool peekPrevious(void *const record) __attribute__((nonnull))
Peek previous record from queue.
~cppQueue()
cppQueue destructor: release dynamically allocated queue
uint16_t getCount(void)
get number of records in the queue
bool push(const void *const record) __attribute__((nonnull))
Push record to queue.
bool peek(void *const record) __attribute__((nonnull))
Peek record from queue.
enumcppQueueType
cppQueue behavior enumeration (FIFO, LIFO)
Definition cppQueue.h:20
@ FIFO
First In First Out behavior.
Definition cppQueue.h:21
@ LIFO
Last In First Out behavior.
Definition cppQueue.h:22
enum enumcppQueueType cppQueueType