Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Convert last bits from the xbt/config C interface.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 19 Apr 2018 15:39:07 +0000 (17:39 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 19 Apr 2018 16:53:28 +0000 (18:53 +0200)
12 files changed:
include/xbt.h
include/xbt/config.h
include/xbt/config.hpp
src/include/simgrid/sg_config.hpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_events.cpp
src/mc/mc_config.cpp
src/s4u/s4u_engine.cpp
src/simgrid/sg_config.cpp
src/simix/smx_environment.cpp
src/xbt/config.cpp
src/xbt/xbt_main.cpp

index 073344b..96c0bdd 100644 (file)
@@ -24,6 +24,9 @@
 #include <xbt/parmap.h>
 
 #include <xbt/config.h>
 #include <xbt/parmap.h>
 
 #include <xbt/config.h>
+#ifdef __cplusplus
+#include <xbt/config.hpp>
+#endif
 #include <xbt/cunit.h>
 
 #include <xbt/xbt_os_thread.h>
 #include <xbt/cunit.h>
 
 #include <xbt/xbt_os_thread.h>
index df1cedb..18d17ce 100644 (file)
@@ -110,9 +110,10 @@ XBT_ATTRIB_DEPRECATED_v323("Please use simgrid::config::is_default") XBT_PUBLIC
 /** \brief Callback types. They get the name of the modified entry, and the position of the changed value */
 typedef void (*xbt_cfg_cb_t)(const char* name);
 
 /** \brief Callback types. They get the name of the modified entry, and the position of the changed value */
 typedef void (*xbt_cfg_cb_t)(const char* name);
 
-XBT_PUBLIC xbt_cfg_t xbt_cfg_new();
-XBT_PUBLIC void xbt_cfg_free(xbt_cfg_t* cfg);
-XBT_PUBLIC void xbt_cfg_dump(const char* name, const char* indent, xbt_cfg_t cfg);
+XBT_ATTRIB_DEPRECATED_v323("Please don't use it") XBT_PUBLIC xbt_cfg_t xbt_cfg_new();
+XBT_ATTRIB_DEPRECATED_v323("Please don't use it") XBT_PUBLIC void xbt_cfg_free(xbt_cfg_t* cfg);
+XBT_ATTRIB_DEPRECATED_v323("Please don't use it") XBT_PUBLIC
+    void xbt_cfg_dump(const char* name, const char* indent, xbt_cfg_t cfg);
 
 /** @} */
 
 
 /** @} */
 
@@ -134,8 +135,8 @@ XBT_ATTRIB_DEPRECATED_v323("Please use simgrid::config::declare_flag<bool>") XBT
 XBT_ATTRIB_DEPRECATED_v323("Please use simgrid::config::alias") XBT_PUBLIC
     void xbt_cfg_register_alias(const char* newname, const char* oldname);
 
 XBT_ATTRIB_DEPRECATED_v323("Please use simgrid::config::alias") XBT_PUBLIC
     void xbt_cfg_register_alias(const char* newname, const char* oldname);
 
-XBT_PUBLIC void xbt_cfg_aliases();
-XBT_PUBLIC void xbt_cfg_help();
+XBT_ATTRIB_DEPRECATED_v323("Please use simgrid::config::show_aliases") XBT_PUBLIC void xbt_cfg_aliases();
+XBT_ATTRIB_DEPRECATED_v323("Please use simgrid::config::help") XBT_PUBLIC void xbt_cfg_help();
 
 /*  @} */
 /** @defgroup XBT_cfg_get Getting the stored values
 
 /*  @} */
 /** @defgroup XBT_cfg_get Getting the stored values
index 48fd59f..10cdc39 100644 (file)
 #include <utility>
 
 #include <xbt/base.h>
 #include <utility>
 
 #include <xbt/base.h>
-#include <xbt/config.h>
 #include <xbt/sysdep.h>
 
 namespace simgrid {
 namespace config {
 
 #include <xbt/sysdep.h>
 
 namespace simgrid {
 namespace config {
 
+class Config;
+
 template<class T> inline
 std::string to_string(T&& value)
 {
 template<class T> inline
 std::string to_string(T&& value)
 {
@@ -279,6 +280,9 @@ public:
   bool operator>=(U const& that) const { return value_ >= that; }
 };
 
   bool operator>=(U const& that) const { return value_ >= that; }
 };
 
+XBT_PUBLIC void finalize();
+XBT_PUBLIC void show_aliases();
+XBT_PUBLIC void help();
 }
 }
 XBT_ATTRIB_DEPRECATED_v323("Please use simgrid::config::get_value<std::string>") XBT_PUBLIC std::string
 }
 }
 XBT_ATTRIB_DEPRECATED_v323("Please use simgrid::config::get_value<std::string>") XBT_PUBLIC std::string
index a11602f..998d724 100644 (file)
@@ -6,12 +6,10 @@
 #ifndef SIMGRID_CONFIG_HPP
 #define SIMGRID_CONFIG_HPP
 
 #ifndef SIMGRID_CONFIG_HPP
 #define SIMGRID_CONFIG_HPP
 
-#include "xbt/config.h"
 #include "xbt/config.hpp"
 
 /** Config Globals */
 
 #include "xbt/config.hpp"
 
 /** Config Globals */
 
-XBT_PUBLIC_DATA xbt_cfg_t simgrid_config;
 XBT_PUBLIC_DATA int _sg_cfg_init_status;
 XBT_PUBLIC_DATA int _sg_cfg_exit_asap;
 
 XBT_PUBLIC_DATA int _sg_cfg_init_status;
 XBT_PUBLIC_DATA int _sg_cfg_exit_asap;
 
index 9ecaa54..8b29f80 100644 (file)
@@ -3,8 +3,6 @@
 /* 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. */
 
 /* 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 <xbt/config.hpp>
-
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "src/instr/instr_private.hpp"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "src/instr/instr_private.hpp"
index 267c16d..6373f40 100644 (file)
@@ -3,8 +3,6 @@
 /* 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. */
 
 /* 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 <xbt/config.hpp>
-
 #include "src/instr/instr_private.hpp"
 #include "src/instr/instr_smpi.hpp"
 #include "src/smpi/include/private.hpp"
 #include "src/instr/instr_private.hpp"
 #include "src/instr/instr_smpi.hpp"
 #include "src/smpi/include/private.hpp"
index 4aebb9b..3aa17e3 100644 (file)
@@ -3,7 +3,7 @@
 /* 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. */
 
 /* 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 "xbt/config.h"
+#include "xbt/config.hpp"
 #include "xbt/log.h"
 #include <xbt/sysdep.h>
 
 #include "xbt/log.h"
 #include <xbt/sysdep.h>
 
index f928ff7..0510bbb 100644 (file)
@@ -18,7 +18,6 @@
 #include "src/kernel/EngineImpl.hpp"
 #include "src/surf/network_interface.hpp"
 #include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
 #include "src/kernel/EngineImpl.hpp"
 #include "src/surf/network_interface.hpp"
 #include "surf/surf.hpp" // routing_platf. FIXME:KILLME. SOON
-#include "xbt/config.hpp"
 
 XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
 
 
 XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
 
index 86c1a6f..c16b0c6 100644 (file)
@@ -14,7 +14,6 @@
 #include "src/mc/mc_replay.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "surf/surf.hpp"
 #include "src/mc/mc_replay.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "surf/surf.hpp"
-#include "xbt/config.h"
 #include "xbt/config.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf, "About the configuration of SimGrid");
 #include "xbt/config.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf, "About the configuration of SimGrid");
@@ -51,7 +50,7 @@ static void sg_config_cmd_line(int *argc, char **argv)
       shall_exit = 1;
     } else if (not strcmp(argv[i], "--cfg-help") || not strcmp(argv[i], "--help")) {
       printf("Description of the configuration accepted by this simulator:\n");
       shall_exit = 1;
     } else if (not strcmp(argv[i], "--cfg-help") || not strcmp(argv[i], "--help")) {
       printf("Description of the configuration accepted by this simulator:\n");
-      xbt_cfg_help();
+      simgrid::config::help();
       printf(
           "\n"
           "Each of these configurations can be used by adding\n"
       printf(
           "\n"
           "Each of these configurations can be used by adding\n"
@@ -69,7 +68,7 @@ static void sg_config_cmd_line(int *argc, char **argv)
       shall_exit = 1;
     } else if (not strcmp(argv[i], "--help-aliases")) {
       printf("Here is a list of all deprecated option names, with their replacement.\n");
       shall_exit = 1;
     } else if (not strcmp(argv[i], "--help-aliases")) {
       printf("Here is a list of all deprecated option names, with their replacement.\n");
-      xbt_cfg_aliases();
+      simgrid::config::show_aliases();
       printf("Please consider using the recent names\n");
       shall_exit = 1;
     } else if (not strcmp(argv[i], "--help-models")) {
       printf("Please consider using the recent names\n");
       shall_exit = 1;
     } else if (not strcmp(argv[i], "--help-models")) {
@@ -472,6 +471,6 @@ void sg_config_finalize()
   if (not _sg_cfg_init_status)
     return;                     /* Not initialized yet. Nothing to do */
 
   if (not _sg_cfg_init_status)
     return;                     /* Not initialized yet. Nothing to do */
 
-  xbt_cfg_free(&simgrid_config);
+  simgrid::config::finalize();
   _sg_cfg_init_status = 0;
 }
   _sg_cfg_init_status = 0;
 }
