jaulib v1.3.0
Jau Support Library (C++, Java, ..)
|
A std::shared_ptr<T>
storage instance to be copied from and released into a java object's long nativeInstance
field.
More...
#include <helper_jni.hpp>
Public Member Functions | |
shared_ptr_ref () noexcept | |
Default constructor, nullptr. More... | |
shared_ptr_ref (const shared_ptr_ref &o) noexcept | |
Copy constructor. More... | |
shared_ptr_ref (const std::shared_ptr< T > &ref) noexcept | |
Constructs a new instance, copying the given std::shared_ptr<T>. More... | |
shared_ptr_ref (jlong nativeInstance, const bool throw_on_nullptr=true) | |
Constructs a new instance, copying the instance from the given java long nativeInstance value, representing a java object's shared_ptr<T> storage. More... | |
shared_ptr_ref (JNIEnv *env, jobject obj, const bool throw_on_nullptr=true) | |
Constructs a new instance, copying the instance from the java object's long nativeInstance field. More... | |
shared_ptr_ref (shared_ptr_ref &&o) noexcept | |
Move constructor. More... | |
shared_ptr_ref (std::shared_ptr< T > &&ref) noexcept | |
Constructs a new instance, moving the given std::shared_ptr<T>. More... | |
shared_ptr_ref (T *ptr) noexcept | |
Constructs a new instance, taking ownership of the given T pointer. More... | |
~shared_ptr_ref () | |
bool | is_null () const noexcept |
Returns true if either this instances shared_ptr<T> storage or the managed object reference is nullptr. More... | |
void | null_check1 () const |
Throws an exception if this instances shared_ptr<T> storage is nullptr. More... | |
void | null_check2 () const |
Throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr. More... | |
T & | operator* () |
Provides access to reference of stored T. More... | |
T * | operator-> () |
Provides access to pointer of stored T. More... | |
shared_ptr_ref & | operator= (const shared_ptr_ref &o) |
Assignment operator. More... | |
shared_ptr_ref & | operator= (const std::shared_ptr< T > &o) |
Assignment operator. More... | |
shared_ptr_ref & | operator= (shared_ptr_ref &&o) noexcept |
Move assignment operator. More... | |
std::shared_ptr< T > * | pointer () noexcept |
Provides access to the shared_ptr<T> pointer, l-value of storage. More... | |
std::shared_ptr< T > * | release () noexcept |
Release ownership and returns the shared_ptr<T> storage. More... | |
void | release_into_object (JNIEnv *env, jobject obj) |
Deletes the std::shared_ptr<T> storage of the target java object if exists first and writes this instance's std::shared_ptr<T> storage pointer into its long nativeInstance field, then releases ownership, see release_to_jlong(). More... | |
jlong | release_to_jlong () noexcept |
Release ownership and return the jlong representation of the shared_ptr<T> storage. More... | |
const std::shared_ptr< T > & | shared_ptr () const |
Provides access to const reference of shared_ptr<T>, r-value. More... | |
std::string | toString () const noexcept |
A std::shared_ptr<T>
storage instance to be copied from and released into a java object's long nativeInstance
field.
An instance holds a shared_ptr<T> storage pointer for a managed object T.
Using a shared_ptr<T>
copy increments its reference counter and prohibits its destruction while in use.
We prefer using std::shared_ptr<T>
instead of a naked pointer
, this way we automatically preserve the native instance lifecycle while within a JNI method.
T | the managed object type |
Definition at line 393 of file helper_jni.hpp.
|
inlinenoexcept |
Default constructor, nullptr.
Definition at line 424 of file helper_jni.hpp.
|
inlinenoexcept |
Copy constructor.
Definition at line 429 of file helper_jni.hpp.
|
inlinenoexcept |
Move constructor.
Definition at line 434 of file helper_jni.hpp.
|
inline |
Definition at line 462 of file helper_jni.hpp.
|
inlinenoexcept |
Constructs a new instance, taking ownership of the given T pointer.
Definition at line 469 of file helper_jni.hpp.
|
inlinenoexcept |
Constructs a new instance, copying the given std::shared_ptr<T>.
Definition at line 474 of file helper_jni.hpp.
|
inlinenoexcept |
Constructs a new instance, moving the given std::shared_ptr<T>.
Definition at line 479 of file helper_jni.hpp.
|
inline |
Constructs a new instance, copying the instance from the given java long nativeInstance
value, representing a java object's shared_ptr<T> storage.
Using a shared_ptr<T>
copy increments its reference counter and prohibits its destruction while in use.
If throw_on_nullptr
is true, throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr.
nativeInstance | the jlong representation of another shared_ptr<T> storage |
throw_on_nullptr | if true, throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr. |
Definition at line 529 of file helper_jni.hpp.
|
inline |
Constructs a new instance, copying the instance from the java object's long nativeInstance
field.
representing its shared_ptr<T> storage
Using a shared_ptr<T>
copy increments its reference counter and prohibits its destruction while in use.
If throw_on_nullptr
is true, throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr.
env | denoting the JVM |
obj | denoting the java object holding the long nativeInstance field, representing its shared_ptr<T> storage. Maybe nullptr , see throw_on_nullptr . |
throw_on_nullptr | if true, throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr. |
Definition at line 554 of file helper_jni.hpp.
|
inline |
Assignment operator.
Definition at line 441 of file helper_jni.hpp.
|
inlinenoexcept |
Move assignment operator.
Definition at line 453 of file helper_jni.hpp.
|
inline |
Assignment operator.
Definition at line 484 of file helper_jni.hpp.
|
inline |
Throws an exception if this instances shared_ptr<T> storage is nullptr.
The managed object reference may be nullptr.
Definition at line 498 of file helper_jni.hpp.
|
inline |
Throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr.
Definition at line 508 of file helper_jni.hpp.
|
inlinenoexcept |
Release ownership and returns the shared_ptr<T> storage.
This instance shall not be used anymore.
Definition at line 563 of file helper_jni.hpp.
|
inlinenoexcept |
Release ownership and return the jlong representation of the shared_ptr<T> storage.
This instance shall not be used anymore.
Definition at line 574 of file helper_jni.hpp.
|
inline |
Deletes the std::shared_ptr<T>
storage of the target java object if exists first and writes this instance's std::shared_ptr<T>
storage pointer into its long nativeInstance
field, then releases ownership, see release_to_jlong().
This instance shall not be used anymore.
Throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr.
env | |
obj | the target java object |
Definition at line 593 of file helper_jni.hpp.
|
inlinenoexcept |
Returns true if either this instances shared_ptr<T> storage or the managed object reference is nullptr.
Definition at line 614 of file helper_jni.hpp.
|
inlinenoexcept |
Provides access to the shared_ptr<T> pointer, l-value of storage.
Definition at line 621 of file helper_jni.hpp.
|
inline |
Provides access to const reference of shared_ptr<T>, r-value.
Throws an exception if this instances shared_ptr<T> storage is nullptr.
Definition at line 630 of file helper_jni.hpp.
|
inline |
Provides access to reference of stored T.
Throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr.
Definition at line 641 of file helper_jni.hpp.
|
inline |
Provides access to pointer of stored T.
Throws an exception if either this instances shared_ptr<T> storage or the managed object reference is nullptr.
Definition at line 652 of file helper_jni.hpp.
|
inlinenoexcept |
Definition at line 657 of file helper_jni.hpp.