Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Trust the config system to check that only valid values are used
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 13 Apr 2023 21:51:41 +0000 (23:51 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 13 Apr 2023 21:51:57 +0000 (23:51 +0200)
include/xbt/config.hpp
src/mc/mc_config.cpp

index 8071dbd..4cf17bf 100644 (file)
@@ -261,6 +261,17 @@ public:
   /* A constructor accepting a map of valid values -> their description,
    * and producing an informative error message when an invalid value is passed, or when help is passed as a value.
    */
+  Flag(const char* name, const char* desc, xbt::type_identity_t<T> value,
+       const std::map<std::string, std::string, std::less<>>& valid_values)
+      : value_(value), name_(name)
+  {
+    simgrid::config::bind_flag(value_, name, desc, valid_values, [](std::string) {});
+  }
+
+  /* As earlier, a constructor accepting a map of valid values -> their description,
+   * and producing an informative error message when an invalid value is passed, or when help is passed as a value.
+   * But also take a callback that is invoked before the verification of parameter name validity.
+   */
   template <class F>
   Flag(const char* name, const char* desc, xbt::type_identity_t<T> value,
        const std::map<std::string, std::string, std::less<>>& valid_values, F callback)
index e182f50..069d1ce 100644 (file)
@@ -66,11 +66,11 @@ simgrid::config::Flag<bool> _sg_mc_sleep_set{
     [](bool) { _mc_cfg_cb_check("value to enable/disable the use of sleep-set in the reduction algorithm"); }};
 
 simgrid::config::Flag<std::string> _sg_mc_strategy{
-    "model-check/strategy", "Specify the the kind of heuristic to use for guided model-checking", "none",
-    [](std::string_view value) {
-      if (value != "none" && value != "nb_wait")
-        xbt_die("configuration option 'model-check/guided-mc' can only take 'none' or 'nb_wait' as a value");
-    }};
+    "model-check/strategy",
+    "Specify the the kind of heuristic to use for guided model-checking",
+    "none",
+    {{"none", "No specific strategy: simply pick the first available transistion."},
+     {"nb_wait", "Take any enabled wait transition, to reduce the distance between an async and its wait."}}};
 
 #if SIMGRID_HAVE_STATEFUL_MC
 simgrid::config::Flag<int> _sg_mc_checkpoint{