-/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2004-2018. 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. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support");
-XBT_EXPORT_NO_IMPORT(xbt_cfg_t) simgrid_config = nullptr;
-extern "C" {
- XBT_PUBLIC(void) sg_config_finalize();
-}
+XBT_EXPORT_NO_IMPORT xbt_cfg_t simgrid_config = nullptr;
+extern "C" XBT_PUBLIC void sg_config_finalize();
namespace simgrid {
namespace config {
/* Callback */
xbt_cfg_cb_t old_callback = nullptr;
- ConfigurationElement(const char* key, const char* desc)
- : key(key ? key : ""), desc(desc ? desc : "") {}
+ ConfigurationElement(const char* key, const char* desc) : key(key ? key : ""), desc(desc ? desc : "") {}
ConfigurationElement(const char* key, const char* desc, xbt_cfg_cb_t cb)
: key(key ? key : ""), desc(desc ? desc : ""), old_callback(cb) {}
private:
// name -> ConfigElement:
std::map<std::string, simgrid::config::ConfigurationElement*> options;
- // alias -> xbt_dict_elm_t from options:
+ // alias -> ConfigElement from options:
std::map<std::string, simgrid::config::ConfigurationElement*> aliases;
bool warn_for_aliases = true;
// ***** getConfig *****
-template<class T>
-XBT_PUBLIC(T const&) getConfig(const char* name)
+template <class T> XBT_PUBLIC T const& getConfig(const char* name)
{
return (*simgrid_config)[name].getValue<T>();
}
-template XBT_PUBLIC(int const&) getConfig<int>(const char* name);
-template XBT_PUBLIC(double const&) getConfig<double>(const char* name);
-template XBT_PUBLIC(bool const&) getConfig<bool>(const char* name);
-template XBT_PUBLIC(std::string const&) getConfig<std::string>(const char* name);
+template XBT_PUBLIC int const& getConfig<int>(const char* name);
+template XBT_PUBLIC double const& getConfig<double>(const char* name);
+template XBT_PUBLIC bool const& getConfig<bool>(const char* name);
+template XBT_PUBLIC std::string const& getConfig<std::string>(const char* name);
// ***** alias *****
// ***** declareFlag *****
-template<class T>
-XBT_PUBLIC(void) declareFlag(const char* name, const char* description,
- T value, std::function<void(const T&)> callback)
+template <class T>
+XBT_PUBLIC void declareFlag(const char* name, const char* description, T value, std::function<void(const T&)> callback)
{
if (simgrid_config == nullptr) {
simgrid_config = xbt_cfg_new();
name, description, std::move(value), std::move(callback));
}
-template XBT_PUBLIC(void) declareFlag(const char* name,
- const char* description, int value, std::function<void(int const &)> callback);
-template XBT_PUBLIC(void) declareFlag(const char* name,
- const char* description, double value, std::function<void(double const &)> callback);
-template XBT_PUBLIC(void) declareFlag(const char* name,
- const char* description, bool value, std::function<void(bool const &)> callback);
-template XBT_PUBLIC(void) declareFlag(const char* name,
- const char* description, std::string value, std::function<void(std::string const &)> callback);
-
+template XBT_PUBLIC void declareFlag(const char* name, const char* description, int value,
+ std::function<void(int const&)> callback);
+template XBT_PUBLIC void declareFlag(const char* name, const char* description, double value,
+ std::function<void(double const&)> callback);
+template XBT_PUBLIC void declareFlag(const char* name, const char* description, bool value,
+ std::function<void(bool const&)> callback);
+template XBT_PUBLIC void declareFlag(const char* name, const char* description, std::string value,
+ std::function<void(std::string const&)> callback);
}
}
* @param value the value to be added
*
*/
-void xbt_cfg_set_string(const char* key, std::string value)
+void xbt_cfg_set_string(const char* key, const char* value)
{
try {
(*simgrid_config)[key].setValue<std::string>(value);
return;
}
- TRANSLATE_EXCEPTIONS("Could not set variable %s to string %s", key, value.c_str());
+ TRANSLATE_EXCEPTIONS("Could not set variable %s to string %s", key, value);
}
/** @brief Set or add a boolean value to \a name within \a cfg
XBT_TEST_SUITE("config", "Configuration support");
-XBT_PUBLIC_DATA(xbt_cfg_t) simgrid_config;
+XBT_PUBLIC_DATA xbt_cfg_t simgrid_config;
static void make_set()
{