index eb475f5..3a97ce8 100644 (file)
@@ -5,7 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "smx_private.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "smx_private.hpp"
-#include "xbt/config.h"
+#include "xbt/config.hpp"
 #include "xbt/log.h"
 #include "xbt/sysdep.h"
 #include "xbt/xbt_os_time.h"
 #include "xbt/log.h"
 #include "xbt/sysdep.h"
 #include "xbt/xbt_os_time.h"
index 92f0412..4c3b69e 100644 (file)
@@ -459,7 +459,7 @@ template <class T>
 XBT_PUBLIC void declare_flag(const char* name, const char* description, T value, std::function<void(const T&)> callback)
 {
   if (simgrid_config == nullptr)
 XBT_PUBLIC void declare_flag(const char* name, const char* description, T value, std::function<void(const T&)> callback)
 {
   if (simgrid_config == nullptr)
-    simgrid_config = xbt_cfg_new();
+    simgrid_config = new simgrid::config::Config();
   simgrid_config->register_option<T>(name, description, std::move(value), std::move(callback));
 }
 
   simgrid_config->register_option<T>(name, description, std::move(value), std::move(callback));
 }
 
@@ -471,6 +471,22 @@ template XBT_PUBLIC void declare_flag(const char* name, const char* description,
                                       std::function<void(bool const&)> callback);
 template XBT_PUBLIC void declare_flag(const char* name, const char* description, std::string value,
                                       std::function<void(std::string const&)> callback);
                                       std::function<void(bool const&)> callback);
 template XBT_PUBLIC void declare_flag(const char* name, const char* description, std::string value,
                                       std::function<void(std::string const&)> callback);
