libcommonc++  0.7
JavaVirtualMachine.h++
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------
2  commonc++ - A C++ Common Class Library
3  Copyright (C) 2005-2014 Mark A Lindner
4 
5  This file is part of commonc++.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public
18  License along with this library; if not, write to the Free
19  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  ---------------------------------------------------------------------------
21 */
22 
23 #ifndef __ccxx_JavaVirtualMachine_hxx
24 #define __ccxx_JavaVirtualMachine_hxx
25 
26 #include <commonc++/Common.h++>
27 #include <commonc++/Exception.h++>
28 #include <commonc++/SearchPath.h++>
32 
33 #include <jni.h>
34 
35 namespace ccxx {
36 
54 {
55  public:
56 
71  const SearchPath& linkerPath = SearchPath::empty,
72  uint_t initialHeapSize = 0, uint_t maxHeapSize = 0,
73  bool server = false, bool verbose = false,
74  bool nojit = false);
75 
81  JavaVirtualMachine(JavaVM* jvm);
82 
85 
92  JavaContext attachThread();
93 
100  void detachThread();
101 
103  inline bool isVerbose() const
104  { return(_verbose); }
105 
106  private:
107 
108  class JavaContextPtr : public ThreadLocal<JavaContext>
109  {
110  protected:
111 
112  JavaContext* initialValue()
113  { return(new JavaContext(NULL)); }
114  };
115 
116  JavaVM* _jvm;
117  JavaContextPtr _context;
118  bool _verbose;
119 
121 };
122 
123 } // namespace ccxx
124 
125 #endif // __ccxx_JavaVirtualMachine_hxx
#define COMMONCPPJVM_API
Definition: Common.h++:128
A file search path.
Definition: SearchPath.h++:45
An object that encapsulates (most of) the Java Native Interface (JNI) to a Java Virtual Machine...
Definition: JavaVirtualMachine.h++:53
unsigned int uint_t
An alias for unsigned int.
Definition: Integers.h++:74
bool isVerbose() const
Determine if verbose mode is enabled for this JVM.
Definition: JavaVirtualMachine.h++:103
When the Invocation Interface is being used (that is, when a C++ program calls into Java code)...
Definition: JavaContext.h++:67
static const SearchPath empty
An empty SearchPath.
Definition: SearchPath.h++:156
#define CCXX_COPY_DECLS(CLASS)
Inlines declarations of a copy constructor and assignment operator for the class CLASS.
Definition: Common.h++:295
Thread-local storage smart pointer.
Definition: ThreadLocal.h++:51
Definition: AllocationMap.c++:25