Skip to content

Commit 0084445

Browse files
kmilo17petcamilo
andauthored
Added bool operator to some core objects. Fix task entries tracking at removal. Increase rev to 1.7.6 (#12)
Co-authored-by: camilo <[email protected]>
1 parent 6a23b60 commit 0084445

20 files changed

+153
-33
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"maintainer": true
1717
}
1818
],
19-
"version": "1.7.5",
19+
"version": "1.7.6",
2020
"license": "MIT",
2121
"frameworks": "arduino",
2222
"platforms": "*"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=QuarkTS
2-
version=1.7.5
2+
version=1.7.6
33
license=MIT
44
author=J. Camilo Gomez C. <[email protected]>
55
maintainer=J. Camilo Gomez C. <[email protected]>

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required( VERSION 3.2 )
22
project( quarkts-cpp
3-
VERSION 1.7.5
3+
VERSION 1.7.6
44
DESCRIPTION "An open-source OS for small embedded applications"
55
LANGUAGES CXX )
66

src/QuarkTS.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* @file QuarkTS.h
33
* @author J. Camilo Gomez C.
4-
* @version 1.7.5
4+
* @version 1.7.6
55
* @note This file is part of the QuarkTS++ distribution.
66
* @brief Global inclusion header
77
**/
@@ -41,8 +41,8 @@ This file is part of the QuarkTS++ OS distribution.
4141
#ifndef QOS_CPP_H
4242
#define QOS_CPP_H
4343

44-
#define QUARKTS_CPP_VERSION "1.7.5"
45-
#define QUARKTS_CPP_VERNUM ( 175u )
44+
#define QUARKTS_CPP_VERSION "1.7.6"
45+
#define QUARKTS_CPP_VERNUM ( 176u )
4646
#define QUARKTS_CPP_CAPTION "QuarkTS++ OS " QUARKTS_CPP_VERSION
4747

4848
#include "config/config.h"
@@ -66,7 +66,7 @@ This file is part of the QuarkTS++ OS distribution.
6666

