8 #ifndef META_OCEAN_PLATFORM_ANDROID_SCOPED_JNI_OBJECT_H
9 #define META_OCEAN_PLATFORM_ANDROID_SCOPED_JNI_OBJECT_H
24 template <
typename T>
class ScopedJNIObject;
127 inline operator T()
const;
147 explicit inline operator bool()
const;
183 template <
typename T>
186 *
this = std::move(
object);
189 template <
typename T>
191 jniEnvironment_(scopedJNIEnvironment.jniEnv()),
197 template <
typename T>
199 jniEnvironment_(&jniEnvironment),
205 template <
typename T>
211 template <
typename T>
214 ocean_assert(isValid());
216 if (globalObject_ ==
nullptr)
218 globalObject_ = T(jniEnvironment_->NewGlobalRef(object_));
222 template <
typename T>
225 if (globalObject_ !=
nullptr)
227 ocean_assert(jniEnvironment_ !=
nullptr);
228 jniEnvironment_->DeleteGlobalRef(globalObject_);
229 globalObject_ =
nullptr;
234 ocean_assert(jniEnvironment_ !=
nullptr);
235 jniEnvironment_->DeleteLocalRef(object_);
240 template <
typename T>
243 return object_ !=
nullptr;
246 template <
typename T>
249 return globalObject_ !=
nullptr;
252 template <
typename T>
255 if (globalObject_ !=
nullptr)
257 ocean_assert(object_ !=
nullptr);
258 return globalObject_;
264 template <
typename T>
270 template <
typename T>
273 ocean_assert(isValid());
278 template <
typename T>
281 ocean_assert(isValid());
286 template <
typename T>
292 template <
typename T>
299 jniEnvironment_ =
object.jniEnvironment_;
300 object_ = std::move(
object.object_);
301 globalObject_ = std::move(
object.globalObject_);
303 object.jniEnvironment_ =
nullptr;
304 object.object_ = T();
305 object.globalObject_ = T();
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15