Skip to content

Commit 1437aa3

Browse files
committed
v2.1 (minor update):
- Internal functions name refactoring - Unused tags removal - always_inline attribute removal for index manipulation functions - c-cast updated to cpp static_cast - Legacy standard library headers replaced by their cpp equivalents
1 parent 2c6da8c commit 1437aa3

File tree

7 files changed

+59
-52
lines changed

7 files changed

+59
-52
lines changed

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = Queue
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = 2.0
51+
PROJECT_NUMBER = 2.1
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

Doxyfile.auto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = Queue
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = 2.0
51+
PROJECT_NUMBER = 2.1
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2017-2025, SMFSW
3+
Copyright (c) 2017-2026, SMFSW
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

ReleaseNotes.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Queue handling library (designed on Arduino)
2-
2017-2025 SMFSW
2+
2017-2026 SMFSW
33

44
Feel free to share your thoughts @ [email protected] about:
55
- issues encountered
@@ -10,6 +10,13 @@ Feel free to share your thoughts @ [email protected] about:
1010

1111
** Actual:
1212

13+
v2.1: 02 Jan 2026:
14+
- Internal functions name refactoring
15+
- Unused tags removal
16+
- always_inline attribute removal for index manipulation functions
17+
- c-cast updated to cpp static_cast
18+
- Legacy standard library headers replaced by their cpp equivalents
19+
1320
v2.0: 15 Apr 2024:
1421
- No more inlines in header file (to generate proper static library)
1522
- MISRA refactoring

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Queue
2-
version=2.0
2+
version=2.1
33
author=SMFSW <[email protected]>
44
maintainer=SMFSW <[email protected]>
55
sentence=Queue handling library.

src/cppQueue.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*!\file cppQueue.cpp
22
** \author SMFSW
3-
** \copyright BSD 3-Clause License (c) 2017-2025, SMFSW
3+
** \copyright BSD 3-Clause License (c) 2017-2026, SMFSW
44
** \brief cppQueue handling library (designed on Arduino)
55
** \details cppQueue handling library (designed on Arduino)
66
** This library was designed for Arduino, yet may be compiled without change with gcc for other purposes/targets
77
**/
88
/****************************************************************/
9-
#include <string.h>
10-
#include <stdlib.h>
9+
#include <cstring>
10+
#include <cstdlib>
1111