+
+void finalize()
+{
+  delete simgrid_config;
+  simgrid_config = nullptr;
+}
+
+void show_aliases()
+{
+  simgrid_config->show_aliases();
+}
+
+void help()
+{
+  simgrid_config->help();
+}
 }
 }
 
 }
 }
 
@@ -493,35 +509,35 @@ void xbt_cfg_register_double(const char *name, double default_value,
   xbt_cfg_cb_t cb_set, const char *desc)
 {
   if (simgrid_config == nullptr)
   xbt_cfg_cb_t cb_set, const char *desc)
 {
   if (simgrid_config == nullptr)
-    simgrid_config = xbt_cfg_new();
+    simgrid_config = new simgrid::config::Config();
   simgrid_config->register_option<double>(name, desc, default_value, cb_set);
 }
 
 void xbt_cfg_register_int(const char *name, int default_value,xbt_cfg_cb_t cb_set, const char *desc)
 {
   if (simgrid_config == nullptr)
   simgrid_config->register_option<double>(name, desc, default_value, cb_set);
 }
 
 void xbt_cfg_register_int(const char *name, int default_value,xbt_cfg_cb_t cb_set, const char *desc)
 {
   if (simgrid_config == nullptr)
-    simgrid_config = xbt_cfg_new();
+    simgrid_config = new simgrid::config::Config();
   simgrid_config->register_option<int>(name, desc, default_value, cb_set);
 }
 
 void xbt_cfg_register_string(const char *name, const char *default_value, xbt_cfg_cb_t cb_set, const char *desc)
 {
   if (simgrid_config == nullptr)
   simgrid_config->register_option<int>(name, desc, default_value, cb_set);
 }
 
 void xbt_cfg_register_string(const char *name, const char *default_value, xbt_cfg_cb_t cb_set, const char *desc)
 {
   if (simgrid_config == nullptr)
-    simgrid_config = xbt_cfg_new();
+    simgrid_config = new simgrid::config::Config();
   simgrid_config->register_option<std::string>(name, desc, default_value ? default_value : "", cb_set);
 }
 
 void xbt_cfg_register_boolean(const char *name, const char*default_value,xbt_cfg_cb_t cb_set, const char *desc)
 {
   if (simgrid_config == nullptr)
   simgrid_config->register_option<std::string>(name, desc, default_value ? default_value : "", cb_set);
 }
 
 void xbt_cfg_register_boolean(const char *name, const char*default_value,xbt_cfg_cb_t cb_set, const char *desc)
 {
   if (simgrid_config == nullptr)
-    simgrid_config = xbt_cfg_new();
+    simgrid_config = new simgrid::config::Config();
   simgrid_config->register_option<bool>(name, desc, simgrid::config::parse_bool(default_value), cb_set);
 }
 
 void xbt_cfg_register_alias(const char *realname, const char *aliasname)
 {
   if (simgrid_config == nullptr)
   simgrid_config->register_option<bool>(name, desc, simgrid::config::parse_bool(default_value), cb_set);
 }
 
 void xbt_cfg_register_alias(const char *realname, const char *aliasname)
 {
   if (simgrid_config == nullptr)
-    simgrid_config = xbt_cfg_new();
+    simgrid_config = new simgrid::config::Config();
   simgrid_config->alias(realname, aliasname);
 }
 
   simgrid_config->alias(realname, aliasname);
 }
 
