diff options
author | Sven Gothel <[email protected]> | 2020-05-04 15:33:27 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-05-04 15:33:27 +0200 |
commit | 9bf8ebba47bd6715dfa1d9d8ddbf959ebf7d259b (patch) | |
tree | 445b8c5b69a4a98eb1878f1f7695e6820b735079 /java/jni/JNIMem.hpp | |
parent | 72f865fe2a1371944d10a1c3fee1fd1a9b54c5cd (diff) |
JNIGlobalRef: Add copy-ctor, move-ctor and equality operations
Goal is to utilize JNIGlobalRef as a first class shared jobject instance
without the need to use std::shared_ptr<JNIGlobalRef>.
+++
Efficiency and functionality: Add copy-ctor, move-ctor
- Allow a JNIGlobalRef to be shared by creating copies
with a 'NewGlobalRef(..)'.
- Allow JNIGlobalRef to be moved by 'nulling' the source jobject
+++
Functionality: Add equality operations
- test inner jobject via 'IsSameObject(..)'
Diffstat (limited to 'java/jni/JNIMem.hpp')
-rw-r--r-- | java/jni/JNIMem.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/java/jni/JNIMem.hpp b/java/jni/JNIMem.hpp index a133bd9..b7f5323 100644 --- a/java/jni/JNIMem.hpp +++ b/java/jni/JNIMem.hpp @@ -84,6 +84,12 @@ public: /* Creates a GlobalRef from an object passed to it */ JNIGlobalRef(jobject object); + JNIGlobalRef(const JNIGlobalRef &o); + JNIGlobalRef(JNIGlobalRef &&o); + + JNIGlobalRef& operator=(const JNIGlobalRef &o); + JNIGlobalRef& operator=(JNIGlobalRef &&o); + /* Deletes the stored GlobalRef */ ~JNIGlobalRef(); @@ -94,6 +100,11 @@ public: jobject getObject() const { return object; } /* Provides access to the stored GlobalRef as a jclass. */ jclass getClass() const { return (jclass)object; } + + bool operator==(const JNIGlobalRef& rhs) const; + + bool operator!=(const JNIGlobalRef& rhs) const + { return !( *this == rhs ); } }; #endif /* JNIMEM__HPP_ */ |