/* Pick the right models for CPU, net and host, and call their model_init_preparse */
static void surf_config_models_setup()
{
- std::string host_model_name = simgrid::config::get_value<std::string>("host/model");
-
- simgrid_host_models().by_name(host_model_name).init();
+ simgrid_host_models().init_from_flag_value();
XBT_DEBUG("Call vm_model_init");
/* TODO: ideally we should get back the pointer to CpuModel from init(), but this
void ModuleGroup::create_flag(const std::string& opt_name, const std::string& descr, const std::string& default_value,
bool init_now)
{
+ opt_name_ = opt_name;
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)";
by_name(value); // Simply ensure that this value exists, it will be picked up later
});
}
+void ModuleGroup::init_from_flag_value()
+{
+ by_name(simgrid::config::get_value<std::string>(opt_name_)).init();
+}
ModuleGroup& ModuleGroup::add(const char* id, const char* desc, std::function<void()> init)
{
class ModuleGroup {
std::vector<Module> table_;
const std::string kind_; // either 'plugin' or 'CPU model' or whatever. Used in error messages only
+ std::string opt_name_;
+
public:
ModuleGroup(const std::string& kind) : kind_(kind) {}
std::string existing_values() const;
void create_flag(const std::string& opt_name, const std::string& descr, const std::string& default_value,
bool init_now);
+ void init_from_flag_value();
};
}; // namespace simgrid
engine->add_model(host_model);
engine->get_netzone_root()->set_host_model(host_model);
- std::string network_model_name = simgrid::config::get_value<std::string>("network/model");
- std::string cpu_model_name = simgrid::config::get_value<std::string>("cpu/model");
- std::string disk_model_name = simgrid::config::get_value<std::string>("disk/model");
- simgrid_cpu_models().by_name(cpu_model_name).init();
- simgrid_disk_models().by_name(disk_model_name).init();
- simgrid_network_models().by_name(network_model_name).init();
+ simgrid_cpu_models().init_from_flag_value();
+ simgrid_disk_models().init_from_flag_value();
+ simgrid_network_models().init_from_flag_value();
});
namespace simgrid::kernel::resource {