Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix issues for destroy callbacks
[simgrid.git] / src / bindings / java / surf.i
1 /* File : example.i */
2 %module(directors="1") Surf
3
4 %pragma(java) jniclassimports=%{
5 import org.simgrid.NativeLib;
6
7 %}
8 %pragma(java) jniclasscode=%{
9   static {
10     NativeLib.nativeInit("surf-java");
11     Runtime.getRuntime().addShutdownHook(
12       new Thread() {
13         public void run() {
14           Thread.currentThread().setName( "Destroyer" );
15           Surf.clean();
16         }
17       }
18     );
19   }
20 %}
21
22 %{
23 #include "src/surf/cpu_interface.hpp"
24 #include "src/surf/network_interface.hpp"
25 #include "src/bindings/java/surf_swig.hpp"
26 #include "src/xbt/dict_private.h"
27 typedef struct lmm_constraint *lmm_constraint_t;
28 %}
29
30 %feature("director") Plugin;
31
32 %include "src/bindings/java/surf_swig.hpp"
33
34 %nodefaultctor Model;
35 class Model {
36 public:
37   const char *getName();
38 };
39
40 class Resource {
41 public:
42   Resource();
43   const char *getName();
44   virtual bool isUsed()=0;
45   lmm_constraint *getConstraint();
46   s_xbt_dict *getProperties();
47 };
48
49 class Cpu : public Resource {
50 public:
51   Cpu();
52   ~Cpu();
53   double getCurrentPowerPeak();
54 };
55
56 class NetworkLink : public Resource {
57 public:
58   NetworkLink();
59   ~NetworkLink();
60 };
61
62 class Action {
63 public:
64   Model *getModel();
65 };
66
67 class CpuAction : public Action {
68 public:
69 %extend {
70   Cpu *getCpu() {return getActionCpu($self);}
71 }
72 };
73
74 %nodefaultctor NetworkAction;
75 class NetworkAction : public Action {
76 public:
77 %extend {
78   double getLatency() {return $self->m_latency;}
79 }
80 };
81
82
83 %rename lmm_constraint LmmConstraint;
84 struct lmm_constraint {
85 %extend {
86   double getUsage() {return lmm_constraint_get_usage($self);}
87 }
88 };
89
90 %rename s_xbt_dict XbtDict;
91 struct s_xbt_dict {
92 %extend {
93   char *getValue(char *key) {return (char*)xbt_dict_get_or_null($self, key);}
94 }
95 };
96