@@ -713,7 +729,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_cfg);
 
 XBT_TEST_SUITE("config", "Configuration support");
 
 
 XBT_TEST_SUITE("config", "Configuration support");
 
-XBT_PUBLIC_DATA xbt_cfg_t simgrid_config;
+XBT_PUBLIC_DATA simgrid::config::Config* simgrid_config;
 
 static void make_set()
 {
 
 static void make_set()
 {
@@ -730,7 +746,7 @@ XBT_TEST_UNIT("memuse", test_config_memuse, "Alloc and free a config set")
   make_set();
   xbt_test_add("Alloc and free a config set");
   simgrid::config::set_parse("peername:veloce user:bidule");
   make_set();
   xbt_test_add("Alloc and free a config set");
   simgrid::config::set_parse("peername:veloce user:bidule");
-  xbt_cfg_free(&simgrid_config);
+  simgrid::config::finalize();
   simgrid_config = temp;
 }
 
   simgrid_config = temp;
 }
 
@@ -756,7 +772,7 @@ XBT_TEST_UNIT("use", test_config_use, "Data retrieving tests")
         xbt_test_exception(e);
     }
   }
         xbt_test_exception(e);
     }
   }
-  xbt_cfg_free(&simgrid_config);
+  simgrid::config::finalize();
   simgrid_config = temp;
 }
 
   simgrid_config = temp;
 }
 
@@ -780,7 +796,7 @@ XBT_TEST_UNIT("c++flags", test_config_cxx_flags, "C++ flags")
   xbt_test_assert(bool_flag1, "Check bool1 flag");
   xbt_test_assert(not bool_flag2, "Check bool2 flag");
 
   xbt_test_assert(bool_flag1, "Check bool1 flag");
   xbt_test_assert(not bool_flag2, "Check bool2 flag");
 
-  xbt_cfg_free(&simgrid_config);
+  simgrid::config::finalize();
   simgrid_config = temp;
 }
 
   simgrid_config = temp;
 }
 
index 20be974..3faed87 100644 (file)
@@ -8,7 +8,7 @@
 #define XBT_LOG_LOCALLY_DEFINE_XBT_CHANNEL /* MSVC don't want it to be declared extern in headers and local here */
 
 #include "simgrid_config.h"
 #define XBT_LOG_LOCALLY_DEFINE_XBT_CHANNEL /* MSVC don't want it to be declared extern in headers and local here */
 
 #include "simgrid_config.h"
-#include "xbt/config.h"
+#include "xbt/config.hpp"
 #include "xbt/dynar.h"
 #include "xbt/log.h"
 #include "xbt/log.hpp"
 #include "xbt/dynar.h"
 #include "xbt/log.h"
 #include "xbt/log.hpp"