+/** @brief Displays the declared aliases and their description */
+void Config::showAliases()
+{
+ xbt_dict_cursor_t dict_cursor;
+ unsigned int dynar_cursor;
+ xbt_dictelm_t dictel;
+ char *name;
+ xbt_dynar_t names = xbt_dynar_new(sizeof(char *), NULL);
+
+ xbt_dict_foreach(this->aliases, dict_cursor, name, dictel)
+ xbt_dynar_push(names, &name);
+ xbt_dynar_sort_strings(names);
+
+ xbt_dynar_foreach(names, dynar_cursor, name) {
+ simgrid::config::ConfigurationElement* variable = (*this)[name];
+ if (variable)
+ printf(" %s: %s\n", name, variable->desc.c_str());
+ }
+}
+
+/** @brief Displays the declared options and their description */
+void Config::help()
+{
+ xbt_dict_cursor_t dict_cursor;
+ unsigned int dynar_cursor;
+ simgrid::config::ConfigurationElement* variable;
+ char *name;
+ xbt_dynar_t names = xbt_dynar_new(sizeof(char *), NULL);
+
+ xbt_dict_foreach(this->options, dict_cursor, name, variable)
+ xbt_dynar_push(names, &name);
+ xbt_dynar_sort_strings(names);
+
+ xbt_dynar_foreach(names, dynar_cursor, name) {
+ variable = (simgrid::config::ConfigurationElement*) xbt_dict_get(this->options, name);
+
+ printf(" %s: %s\n", name, variable->desc.c_str());
+ printf(" Type: %s; ", xbt_cfgelm_type_name[variable->type]);
+ printf("Current value: ");
+
+ switch (variable->type) {
+ case xbt_cfgelm_int:
+ printf("%d\n", variable->int_content);
+ break;
+ case xbt_cfgelm_double:
+ printf("%f\n", variable->double_content);
+ break;
+ case xbt_cfgelm_string:
+ printf("'%s'\n", variable->string_content);
+ break;
+ case xbt_cfgelm_boolean:
+ printf("'%s'\n", variable->boolean_content ? "true" : "false");
+ break;
+ default:
+ printf("Invalid type!!\n");
+ break;
+ }
+
+ }
+ xbt_dynar_free(&names);
+}
+
+}
+}
+
+// C bindings:
+
+/** @brief Constructor */
+xbt_cfg_t xbt_cfg_new(void) { return new simgrid::config::Config(); }
+/** @brief Destructor */
+void xbt_cfg_free(xbt_cfg_t * cfg) { delete *cfg; }
+
+void xbt_cfg_dump(const char *name, const char *indent, xbt_cfg_t cfg)
+{
+ cfg->dump(name, indent);
+}
+
+/*----[ Registering stuff ]-----------------------------------------------*/
+/** @brief Register an element within a config set
+ *
+ * @param cfg the config set
+ * @param name the name of the config element
+ * @param desc a description for this item (used by xbt_cfg_help())
+ * @param type the type of the config element
+ * @param cb_set callback function called when a value is set
+ */
+static simgrid::config::ConfigurationElement* xbt_cfg_register(
+ xbt_cfg_t * cfg, const char *name, const char *desc, e_xbt_cfgelm_type_t type, xbt_cfg_cb_t cb_set)
+{
+ if (*cfg == NULL)
+ *cfg = xbt_cfg_new();
+ return (*cfg)->registerOption(name, desc, type, cb_set);
+}
+