Skip to content

Commit 12063dd

Browse files
author
camilo
committed
isInitialized() and operator bool() for most of the objects. Bump to 1.4.0
1 parent a802faf commit 12063dd

File tree

14 files changed

+145
-13
lines changed

14 files changed

+145
-13
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.3.9",
19+
"version": "1.4.0",
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=qlibs
2-
version=1.3.9
2+
version=1.4.0
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( qlibs-cpp
3-
VERSION 1.3.9
3+
VERSION 1.4.0
44
DESCRIPTION "A collection of useful C++ libraries for embedded systems"
55
LANGUAGES CXX )
66

src/include/bitfield.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,22 @@ namespace qlibs {
213213
*/
214214
void* dump( void * const dst,
215215
const size_t n ) noexcept;
216+
217+
/**
218+
* @brief Check if the bit-field instance has been initialized.
219+
* @return @c true if instance has been initialized
220+
*/
221+
bool isInitialized( void ) const {
222+
return ( nullptr != field );
223+
}
224+
225+
/**
226+
* @brief Check if the bit-field instance has been initialized.
227+
* @return @c true if instance has been initialized
228+
*/
229+
explicit operator bool() const noexcept {
230+
return isInitialized();
231+
}
216232
};
217233

218234
/** @}*/

src/include/fis.hpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,22 @@ namespace qlibs {
814814
*/
815815
bool setRuleWeights( real_t *rWeights ) noexcept;
816816

817+
/**
818+
* @brief Check if the FIS instance has been initialized.
819+
* @return @c true if instance has been initialized
820+
*/
821+
bool isInitialized( void ) const {
822+
return ( nullptr != xInput );
823+
}
824+
825+
/**
826+
* @brief Check if the FIS instance has been initialized.
827+
* @return @c true if instance has been initialized
828+
*/
829+
explicit operator bool() const noexcept {
830+
return isInitialized();
831+
}
832+
817833
/**
818834
* @brief Get the number of points used on Mamdani to perform the
819835
* de-fuzzification proccess
@@ -1207,6 +1223,23 @@ namespace qlibs {
12071223
}
12081224
return *this;
12091225
}
1226+
1227+
/**
1228+
* @brief Check if the FIS system has been initialized.
1229+
* @return @c true if instance has been initialized
1230+
*/
1231+
bool isInitialized( void ) const {
1232+
return sys.isInitialized();
1233+
}
1234+
1235+
/**
1236+
* @brief Check if the FIS system has been initialized.
1237+
* @return @c true if instance has been initialized
1238+
*/
1239+
explicit operator bool() const noexcept {
1240+
return sys.isInitialized();
1241+
}
1242+
12101243
};
12111244
/** @}*/
12121245
}

src/include/ltisys.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,16 @@ namespace qlibs {
373373
*/
374374
virtual bool isInitialized( void ) const = 0;
375375

376+
377+
/**
378+
* @brief Check if the LTI system is initialized.
379+
* @return @c true if the system has been initialized, otherwise
380+
* return @c false.
381+
*/
382+
explicit operator bool() const noexcept {
383+
return isInitialized();
384+
}
385+
376386
/**
377387
* @brief Set the initial states for the given system
378388
* @pre System should be previously initialized by using the @c setup() method
@@ -577,6 +587,15 @@ namespace qlibs {
577587
return ( nullptr != xd ) && ( LTISYS_TYPE_DISCRETE == type );
578588
}
579589

590+
/**
591+
* @brief Check if the LTI discrete system is initialized.
592+
* @return @c true if the system has been initialized, otherwise
593+
* return @c false.
594+
*/
595+
explicit operator bool() const noexcept {
596+
return isInitialized();
597+
}
598+
580599
/**
581600
* @brief Set the initial states for the discrete system
582601
* @pre System should be previously initialized by using the

src/include/numa.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ namespace qlibs {
258258
* @note This should be called at intervals equal to the time step provided in the constructor.
259259
*/
260260
real_t operator()( const real_t xDot );
261+
262+
/**
263+
* @brief Retrieve the current value of the integration
264+
* @return The current value of the integral.
265+
*/
266+
real_t operator()() const;
261267
};
262268

263269
/**

src/include/pid.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,15 @@ namespace qlibs {
449449
{
450450
return { Kc, Ki, Kd };
451451
}
452+
453+
/**
454+
* @brief Check if the PID instance has been initialized using setup().
455+
* @return @c true if the PID instance has been initialized, otherwise
456+
* return @c false.
457+
*/
458+
explicit operator bool() const noexcept {
459+
return isInitialized;
460+
}
452461
};
453462

454463
/** @}*/

src/include/rms.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ namespace qlibs {
6868
return setup( win, windowSize );
6969
}
7070

71+
/**
72+
* @brief Check if the RMS instance has been initialized using setup().
73+
* @return @c true if the RMS instance has been initialized, otherwise
74+
* return @c false.
75+
*/
76+
explicit operator bool() const noexcept {
77+
return smootherLPF1::isInitialized(); // controls truthiness
78+
}
79+
7180
/**
7281
* @brief Change the recursive parameters for the moving RMS estimator.
7382
* @param[in] l Exponential weighting factor, specified as a positive

src/include/smoother.hpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace qlibs {
2828
protected:
2929
/*! @cond */
3030
bool init{ true };
31+
bool isSetup{ false };
3132
static void windowSet( real_t *w,
3233
const size_t wsize,
3334
const real_t x );
@@ -36,11 +37,24 @@ namespace qlibs {
3637
virtual ~smoother() {}
3738

3839
/**
39-
* @brief Check if the smoother filter is initialized.
40+
* @brief Check if the smoother filter has been initialized using setup().
4041
* @return @c true if the smoother has been initialized, otherwise
4142
* return @c false.
4243
*/
43-
bool isInitialized( void ) const;
44+
bool isInitialized( void ) const
45+
{
46+
return isSetup;
47+
}
48+
49+
/**
50+
* @brief Check if the smoother filter has been initialized using setup().
51+
* @return @c true if the smoother has been initialized, otherwise
52+
* return @c false.
53+
*/
54+
explicit operator bool() const noexcept
55+
{
56+
return isInitialized();
57+
}
4458

4559
/**
4660
* @brief Perform the smooth operation recursively for the input signal @a x.

0 commit comments

Comments
 (0)