Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e01b9522f8e9a195b3b9dba4e1c178fb1b40ffd2
[simgrid.git] / src / bindings / java / surf_swig.cpp
1 /* Copyright (c) 2014-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include <boost/lambda/bind.hpp>
8 #include "src/surf/surf_interface.hpp"
9 #include "surf_swig.hpp"
10 #include "src/simix/smx_private.h"
11
12 double getClock() {
13   return surf_get_clock();
14 }
15
16 void clean() {
17   SIMIX_clean();
18 }
19
20 CpuModel *getCpuModel(){
21   return surf_cpu_model_pm;
22 }
23
24 CpuModel *java_cpu_model;
25 static void java_cpu_model_init_preparse() {
26   surf_cpu_model_pm = java_cpu_model;
27   xbt_dynar_push(all_existing_models, &java_cpu_model);
28   sg_platf_host_add_cb(cpu_parse_init);
29 }
30
31 void setCpuModel(CpuModel *cpuModel){
32   java_cpu_model = cpuModel;
33   surf_cpu_model_init_preparse = java_cpu_model_init_preparse;
34 }
35
36 void setCpu(char *name, Cpu *cpu) {
37         sg_host_surfcpu_set(sg_host_by_name(name), cpu);
38 }
39
40 LinkDynar getRoute(char *srcName, char *dstName) {
41   RoutingEdge *src = sg_host_edge(sg_host_by_name(srcName));
42   RoutingEdge *dst = sg_host_edge(sg_host_by_name(dstName));
43   xbt_assert(src,"Cannot get the route from a NULL source");
44   xbt_assert(dst,"Cannot get the route to a NULL destination");
45   xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdge*), NULL);
46   routing_platf->getRouteAndLatency(src, dst, &route, NULL);
47   return route;
48 }
49
50 void Plugin::activateCpuCreatedCallback(){
51   surf_callback_connect(cpuCreatedCallbacks, boost::bind(&Plugin::cpuCreatedCallback, this, _1));
52 }
53
54 void Plugin::activateCpuDestructedCallback(){
55   surf_callback_connect(cpuDestructedCallbacks, boost::bind(&Plugin::cpuDestructedCallback, this, _1));
56 }
57
58 void Plugin::activateCpuStateChangedCallback(){
59   surf_callback_connect(cpuStateChangedCallbacks, boost::bind(&Plugin::cpuStateChangedCallback, this, _1, _2, _3));
60 }
61
62 void Plugin::activateCpuActionStateChangedCallback(){
63   surf_callback_connect(cpuActionStateChangedCallbacks, boost::bind(&Plugin::cpuActionStateChangedCallback, this, _1, _2, _3));
64 }
65
66
67 void Plugin::activateLinkCreatedCallback(){
68   surf_callback_connect(networkLinkCreatedCallbacks, boost::bind(&Plugin::networkLinkCreatedCallback, this, _1));
69 }
70
71 void Plugin::activateLinkDestructedCallback(){
72   surf_callback_connect(networkLinkDestructedCallbacks, boost::bind(&Plugin::networkLinkDestructedCallback, this, _1));
73 }
74
75 void Plugin::activateLinkStateChangedCallback(){
76   surf_callback_connect(networkLinkStateChangedCallbacks, boost::bind(&Plugin::networkLinkStateChangedCallback, this, _1, _2, _3));
77 }
78
79 void Plugin::activateNetworkActionStateChangedCallback(){
80   surf_callback_connect(networkActionStateChangedCallbacks, boost::bind(&Plugin::networkActionStateChangedCallback, this, _1, _2, _3));
81 }
82
83 void Plugin::activateNetworkCommunicateCallback(){
84   surf_callback_connect(networkCommunicateCallbacks, boost::bind(&Plugin::networkCommunicateCallback, this, _1, _2, _3, _4, _5));
85 }
86
87
88