X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d8eb62b207b566949a0d9ce649a7b21e226b9168..17496ac16483b8d60b8c375ac109d4c19639297b:/src/simix/smx_deployment.cpp diff --git a/src/simix/smx_deployment.cpp b/src/simix/smx_deployment.cpp index aece2e987c..b549d91ae3 100644 --- a/src/simix/smx_deployment.cpp +++ b/src/simix/smx_deployment.cpp @@ -3,14 +3,14 @@ /* 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 - +#include "simgrid/Exception.hpp" #include "simgrid/s4u/Host.hpp" #include "smx_private.hpp" #include "src/surf/xml/platf_private.hpp" // FIXME: KILLME. There must be a better way than mimicking XML here #include -#include + +#include +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_deployment, simix, "Logging specific to SIMIX (deployment)"); @@ -67,6 +67,10 @@ static simgrid::simix::ActorCodeFactory toActorCodeFactory(xbt_main_func_t code) { return [code](std::vector args) { return simgrid::xbt::wrap_main(code, std::move(args)); }; } +static simgrid::simix::ActorCodeFactory toActorCodeFactory(void (*code)(std::vector)) +{ + return [code](std::vector args) { return std::bind(std::move(code), std::move(args)); }; +} /** * @brief Registers a #xbt_main_func_t code in a global table. @@ -78,8 +82,10 @@ static simgrid::simix::ActorCodeFactory toActorCodeFactory(xbt_main_func_t code) */ void SIMIX_function_register(std::string name, xbt_main_func_t code) { - xbt_assert(simix_global, - "SIMIX_global_init has to be called before SIMIX_function_register."); + simix_global->registered_functions[name] = toActorCodeFactory(code); +} +void SIMIX_function_register(std::string name, void (*code)(std::vector)) +{ simix_global->registered_functions[name] = toActorCodeFactory(code); }