1 /* Copyright (c) 2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
8 %module(directors="1") Surf
10 %include "arrays_java.i"
12 %pragma(java) jniclassimports=%{
13 import org.simgrid.NativeLib;
15 %pragma(java) jniclasscode=%{
17 NativeLib.nativeInit("surf-java");
18 Runtime.getRuntime().addShutdownHook(
21 Thread.currentThread().setName( "Destroyer" );
30 #include "src/surf/cpu_interface.hpp"
31 #include "src/surf/network_interface.hpp"
32 #include "src/bindings/java/surf_swig.hpp"
33 #include "src/xbt/dict_private.h"
34 typedef struct lmm_constraint *lmm_constraint_t;
37 /* Handle xbt_dynar_t of NetworkLink */
38 JAVA_ARRAYSOFCLASSES(NetworkLink);
39 %apply NetworkLink[] {NetworkLinkDynar};
40 %typemap(jstype) NetworkLinkDynar "NetworkLink[]"
41 %typemap(javain) NetworkLinkDynar "NetworkLink.cArrayUnwrap($javainput)"
43 %typemap(javaout) NetworkLinkDynar {
44 return NetworkLink.cArrayWrap($jnicall, $owner);
46 %typemap(out) NetworkLinkDynar {
47 long l = xbt_dynar_length($1);
48 $result = jenv->NewLongArray(l);
51 jlong *elts = jenv->GetLongArrayElements($result, NULL);
52 xbt_dynar_foreach($1, i, link) {
53 elts[i] = (jlong)link;
55 jenv->ReleaseLongArrayElements($result, elts, 0);
59 /* Allow to subclass Plugin and send java object to C++ code */
60 %feature("director") Plugin;
62 %include "src/bindings/java/surf_swig.hpp"
67 const char *getName();
73 const char *getName();
74 virtual bool isUsed()=0;
75 lmm_constraint *getConstraint();
76 s_xbt_dict *getProperties();
79 class Cpu : public Resource {
83 double getCurrentPowerPeak();
86 class NetworkLink : public Resource {
90 double getBandwidth();
91 void updateBandwidth(double value, double date=surf_get_clock());
93 void updateLatency(double value, double date=surf_get_clock());
96 %nodefaultctor Action;
100 lmm_variable *getVariable();
102 void setBound(double bound);
105 %nodefaultctor CpuAction;
106 class CpuAction : public Action {
109 Cpu *getCpu() {return getActionCpu($self);}
113 %nodefaultctor NetworkAction;
114 class NetworkAction : public Action {
117 double getLatency() {return $self->m_latency;}
121 %nodefaultctor RoutingEdge;
124 virtual char *getName()=0;
127 %rename lmm_constraint LmmConstraint;
128 struct lmm_constraint {
130 double getUsage() {return lmm_constraint_get_usage($self);}
134 %rename lmm_variable LmmVariable;
135 struct lmm_variable {
137 double getValue() {return lmm_variable_getvalue($self);}
141 %rename s_xbt_dict XbtDict;
144 char *getValue(char *key) {return (char*)xbt_dict_get_or_null($self, key);}
148 %rename e_surf_action_state_t ActionState;
150 SURF_ACTION_READY = 0, /**< Ready */
151 SURF_ACTION_RUNNING, /**< Running */
152 SURF_ACTION_FAILED, /**< Task Failure */
153 SURF_ACTION_DONE, /**< Completed */
154 SURF_ACTION_TO_FREE, /**< Action to free in next cleanup */
155 SURF_ACTION_NOT_IN_THE_SYSTEM
156 /**< Not in the system anymore. Why did you ask ? */
157 } e_surf_action_state_t;
159 %rename e_surf_resource_state_t ResourceState;
161 SURF_RESOURCE_ON = 1, /**< Up & ready */
162 SURF_RESOURCE_OFF = 0 /**< Down & broken */
163 } e_surf_resource_state_t;