X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b3973f5189df8d8983e47336546fd0259f0e2dab..91bb77753278264baf1acecdfe389ff7e2fcd270:/src/bindings/java/surf_swig.cpp diff --git a/src/bindings/java/surf_swig.cpp b/src/bindings/java/surf_swig.cpp index 88f0ee665d..c1cc3afc14 100644 --- a/src/bindings/java/surf_swig.cpp +++ b/src/bindings/java/surf_swig.cpp @@ -1,9 +1,14 @@ +/* Copyright (c) 2014. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + #include #include "src/surf/surf_interface.hpp" #include "surf_swig.hpp" #include "src/simix/smx_private.h" - double getClock() { return surf_get_clock(); } @@ -12,18 +17,32 @@ void clean() { SIMIX_clean(); } -/*NetworkModel *getNetworkModel() -{ - return surf_network_model; -}*/ +CpuModel *getCpuModel(){ + return surf_cpu_model_pm; +} + +CpuModel *java_cpu_model; +static void java_cpu_model_init_preparse() { + surf_cpu_model_pm = java_cpu_model; + xbt_dynar_push(model_list, &java_cpu_model); + xbt_dynar_push(model_list_invoke, &java_cpu_model); + sg_platf_host_add_cb(cpu_parse_init); +} + +void setCpuModel(CpuModel *cpuModel){ + java_cpu_model = cpuModel; + surf_cpu_model_init_preparse = java_cpu_model_init_preparse; +} + +void setCpu(char *name, Cpu *cpu) { + sg_host_surfcpu_set(sg_host_by_name(name), cpu); +} NetworkLinkDynar getRoute(char *srcName, char *dstName) { RoutingEdge *src = (RoutingEdge*)xbt_lib_get_or_null(host_lib, srcName, ROUTING_HOST_LEVEL); RoutingEdge *dst = (RoutingEdge*)xbt_lib_get_or_null(host_lib, dstName, ROUTING_HOST_LEVEL); - if (src==NULL) - xbt_die("TOTO"); - if (dst==NULL) - xbt_die("TOTO"); + xbt_assert(src,"Cannot get the route from a NULL source"); + xbt_assert(dst,"Cannot get the route to a NULL destination"); xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL); routing_platf->getRouteAndLatency(src, dst, &route, NULL); return route;