#include <xbt/asserts.h>
#include <xbt/log.h>
+#include "simgrid/sg_config.hpp"
#include "src/simgrid/module.hpp"
#include "src/surf/surf_interface.hpp"
using namespace simgrid;
+void ModuleGroup::create_flag(const std::string& opt_name, const std::string& descr, const std::string& default_value,
+ bool init_now)
+{
+ std::string description = descr + ". Possible values (other compilation flags may activate more " + get_kind() +
+ "s): " + existing_values() +
+ ".\n (use 'help' as a value to see the long description of each one)";
+
+ simgrid::config::declare_flag<std::string>(
+ opt_name, description, default_value, [this, default_value, init_now](const std::string& value) {
+ xbt_assert(_sg_cfg_init_status < 2, "Cannot load a %s after the initialization", kind_.c_str());
+
+ if (value == default_value)
+ return;
+
+ if (value == "help") {
+ help();
+ exit(0);
+ }
+
+ if (init_now)
+ by_name(value).init();
+ else
+ by_name(value); // Simply ensure that this value exists, it will be picked up later
+ });
+}
+
ModuleGroup& ModuleGroup::add(const char* id, const char* desc, std::function<void()> init)
{
table_.emplace_back(Module(id, desc, init));