X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dba14c50ee8b9a49c93d13606839fd3c1b611c1b..5f0e7e7b36ee03e0af9961886102f1b427d7eb88:/src/simgrid/module.hpp diff --git a/src/simgrid/module.hpp b/src/simgrid/module.hpp index 3bd18c0ff0..771fe09c92 100644 --- a/src/simgrid/module.hpp +++ b/src/simgrid/module.hpp @@ -19,7 +19,7 @@ struct Module { const char* description_; std::function init; Module(const char* id, const char* desc, std::function init_fun) - : name_(id), description_(desc), init(init_fun) + : name_(id), description_(desc), init(std::move(init_fun)) { } }; @@ -27,16 +27,19 @@ struct Module { class ModuleGroup { std::vector 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) {} + explicit ModuleGroup(const std::string& kind) : kind_(kind) {} ModuleGroup& add(const char* id, const char* desc, std::function init); Module const& by_name(const std::string& name) const; void help() const; - const std::string get_kind() const { return kind_; } + const std::string& get_kind() const { return 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() const; }; }; // namespace simgrid @@ -77,6 +80,18 @@ inline auto& simgrid_cpu_models() // Function to avoid static initialization ord return models; } +#define SIMGRID_REGISTER_DISK_MODEL(id, desc, init) \ + static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _disk_model_register)() \ + { \ + simgrid_disk_models().add(_XBT_STRINGIFY(id), (desc), (init)); \ + } +/** @brief The list of all available disk models (pick one with --cfg=disk/model) */ +inline auto& simgrid_disk_models() // Function to avoid static initialization order fiasco +{ + static simgrid::ModuleGroup models("disk model"); + return models; +} + #define SIMGRID_REGISTER_HOST_MODEL(id, desc, init) \ static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _host_model_register)() \ { \ @@ -89,4 +104,6 @@ inline auto& simgrid_host_models() // Function to avoid static initialization or return models; } -#endif \ No newline at end of file +XBT_PUBLIC void simgrid_vm_model_init_HL13(); + +#endif