VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
SelfDetachingJNIEnv Class Reference

Smart wrapper around JNIEnv which retains information of how the environment was loaded. More...

Public Member Functions

 SelfDetachingJNIEnv (SelfDetachingJNIEnv &&value)
 Move-constructs a SelfDetachingJNIEnv instance, making it use the same JNIEnv that value was using. More...
 
 SelfDetachingJNIEnv (SelfDetachingJNIEnv &value)=delete
 Deleted copy constructor. More...
 
 SelfDetachingJNIEnv (const SelfDetachingJNIEnv &value)=delete
 Deleted copy constructor. More...
 
JNIEnv * getJNIEnv () const
 Returns underlying JNIEnv pointer. More...
 
JNIEnv & operator* ()
 Returns the dereferenced JNIEnv pointer. More...
 
const JNIEnv & operator* () const
 Returns a const reference to the JNIEnv pointer. More...
 
JNIEnv * operator-> ()
 Returns the underlying JNIEnv pointer to provide access to its members. More...
 
const JNIEnv * operator-> () const
 Returns ther underlying JNIEnv pointer to provide access to its const members. More...
 
SelfDetachingJNIEnvoperator= (SelfDetachingJNIEnv &&value)
 Move assigns value to this SelfDetachingJNIEnv instance. More...
 
SelfDetachingJNIEnvoperator= (SelfDetachingJNIEnv &value)=delete
 Deleted copy and assign operator. More...
 
SelfDetachingJNIEnvoperator= (const SelfDetachingJNIEnv &value)=delete
 Deleted copy and assign operator. More...
 
 operator bool () const
 Returns true if the wrapped JNIEnv is not null. More...
 

Static Public Member Functions

static SelfDetachingJNIEnv fromJVM (JavaVM *vm)
 Returns a SelfDetachingJNIEnv wrapper around the current JNIEnv. More...
 

Detailed Description

Smart wrapper around JNIEnv which retains information of how the environment was loaded.

If the current thread has attached to a JavaVM, then this wrapper will detach the current thread from the same JavaVM when the wrapper is deleted.

Constructor & Destructor Documentation

SelfDetachingJNIEnv::SelfDetachingJNIEnv ( SelfDetachingJNIEnv &&  value)

Move-constructs a SelfDetachingJNIEnv instance, making it use the same JNIEnv that value was using.

Parameters
valueSelfDetachingJNIEnv instance to move into this
SelfDetachingJNIEnv::SelfDetachingJNIEnv ( SelfDetachingJNIEnv value)
delete

Deleted copy constructor.

Parameters
valueSelfDetachingJNIEnv to copy
SelfDetachingJNIEnv::SelfDetachingJNIEnv ( const SelfDetachingJNIEnv value)
delete

Deleted copy constructor.

Parameters
valueSelfDetachingJNIEnv to copy

Member Function Documentation

static SelfDetachingJNIEnv SelfDetachingJNIEnv::fromJVM ( JavaVM *  vm)
static

Returns a SelfDetachingJNIEnv wrapper around the current JNIEnv.

This method first tries to load the current JVM environment. If that fails, this method will try attaching to the current JVM thread to load the environment if the vm is non-null.

Note
This method follows a similar model documented here.
JNIEnv* SelfDetachingJNIEnv::getJNIEnv ( ) const

Returns underlying JNIEnv pointer.

SelfDetachingJNIEnv::operator bool ( ) const
inline

Returns true if the wrapped JNIEnv is not null.

JNIEnv& SelfDetachingJNIEnv::operator* ( )

Returns the dereferenced JNIEnv pointer.

Note
If the wrapped pointer is null, behavior is undefined.
const JNIEnv& SelfDetachingJNIEnv::operator* ( ) const

Returns a const reference to the JNIEnv pointer.

Note
If the wrapped pointer is null, behavior is undefined.
JNIEnv* SelfDetachingJNIEnv::operator-> ( )

Returns the underlying JNIEnv pointer to provide access to its members.

const JNIEnv* SelfDetachingJNIEnv::operator-> ( ) const

Returns ther underlying JNIEnv pointer to provide access to its const members.

SelfDetachingJNIEnv& SelfDetachingJNIEnv::operator= ( SelfDetachingJNIEnv &&  value)

Move assigns value to this SelfDetachingJNIEnv instance.

Parameters
valueSelfDetachingJNIEnv instance to move into this
Returns
Reference to this
SelfDetachingJNIEnv& SelfDetachingJNIEnv::operator= ( SelfDetachingJNIEnv value)
delete

Deleted copy and assign operator.

Parameters
valueSelfDetachingJNIEnv to copy and assign
Returns
Reference to this
SelfDetachingJNIEnv& SelfDetachingJNIEnv::operator= ( const SelfDetachingJNIEnv value)
delete

Deleted copy and assign operator.

Parameters
valueSelfDetachingJNIEnv to copy and assign
Returns
Reference to this