6767
namespace qOS {
6868
namespace build {
69-
constexpr const uint32_t number = 4144;
69+
constexpr const uint32_t number = 4149;
7070
constexpr const char* date = __DATE__;
7171
constexpr const char* time = __TIME__;
7272
constexpr const char* std = "c++11";
@@ -76,7 +76,7 @@ namespace qOS {
7676
constexpr const uint8_t number = QUARKTS_CPP_VERNUM;
7777
constexpr const uint8_t mayor = 1U;
7878
constexpr const uint8_t minor = 7U;
79-
constexpr const uint8_t rev = 5U;
79+
constexpr const uint8_t rev = 6U;
8080
}
8181
namespace product {
8282
constexpr const char* author = "J. Camilo Gomez C.";

src/include/bytebuffer.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace qOS {
1414
/**
1515
* @brief A Byte-sized buffer object
1616
*/
17-
class byteBuffer {
17+
class byteBuffer : private nonCopyable {
1818
private:
1919
volatile byte_t *buffer{ nullptr };
2020
volatile index_t tail{ 0U };
@@ -96,6 +96,20 @@ namespace qOS {
9696
* @return Number of elements in the byte-sized Buffer.
9797
*/
9898
size_t count( void ) const noexcept;
99+
/**
100+
* @brief Check if the byteBuffer instance has been initialized.
101+
* @return @c true if instance has been initialized
102+
*/
103+
bool isInitialized( void ) const {
104+
return ( nullptr != buffer );
105+
}
106+
/**
107+
* @brief Check if the byteBuffer instance has been initialized.
108+
* @return @c true if instance has been initialized
109+
*/
110+
explicit operator bool() const noexcept {
111+
return isInitialized();
112+
}
99113
};
100114

101115
/** @}*/

src/include/cli.hpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ namespace qOS {
299299
/**
300300
* @brief An AT-Command object
301301
*/
302-
class command : protected node {
302+
class command : protected node, private nonCopyable {
303303
private:
304304
commandCallback_t cmdCallback{ nullptr };
305305
options_t cmdOpt{ 0U };
@@ -313,10 +313,21 @@ namespace qOS {
313313
/*! @cond */
314314
virtual ~command() {}
315315
/*! @endcond */
316+
/**
317+
* @brief Retrieve the command user-defined parameter.
318+
* @return @c A generic pointer to the user-defined parameter
319+
*/
316320
inline void* getParam( void ) noexcept
317321
{
318322
return param;
319323
}
324+
/**
325+
* @brief Check if the byteBuffer instance has been initialized.
326+
* @return @c true if instance has been initialized
327+
*/
328+
explicit operator bool() const noexcept {
329+
return ( nullptr != Text ) && ( nullptr != cmdCallback );
330+
}
320331
friend class qOS::commandLineInterface;
321332
};
322333
/** @}*/
@@ -330,7 +341,7 @@ namespace qOS {
330341
* The instance should be initialized using the commandLineInterface::setup()
331342
* method.
332343
*/
333-
class commandLineInterface : protected cli::input {
344+
class commandLineInterface : protected cli::input, private nonCopyable {
334345
private:
335346
list subscribed;
336347
cli::commandHandler handler;
@@ -462,6 +473,20 @@ namespace qOS {
462473
{
463474
handler.Data = pData;
464475
}
476+
/**
477+
* @brief Check if the CLI instance has been initialized.
478+
* @return @c true if instance has been initialized
479+
*/
480+
bool isInitialized( void ) const {
481+
return ( nullptr != cli::input::storage );
482+
}
483+
/**
484+
* @brief Check if the CLI instance has been initialized.
485+
* @return @c true if instance has been initialized
486+
*/
487+
explicit operator bool() const noexcept {
488+
return isInitialized();
489+
}
465490
friend class cli::commandHandler;
466491
friend class core;
467492
};

src/include/coroutine.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ namespace qOS {
7777
* @brief Try to execute co::setPosition() statement externally.
7878
*/
7979
void try_set( co::state p ) noexcept;
80+
/**
81+
* @brief Check if the Co-Routine handle is valid.
82+
* @return @c true if handle is valid
83+
*/
84+
explicit operator bool() const noexcept {
85+
return ( nullptr != ctx );
86+
}
8087
friend class co::coContext;
8188
};
8289

src/include/fsm.hpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ namespace qOS {
355355
#endif
356356

357357
/*! @cond */
358-
class stateHandler {
358+
class stateHandler : private nonCopyable {
359359
protected:
360360
state *StartState{ nullptr };
361361
state *NextState{ nullptr };
@@ -364,10 +364,8 @@ namespace qOS {
364364
historyMode TransitionHistory{ historyMode::NO_HISTORY };
365365
status Status{ SUCCESS };
366366
signalID Signal{ signalID::SIGNAL_NONE };
367-
stateHandler( stateHandler const& ) = delete; /* not copyable*/
368-
void operator=( stateHandler const& ) = delete; /* not assignable*/
369-
public:
370367
stateHandler() = default;
368+
public:
371369
virtual ~stateHandler() {}
372370
void *SignalData{ nullptr }; /**< The data with which the signal is associated*/
373371
void *Data{ nullptr }; /**< The user storage pointer. If the FSM its running as a task, this will point to the event_t structure*/
@@ -1032,6 +1030,20 @@ namespace qOS {
10321030
* @c false.
10331031
*/
10341032
bool run( sm::signal_t sig ) noexcept;
1033+
/**
1034+
* @brief Check if the state machine instance has been initialized.
1035+
* @return @c true if instance has been initialized
1036+
*/
1037+
bool isInitialized( void ) const {
1038+
return ( nullptr != top.initState );
1039+
}
1040+
/**
1041+
* @brief Check if the state machine instance has been initialized.
1042+
* @return @c true if instance has been initialized
1043+
*/
1044+
explicit operator bool() const noexcept {
1045+
return isInitialized();
1046+
}
10351047
friend class core;
10361048
};
10371049
/** @}*/

src/include/input.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ namespace qOS {
257257
* @param[in] inputChannel The specified channel(pin) number to read.
258258
* @param[in] invert To invert/negate the raw-reading.
259259
*/
260-
digitalChannel( const uint8_t inputChannel, bool invert = false ) : channel( inputChannel ), negate( invert) {}
260+
explicit digitalChannel( const uint8_t inputChannel, bool invert = false ) : channel( inputChannel ), negate( invert) {}
261261
/**
262262
* @brief Get the channel type.
263263
* @return The channel type.
@@ -453,7 +453,7 @@ namespace qOS {
453453
/**
454454
* @brief The digital input-channel watcher class.
455455
*/
456-
class watcher : protected node {
456+
class watcher : protected node, private nonCopyable {
457457
private:
458458
eventCallback_t exception{ nullptr };
459459
list digitalChannels;
@@ -462,8 +462,6 @@ namespace qOS {
462462
qOS::duration_t debounceTime{ 100_ms };
463463
digitalReaderFcn_t digitalReader{ nullptr };
464464
analogReaderFcn_t analogReader{ nullptr };
465-
watcher( watcher const& ) = delete;
466-
void operator=( watcher const& ) = delete;
467465
public:
468466
/*! @cond */
469467
virtual ~watcher() {}
@@ -473,7 +471,7 @@ namespace qOS {
473471
* @param[in] timeDebounce The specified time to bypass the
474472
* bounce of the digital input channels
475473
*/
476-
watcher( const qOS::duration_t dt = 100_ms ) : debounceTime( dt ) {}
474+
explicit watcher( const qOS::duration_t dt = 100_ms ) : debounceTime( dt ) {}
477475
/**
478476
* @brief Constructor for the input-watcher instance
479477
* @param[in] rDigital A pointer to a function that reads the specific

src/include/kernel.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace qOS {
8080
* @brief The class to interface the OS
8181
* @note Use the predefined os instance
8282
*/
83-
class core final : protected taskEvent {
83+
class core final : protected taskEvent, private nonCopyable {
8484
private:
8585
task idle;
8686
taskFcn_t releaseSchedCallback{ nullptr };
@@ -452,6 +452,13 @@ namespace qOS {
452452
* @return Returns @c true if success, otherwise returns @c false.
453453
*/
454454
bool remove( input::watcher &w ) noexcept;
455+
/**
456+
* @brief Check if the OS instance has been initialized.
457+
* @return @c true if OS instance has been initialized
458+
*/
459+
explicit operator bool() const noexcept {
460+
return ( 0U == idle.entry );
461+
}
455462
};
456463
/** @brief The predefined instance of the OS kernel interface */
457464
extern core& os; // skipcq: CXX-W2011, CXX-W2009

0 commit comments

Comments
 (0)