Accelerator Independent Data Access / PVAccess 2.0
AIDA-PVA is the latest version of the AIDA framework. Built on top of EPICS 7 it enables client applications to programmatically access and manage any device or database on the SLAC Network using simple channel names.
Loading...
Searching...
No Matches
aida_pva_jni_helper.h
Go to the documentation of this file.
1/** @file
2 * @brief The Header File for the JNI helper functions.
3 * **CMS**=C_INC
4 */
5#ifndef aida_pva_jni_helper_h
6#define aida_pva_jni_helper_h
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#include "aida_pva.h"
12
13/**
14 * A structure to hold a java object and java class.
15 */
16typedef struct
17{
18 jobject object;
19 jclass class;
20} JavaObject;
21
22/**
23 * A structure to hold a java class and a java method ID.
24 */
25typedef struct
26{
27 jclass class;
28 jmethodID methodId;
29} ClassAndMethod;
30
31
32// For Argument Processing
33
34/**
35 * Set of java classes that are needed to process the java {@link edu.stanford.slac.aida.lib.model.AidaArgument} class in C
36 */
37typedef struct
38{
39 jclass listClass;
40 jclass floatArgumentClass;
41 jclass doubleArgumentClass;
42 jclass aidaArgumentsClass;
43 jclass aidaArgumentClass;
44} ArgumentClasses;
45
46/**
47 * Set of java methods that are needed to process the java {@link edu.stanford.slac.aida.lib.model.AidaArgument} class in C
48 */
49typedef struct
50{
51 ArgumentClasses* argumentClasses;
52 jmethodID listSizeMethod;
53 jmethodID listGetMethod;
54 jmethodID argumentsGetArgumentsMethod;
55 jmethodID argumentGetNameMethod;
56 jmethodID argumentGetValueMethod;
57 jmethodID argumentsGetFloatArgumentsMethod;
58 jmethodID argumentsGetDoubleArgumentsMethod;
59 jmethodID getFloatNameMethod;
60 jmethodID getFloatValueMethod;
61 jmethodID getDoubleNameMethod;
62 jmethodID getDoubleValueMethod;
63} ArgumentMethods;
64
65/**
66 * Look up class in the given `env`,
67 * and create a new java object.
68 *
69 * @param env environment.
70 * @param clazz string name of java class to create.
71 * @return the new java object.
72 */
73JavaObject newObject(JNIEnv* env, char* clazz);
74
75/**
76 * Convert given jstring to a C string.
77 *
78 * @param env environment.
79 * @param string jstring.
80 * @return C string.
81 */
82char* toCString(JNIEnv* env, jstring string);
83
84/**
85 * Convert C string to jstring.
86 *
87 * @param env environment.
88 * @param string C string.
89 * @return jstring.
90 */
91jstring toJString(JNIEnv* env, const char* string);
92
93/**
94 * Get the method ID on the given class,
95 * with the given method name,
96 * and signature.
97 *
98 * @param env environment.
99 * @param clazz given class.
100 * @param methodName given method name.
101 * @param methodSignature given signature.
102 * @return the method that matches the name and signature specified.
103 */
104jmethodID getMethodId(JNIEnv* env, jclass clazz, char* methodName, char* methodSignature);
105
106/**
107 * Get the method ID of the constructor of the given class.
108 *
109 * @param env environment.
110 * @param clazz given class.
111 * @return the constructor method id.
112 */
113jmethodID getConstructorMethodId(JNIEnv* env, jclass clazz);
114
115/**
116 * Get an {@link Arguments} structure,
117 * from the given java List<AidaArgument>
118 *
119 * @param env environment.
120 * @param jArguments java arguments list - List<{@link AidaArgument}>
121 * @return {@link AidaArgument} structure
122 */
123Arguments toArguments(JNIEnv* env, jobject jArguments);
124
125/**
126 * Create a new instance of a java `boolean[]`,
127 * from the {@link Array} of boolean primitives.
128 *
129 * @param env environment.
130 * @param array {@link Array} of boolean primitives provided.
131 * @return new java `boolean[]`.
132 */
133jbooleanArray toBooleanArray(JNIEnv* env, Array array);
134
135/**
136 * Create a new instance of a java `byte[]`,
137 * from the {@link Array} of byte primitives.
138 *
139 * @param env environment.
140 * @param array {@link Array} of byte primitives provided.
141 * @return new java `byte[]`.
142 */
143jbyteArray toByteArray(JNIEnv* env, Array array);
144
145/**
146 * Create a new instance of a java short[],
147 * from the {@link Array} of short primitives.
148 *
149 * @param env environment.
150 * @param array {@link Array} of short primitives provided.
151 * @return new java short[].
152 */
153jshortArray toShortArray(JNIEnv* env, Array array);
154
155/**
156 * Create a new instance of a java int[],
157 * from the {@link Array} of integer primitives.
158 *
159 * @param env environment.
160 * @param array {@link Array} of integer primitives provided.
161 * @return new java int[].
162 */
163jintArray toIntegerArray(JNIEnv* env, Array array);
164
165/**
166 * Create a new instance of a java long[],
167 * from the {@link Array} of long primitives.
168 *
169 * @param env environment.
170 * @param array {@link Array} of long primitives provided.
171 * @return new java long[].
172 */
173jlongArray toLongArray(JNIEnv* env, Array array);
174
175/**
176 * Create a new instance of a java float[],
177 * from the {@link Array} of float primitives.
178 *
179 * @param env environment.
180 * @param array {@link Array} of float primitives provided.
181 * @return new java float[].
182 */
183jfloatArray toFloatArray(JNIEnv* env, Array array);
184
185/**
186 * Create a new instance of a java double[],
187 * from the {@link Array} of double primitives.
188 *
189 * @param env environment.
190 * @param array {@link Array} of double primitives provided.
191 * @return new java double[].
192 */
193jdoubleArray toDoubleArray(JNIEnv* env, Array array);
194
195/**
196 * Create a new instance of a java String[],
197 * from the {@link StringArray} of C string primitives.
198 *
199 * @param env environment.
200 * @param array {@link StringArray} of C string primitives provided
201 * @return new java String[]
202 */
203jobjectArray toStringArray(JNIEnv* env, StringArray array);
204
205/**
206 * Create a new instance of a java `List` of `List`s,
207 * from the given `Table `structure.
208 *
209 * @param env environment.
210 * @param table the {@link Table} provided
211 * @return new java List of Lists
212 */
213jobject toTable(JNIEnv* env, Table table);
214
215/**
216 * Create a new instance of a java Boolean,
217 * from the primitive boolean provided.
218 *
219 * @param env environment.
220 * @param primitive primitive boolean provided
221 * @return new java Boolean
222 */
223jobject toBoolean(JNIEnv* env, jboolean primitive);
224
225/**
226 * Create a new instance of a java Byte,
227 * from the primitive byte provided.
228 *
229 * @param env environment.
230 * @param primitive primitive byte provided
231 * @return new java Byte
232 */
233jobject toByte(JNIEnv* env, jbyte primitive);
234
235/**
236 * Create a new instance of a java Short,
237 * from the primitive short provided.
238 *
239 * @param env environment.
240 * @param primitive primitive short provided
241 * @return new java Short
242 */
243jobject toShort(JNIEnv* env, jshort primitive);
244
245/**
246 * Create a new instance of a java Integer,
247 * from the primitive int provided.
248 *
249 * @param env environment.
250 * @param primitive primitive int provided
251 * @return new java Integer
252 */
253jobject toInteger(JNIEnv* env, jint primitive);
254
255/**
256 * Create a new instance of a java Long,
257 * from the primitive long provided.
258 *
259 * @param env environment.
260 * @param primitive primitive long provided
261 * @return new java Long
262 */
263jobject toLong(JNIEnv* env, jlong primitive);
264
265/**
266 * Create a new instance of a java Float,
267 * from the primitive float provided.
268 *
269 * @param env environment.
270 * @param primitive primitive float provided
271 * @return new java Float
272 */
273jobject toFloat(JNIEnv* env, jfloat primitive);
274
275/**
276 * Create a new instance of a java Double,
277 * from the primitive double provided.
278 *
279 * @param env environment.
280 * @param primitive primitive double provided
281 * @return new java Double
282 */
283jobject toDouble(JNIEnv* env, jdouble primitive);
284
285/**
286 * Get value from the `value` argument,
287 * in the provided {@link Arguments} structure,
288 * when the value is a scalar.
289 *
290 * @param env environment.
291 * @param arguments provided arguments structure
292 * @return the extracted value
293 */
294Value getValue(JNIEnv* env, Arguments arguments);
295
296/**
297 * Get value from the `value` argument,
298 * in the provided {@link Arguments} structure,
299 * when the value is a scalar array.
300 *
301 * Even if the argument is not
302 * an array it will create a one element array to put it in.
303 *
304 * @param env environment.
305 * @param arguments provided arguments structure
306 * @return the extracted value
307 */
308Value getArrayValue(JNIEnv* env, Arguments arguments);
309
310#ifdef __cplusplus
311}
312#endif
313#endif
314
The Header File for the AIDA-PVA Module functions.
Value getArrayValue(JNIEnv *env, Arguments arguments)
Get value from the value argument, in the provided Arguments structure, when the value is a scalar ar...
jlongArray toLongArray(JNIEnv *env, Array array)
Create a new instance of a java long[], from the Array of long primitives.
jobject toTable(JNIEnv *env, Table table)
Create a new instance of a java List of Lists, from the given Tablestructure.
jbooleanArray toBooleanArray(JNIEnv *env, Array array)
Create a new instance of a java boolean[], from the Array of boolean primitives.
jmethodID getConstructorMethodId(JNIEnv *env, jclass clazz)
Get the method ID of the constructor of the given class.
jobject toInteger(JNIEnv *env, jint primitive)
Create a new instance of a java Integer, from the primitive int provided.
jshortArray toShortArray(JNIEnv *env, Array array)
Create a new instance of a java short[], from the Array of short primitives.
JavaObject newObject(JNIEnv *env, char *clazz)
Look up class in the given env, and create a new java object.
jobject toLong(JNIEnv *env, jlong primitive)
Create a new instance of a java Long, from the primitive long provided.
jobjectArray toStringArray(JNIEnv *env, StringArray array)
Create a new instance of a java String[], from the StringArray of C string primitives.
jfloatArray toFloatArray(JNIEnv *env, Array array)
Create a new instance of a java float[], from the Array of float primitives.
jobject toFloat(JNIEnv *env, jfloat primitive)
Create a new instance of a java Float, from the primitive float provided.
jobject toBoolean(JNIEnv *env, jboolean primitive)
Create a new instance of a java Boolean, from the primitive boolean provided.
jobject toShort(JNIEnv *env, jshort primitive)
Create a new instance of a java Short, from the primitive short provided.
Arguments toArguments(JNIEnv *env, jobject jArguments)
Get an Arguments structure, from the given java List<AidaArgument>
jintArray toIntegerArray(JNIEnv *env, Array array)
Create a new instance of a java int[], from the Array of integer primitives.
jobject toDouble(JNIEnv *env, jdouble primitive)
Create a new instance of a java Double, from the primitive double provided.
jbyteArray toByteArray(JNIEnv *env, Array array)
Create a new instance of a java byte[], from the Array of byte primitives.
jmethodID getMethodId(JNIEnv *env, jclass clazz, char *methodName, char *methodSignature)
Get the method ID on the given class, with the given method name, and signature.
Value getValue(JNIEnv *env, Arguments arguments)
Get value from the value argument, in the provided Arguments structure, when the value is a scalar.
jdoubleArray toDoubleArray(JNIEnv *env, Array array)
Create a new instance of a java double[], from the Array of double primitives.
jobject toByte(JNIEnv *env, jbyte primitive)
Create a new instance of a java Byte, from the primitive byte provided.
jstring toJString(JNIEnv *env, const char *string)
Convert C string to jstring.
char * toCString(JNIEnv *env, jstring string)
Convert given jstring to a C string.
An Arguments structure stores all of the arguments passed from the request to the Native Channel Prov...
An array of data.
An array of string data.
Table structure.
This special type represents a Value.