aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-11-29 16:11:44 +0100
committerSven Gothel <[email protected]>2021-11-29 16:11:44 +0100
commit42e514f2a0e32263a4eea9634506f9ab32e62a1e (patch)
treed1ed6c060553a8ec6cc564e2e56666ed47dbb6cb /api
parente03c318f9947d3d148309f1bdc961c0ba1fa6f4c (diff)
Add BTObject::checkValid() implementation overriding jau:JavaUplink, to actually validate whether instance is still valid.
Used in `T* jau::getJavaUplinkObject(JNIEnv *env, jobject obj)`
Diffstat (limited to 'api')
-rw-r--r--api/direct_bt/BTTypes1.hpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/api/direct_bt/BTTypes1.hpp b/api/direct_bt/BTTypes1.hpp
index da2821b1..015902a2 100644
--- a/api/direct_bt/BTTypes1.hpp
+++ b/api/direct_bt/BTTypes1.hpp
@@ -62,6 +62,12 @@ namespace direct_bt {
* Returns whether the object's reference is valid and in a general operational state.
*/
inline bool isValid() const noexcept { return valid.load(); }
+
+ inline void checkValid() const override {
+ if( !isValid() ) {
+ throw jau::IllegalStateException("BTObject::checkValid: Invalid object: "+toString(), E_FILE_LINE);
+ }
+ }
};
inline std::string to_string(const BTObject& o) noexcept { return o.toString(); }