Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix make distcheck
[simgrid.git] / src / bindings / java / jmsg_process.h
1 /* Functions related to the java process instances.                         */
2
3 /* Copyright (c) 2007-2015. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef MSG_JPROCESS_H
10 #define MSG_JPROCESS_H
11
12 #include <jni.h>
13 #include <simgrid/msg.h>
14 #include <simgrid/simix.h>
15
16 SG_BEGIN_DECL();
17
18 /* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
19 #ifndef JNIEXPORT
20 #define JNIEXPORT
21 #endif
22 #ifndef JNICALL
23 #define JNICALL
24 #endif
25 /* end of eclipse-mandated pimple */
26
27 //Cached java fields
28 extern jfieldID jprocess_field_Process_bind;
29 extern jfieldID jprocess_field_Process_host;
30 extern jfieldID jprocess_field_Process_killTime;
31 extern jfieldID jprocess_field_Process_id;
32 extern jfieldID jprocess_field_Process_name;
33 extern jfieldID jprocess_field_Process_pid;
34 extern jfieldID jprocess_field_Process_ppid;
35
36 jobject native_to_java_process(msg_process_t process);
37
38 /**
39  * This function returns a global reference to the  java process instance specified by the parameter jprocess.
40  *
41  * @param jprocess  The original java process instance.
42  * @param env       The env of the current thread
43  *
44  * @return          The global reference to the original java process instance.
45  */
46 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
47
48 /**
49  * This function delete a global reference to a java process instance.
50  * If the java process is alive the function joins it and stops it before.
51  *
52  * @param jprocess The global refernce to delete.
53  * @param env      The env of the current thread
54  *
55  * @see          jprocess_join()
56  * @see          jprocess_exit()
57  */
58 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
59
60 /**
61  * This function waits for a java process to terminate.
62  *
63  * @param jprocess  The java process to wait for.
64  * @param env       The env of the current thread
65  *
66  * @exception       If the class Process is not found the function throws the ClassNotFoundException. If the method
67                     join() of this class is not found the function throws the exception NotSuchMethodException.
68  */
69 void jprocess_join(jobject jprocess, JNIEnv * env);
70
71 /**
72  * This function associated a native process to a java process instance.
73  *
74  * @param jprocess   The java process instance.
75  * @param process    The native process to bind.
76  * @param env        The env of the current thread
77  *
78  * @exception        If the class Process is not found the function throws the ClassNotFoundException. If the field
79  *                   bind of this class is not found the function throws the exception NotSuchFieldException.
80  */
81 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env);
82
83 /**
84  * This function returns a native process from a java process instance.
85  *
86  * @param jprocess   The java process object from which get the native process.
87  * @param env        The env of the current thread
88  *
89  * @return           The function returns the native process associated to the java process object.
90  *
91  * @exception        If the class Process is not found the function throws the ClassNotFoundException. If the field
92  *                   bind of this class is not found the function throws the exception NotSuchFieldException.
93  */
94 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
95
96 /**
97  * This function gets the id of the specified java process.
98  *
99  * @param jprocess   The java process to get the id.
100  * @param env        The env of the current thread
101  *
102  * @exception        If the class Process is not found the function throws the ClassNotFoundException. If the field id
103  *                   of this class is not found the function throws the exception NotSuchFieldException.
104  *
105  * @return        The id of the specified java process.
106  */
107 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
108
109 /**
110  * This function tests if a java process instance is valid.
111  * A java process object is valid if it is bind to a native process.
112  *
113  * @param jprocess   The java process to test the validity.
114  * @param env        The env of the current thread
115  *
116  * @return           If the java process is valid the function returns true. Otherwise the function returns false.
117  */
118 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
119
120 /**
121  * This function gets the name of the specified java process.
122  *
123  * @param jprocess  The java process to get the name.
124  * @param env       The env of the current thread
125  *
126  * @exception       If the class Process is not found the function throws the ClassNotFoundException. If the field name
127  *                  of this class is not found the function throws the exception NotSuchFieldException.
128  *
129  * @return        The name of the specified java process.
130  */
131 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
132
133 /*
134  * Class    org_simgrid_msg_Process
135  * Method    nativeInit
136  * Signature  ();
137  */
138 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
139
140 /*
141  * Class    org_simgrid_msg_Process
142  * Method    create
143  * Signature  (Lorg/simgrid/msg/Host;)V
144  */
145 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject jprocess_arg, jobject jhostname);
146
147 /*
148  * Class    org_simgrid_msg_Process
149  * Method    killAll
150  * Signature  (I)I
151  */
152 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll (JNIEnv *, jclass, jint);
153
154 /*
155  * Class    org_simgrid_msg_Process
156  * Method    fromPID
157  * Signature  (I)Lorg/simgrid/msg/Process;
158  */
159 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID (JNIEnv *, jclass, jint);
160
161 /*
162  * Class        org_simgrid_msg_Process
163  * Method       getProperty
164  * Signature    (D)V
165  */
166 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname);
167
168 /*
169  * Class    org_simgrid_msg_Process
170  * Method    currentProcess
171  * Signature  ()Lorg/simgrid/msg/Process;
172  */
173 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess (JNIEnv *, jclass);
174
175 /*
176  * Class    org_simgrid_msg_Process
177  * Method    suspend
178  * Signature  (Lorg/simgrid/msg/Process;)V
179  */
180 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobject jprocess);
181
182 /*
183  * Class    org_simgrid_msg_Process
184  * Method    resume
185  * Signature  (Lorg/simgrid/msg/Process;)V
186  */
187 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume (JNIEnv *, jobject);
188
189 /*
190  * Class        org_simgrid_msg_Process
191  * Method       setAutoRestart
192  * Signature    (Lorg/simgrid/msg/Process;Z)V
193  */
194 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *, jobject, jboolean);
195
196 /*
197  * Class        org_simgrid_msg_Process
198  * Method       restart
199  * Signature    (Lorg/simgrid/msg/Process;)V
200  */
201 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *, jobject);
202
203 /*
204  * Class    org_simgrid_msg_Process
205  * Method    isSuspended
206  * Signature  (Lorg/simgrid/msg/Process;)Z
207  */
208 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended (JNIEnv *, jobject);
209
210 /*
211  * Class    org_simgrid_msg_Process
212  * Method    sleep
213  * Signature  (DI)V
214  */
215 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep (JNIEnv *, jclass, jlong, jint);
216
217 /*
218  * Class    org_simgrid_msg_Process
219  * Method    waitFor
220  * Signature  (D)V
221  */
222 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor (JNIEnv *, jobject, jdouble);
223
224 /*
225  * Class    org_simgrid_msg_Process
226  * Method    kill
227  * Signature  (Lorg/simgrid/msg/Process;)V
228  */
229 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill (JNIEnv *, jobject);
230
231 /*
232  * Class    org_simgrid_msg_Process
233  * Method    migrate
234  * Signature  (Lorg/simgrid/msg/Host;)V
235  */
236 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate (JNIEnv *, jobject, jobject);
237
238 /*
239  * Class    org_simgrid_msg_Process
240  * Method    setKillTime
241  * Signature  (D)V
242  */
243 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime (JNIEnv *, jobject, jdouble);
244
245 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
246
247 SG_END_DECL();
248 #endif                          /* !MSG_JPROCESS_H */