MADARA  3.1.8
Acquire_VM.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_JAVA_ACQUIRE_VM_H_
3 #define _MADARA_JAVA_ACQUIRE_VM_H_
4 
5 #include "madara_jni.h"
6 
14 namespace madara
15 {
16  namespace utility
17  {
18  namespace java
19  {
24  class Acquire_VM
25  {
26  public:
32  Acquire_VM (bool no_detach = false)
33  {
34  if (!no_detach)
35  {
36  needs_detach = !madara_jni_is_attached ();
37  }
38  else
39  {
40  needs_detach = false;
41  }
42 
43  env = madara_jni_get_env ();
44  }
45 
50  {
51  if (needs_detach)
52  jni_detach();
53  }
54 
58  JNIEnv * env;
59 
60  protected:
65  };
66  }
67  }
68 }
69 
70 #endif // not defined _MADARA_JAVA_ACQUIRE_VM_H_
JNIEnv * env
The Java environment.
Definition: Acquire_VM.h:58
This class encapsulates attaching and detaching to a VM.
Definition: Acquire_VM.h:24
Provides utility functions and classes for common tasks and needs.
Definition: IteratorImpl.h:14
bool needs_detach
Flag for determining whether to call detach in destructor.
Definition: Acquire_VM.h:64
Copyright (c) 2015 Carnegie Mellon University.
Acquire_VM(bool no_detach=false)
Constructor.
Definition: Acquire_VM.h:32