#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>
/** \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);
/** @} */
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
#include <utility>
#include <xbt/base.h>
-#include <xbt/config.h>
#include <xbt/sysdep.h>
namespace simgrid {
namespace config {
+class Config;
+
template<class T> inline
std::string to_string(T&& value)
{
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
#ifndef SIMGRID_CONFIG_HPP
#define SIMGRID_CONFIG_HPP
-#include "xbt/config.h"
#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;
/* 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"
/* 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"
/* 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 "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");
#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");
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"
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")) {
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;
}
* 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"
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));
}
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();
+}
}
}
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 = 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 = 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 = 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 = xbt_cfg_new();
+ simgrid_config = new simgrid::config::Config();
simgrid_config->alias(realname, aliasname);
}
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()
{
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;
}
xbt_test_exception(e);
}
}
- xbt_cfg_free(&simgrid_config);
+ simgrid::config::finalize();
simgrid_config = temp;
}
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;
}
#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"