Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
964343c37d9eee4835fae0d9431fbbfce00bb8c6
[simgrid.git] / src / xbt / config.cpp
1 /* Copyright (c) 2016. 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 <functional>
8 #include <string>
9
10 #include <xbt/config.h>
11 #include <xbt/config.hpp>
12
13 namespace simgrid {
14 namespace config {
15
16 static void callCallback(const char* name, void* data)
17 {
18   (*(std::function<void(const char*)>*) data)(name);
19 }
20
21 static void freeCallback(void* data)
22 {
23   delete (std::function<void(const char*)>*) data;
24 }
25
26 void registerConfig(const char* name, const char* description,
27   e_xbt_cfgelm_type_t type,
28   std::function<void(const char*)> callback)
29 {
30   std::function<void(const char*)>* code
31     = new std::function<void(const char*)>(std::move(callback));
32   xbt_cfg_register_ext(name, description, type,
33     callCallback, code, freeCallback);
34 }
35
36 }
37 }