1212
#include "cppQueue.h"
1313
/****************************************************************/
@@ -25,7 +25,7 @@
2525
** \param [in] end - counter upper limit value
2626
** \param [in] start - counter lower limit value
2727
**/
28-
static inline void __attribute__((nonnull, always_inline)) _inc_idx(uint16_t * const pIdx, const uint16_t end, const uint16_t start)
28+
static inline void __attribute__((nonnull)) cppq_inc_idx(uint16_t * const pIdx, const uint16_t end, const uint16_t start)
2929
{
3030
if (*pIdx < (end - 1U)) { (*pIdx)++; }
3131
else { *pIdx = start; }
@@ -37,7 +37,7 @@ static inline void __attribute__((nonnull, always_inline)) _inc_idx(uint16_t * c
3737
** \param [in] end - counter upper limit value
3838
** \param [in] start - counter lower limit value
3939
**/
40-
static inline void __attribute__((nonnull, always_inline)) _dec_idx(uint16_t * const pIdx, const uint16_t end, const uint16_t start)
40+
static inline void __attribute__((nonnull)) cppq_dec_idx(uint16_t * const pIdx, const uint16_t end, const uint16_t start)
4141
{
4242
if (*pIdx > start) { (*pIdx)--; }
4343
else { *pIdx = end - 1U; }
@@ -49,30 +49,30 @@ static inline void __attribute__((nonnull, always_inline)) _dec_idx(uint16_t * c
4949
** \retval true if queue is allocated
5050
** \retval false is queue is not allocated
5151
**/
52-
inline bool __attribute__((always_inline)) cppQueue::_isInitialized(void) {
53-
return (init == QUEUE_INITIALIZED) ? true : false; }
52+
inline const bool __attribute__((always_inline)) cppQueue::_isInitialized(void) {
53+
return (init == QUEUE_INITIALIZED); }
5454

5555
/*! \brief get emptiness state of the queue
5656
** \return cppQueue emptiness status
5757
** \retval true if queue is empty
5858
** \retval false is not empty
5959
**/
60-
inline bool __attribute__((always_inline)) cppQueue::_isEmpty(void) {
61-
return (cnt == 0U) ? true : false; }
60+
inline const bool __attribute__((always_inline)) cppQueue::_isEmpty(void) {
61+
return (cnt == 0U); }
6262

6363
/*! \brief get fullness state of the queue
6464
** \return cppQueue fullness status
6565
** \retval true if queue is full
6666
** \retval false is not full
6767
**/
68-
inline bool __attribute__((always_inline)) cppQueue::_isFull(void) {
69-
return (cnt == rec_nb) ? true : false; }
68+
inline const bool __attribute__((always_inline)) cppQueue::_isFull(void) {
69+
return (cnt == rec_nb); }
7070

7171

7272
/*! \brief get number of records in the queue
7373
** \return Number of records stored in the queue
7474
**/
75-
inline uint16_t __attribute__((always_inline)) cppQueue::_getCount(void) {
75+
inline const uint16_t __attribute__((always_inline)) cppQueue::_getCount(void) {
7676
return cnt; }
7777

7878

@@ -82,16 +82,16 @@ inline uint16_t __attribute__((always_inline)) cppQueue::_getCount(void) {
8282
cppQueue::cppQueue(const size_t size_rec, const uint16_t nb_recs, const cppQueueType type, const bool overwrite, void * const pQDat, const size_t lenQDat)
8383
{
8484
init = 0;
85-
rec_nb = 0; // rec_nb needs to be 0 to ensure proper push behavior when queue is not allocated
86-
ovw = 0; // ovw needs to be 0 to ensure proper push behavior when queue is not allocated
87-
flush(); // other variables needs to be 0 to ensure proper functions behavior when queue is not allocated
85+
rec_nb = 0; // rec_nb needs to be 0 to ensure proper push behavior when queue is not allocated
86+
ovw = false; // ovw needs to be false to ensure proper push behavior when queue is not allocated
87+
flush(); // other variables needs to be 0 to ensure proper functions behavior when queue is not allocated
8888

8989
const size_t size = nb_recs * size_rec;
9090

91-
dynamic = (pQDat == NULL) ? true : false;
91+
dynamic = (pQDat == NULL);
9292

93-
if (dynamic) { queue = (uint8_t *) malloc(size); }
94-
else if (lenQDat >= size) { queue = (uint8_t *) pQDat; }
93+
if (dynamic) { queue = static_cast<uint8_t *>(malloc(size)); }
94+
else if (lenQDat >= size) { queue = static_cast<uint8_t *>(pQDat); }
9595
else { queue = NULL; }
9696

9797
if (queue != NULL)
@@ -130,7 +130,7 @@ bool __attribute__((nonnull)) cppQueue::push(const void * const record)
130130
{
131131
if (impl == FIFO)
132132
{
133-
_inc_idx(&out, rec_nb, 0); // as oldest record is overwritten, increment out
133+
cppq_inc_idx(&out, rec_nb, 0); // as oldest record is overwritten, increment out
134134
}
135135
//else if (impl == LIFO) {} // Nothing to do in this case
136136
}
@@ -148,7 +148,7 @@ bool __attribute__((nonnull)) cppQueue::push(const void * const record)
148148
{
149149
uint8_t * const pStart = queue + (rec_sz * in);
150150
memcpy(pStart, record, rec_sz);
151-
_inc_idx(&in, rec_nb, 0);
151+
cppq_inc_idx(&in, rec_nb, 0);
152152
}
153153

154154
return ret;
@@ -169,11 +169,11 @@ bool __attribute__((nonnull)) cppQueue::pop(void * const record)
169169
if (impl == FIFO)
170170
{
171171
pStart = queue + (rec_sz * out);
172-
_inc_idx(&out, rec_nb, 0);
172+
cppq_inc_idx(&out, rec_nb, 0);
173173
}
174174
else /* if (impl == LIFO) */
175175
{
176-
_dec_idx(&in, rec_nb, 0);
176+
cppq_dec_idx(&in, rec_nb, 0);
177177
pStart = queue + (rec_sz * in);
178178
}
179179

@@ -205,7 +205,7 @@ bool __attribute__((nonnull)) cppQueue::peek(void * const record)
205205
else /*if (impl == LIFO)*/
206206
{
207207
uint16_t rec = in; // Temporary var for peek (no change on in with dec_idx)
208-
_dec_idx(&rec, rec_nb, 0);
208+
cppq_dec_idx(&rec, rec_nb, 0);
209209
pStart = queue + (rec_sz * rec);
210210
}
211211

@@ -228,11 +228,11 @@ bool cppQueue::drop(void)
228228
{
229229
if (impl == FIFO)
230230
{
231-
_inc_idx(&out, rec_nb, 0);
231+
cppq_inc_idx(&out, rec_nb, 0);
232232
}
233233
else /*if (impl == LIFO)*/
234234
{
235-
_dec_idx(&in, rec_nb, 0);
235+
cppq_dec_idx(&in, rec_nb, 0);
236236
}
237237

238238
cnt--; // Decrease records count
@@ -280,21 +280,21 @@ bool __attribute__((nonnull)) cppQueue::peekPrevious(void * const record)
280280
/**********************/
281281
/*** PUBLIC GETTERS ***/
282282
/**********************/
283-
bool cppQueue::isInitialized(void) {
283+
const bool cppQueue::isInitialized(void) {
284284
return _isInitialized(); }
285285

286-
bool cppQueue::isEmpty(void) {
286+
const bool cppQueue::isEmpty(void) {
287287
return _isEmpty(); }
288288

289-
bool cppQueue::isFull(void) {
289+
const bool cppQueue::isFull(void) {
290290
return _isFull(); }
291291

292-
uint32_t cppQueue::sizeOf(void) {
292+
const uint32_t cppQueue::sizeOf(void) {
293293
return queue_sz; }
294294

295-
uint16_t cppQueue::getCount(void) {
295+
const uint16_t cppQueue::getCount(void) {
296296
return _getCount(); }
297297

298-
uint16_t cppQueue::getRemainingCount(void) {
298+
const uint16_t cppQueue::getRemainingCount(void) {
299299
return rec_nb - cnt; }
300300

src/cppQueue.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!\file cppQueue.h
22
** \author SMFSW
3-
** \copyright BSD 3-Clause License (c) 2017-2025, SMFSW
3+
** \copyright BSD 3-Clause License (c) 2017-2026, SMFSW
44
** \brief cppQueue handling library (designed on Arduino)
55
** \details cppQueue handling library (designed on Arduino)
66
** This library was designed for Arduino, yet may be compiled without change with gcc for other purposes/targets
@@ -9,15 +9,15 @@
99
#ifndef CPPQUEUE_H_
1010
#define CPPQUEUE_H_
1111

12-
#include <inttypes.h>
13-
#include <stddef.h>
12+
#include <cinttypes>
13+
#include <cstddef>
1414
/****************************************************************/
1515

1616

17-
/*!\enum enumcppQueueType
17+
/*!\enum cppQueueType
1818
** \brief cppQueue behavior enumeration (FIFO, LIFO)
1919
**/
20-
typedef enum enumcppQueueType {
20+
typedef enum {
2121
FIFO = 0, //!< First In First Out behavior
2222
LIFO = 1 //!< Last In First Out behavior
2323
} cppQueueType;
@@ -42,10 +42,10 @@ class cppQueue
4242
uint16_t cnt; //!< number of records not retrieved from the queue
4343
uint16_t init; //!< set to QUEUE_INITIALIZED after successful init of the queue, 0 otherwise
4444

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));
45+
inline const bool _isInitialized(void) __attribute__((always_inline));
46+
inline const bool _isEmpty(void) __attribute__((always_inline));
47+
inline const bool _isFull(void) __attribute__((always_inline));
48+
inline const uint16_t _getCount(void) __attribute__((always_inline));
4949
public:
5050
/*! \brief cppQueue constructor
5151
** \param [in] size_rec - size of a record in the queue
@@ -77,44 +77,44 @@ class cppQueue
7777
** \retval true if queue is allocated
7878
** \retval false is queue is not allocated
7979
**/
80-
bool isInitialized(void);
80+
const bool isInitialized(void);
8181

8282
/*! \brief get emptiness state of the queue
8383
** \return cppQueue emptiness status
8484
** \retval true if queue is empty
8585
** \retval false is not empty
8686
**/
87-
bool isEmpty(void);
87+
const bool isEmpty(void);
8888

8989
/*! \brief get fullness state of the queue
9090
** \return cppQueue fullness status
9191
** \retval true if queue is full
9292
** \retval false is not full
9393
**/
94-
bool isFull(void);
94+
const bool isFull(void);
9595

9696
/*! \brief get size of queue
9797
** \remark Size in bytes (like sizeof)
9898
** \return Size of queue in bytes
9999
**/
100-
uint32_t sizeOf(void);
100+
const uint32_t sizeOf(void);
101101

102102
/*! \brief get number of records in the queue
103103
** \return Number of records stored in the queue
104104
**/
105-
uint16_t getCount(void);
105+
const uint16_t getCount(void);
106106

107107
/*! \brief get number of records in the queue (same as getCount)
108108
** \deprecated nbRecs was already used in cppQueue lib, alias is made to keep compatibility with earlier versions
109109
** \return Number of records stored in the queue
110110
**/
111-
inline uint16_t nbRecs(void) __attribute__((always_inline)) {
111+
inline const uint16_t nbRecs(void) __attribute__((always_inline)) {
112112
return getCount(); }
113113

114114
/*! \brief get number of records left in the queue
115115
** \return Number of records left in the queue
116116
**/
117-
uint16_t getRemainingCount(void);
117+
const uint16_t getRemainingCount(void);
118118

119119
/*! \brief Push record to queue
120120
** \param [in] record - pointer to record to be pushed into queue

0 commit comments

Comments
 (0)