/* Callbacks */
xbt_cfg_cb_t cb_set;
- xbt_cfg_cb_t cb_rm;
- /* actual content
- (cannot be an union because type peer used to use both str and i, but it could be converted now) */
+ /* actual content (could be an union or something) */
xbt_dynar_t content;
} s_xbt_cfgelm_t, *xbt_cfgelm_t;
xbt_dict_foreach((xbt_dict_t) tocopy, cursor, name, variable) {
xbt_cfg_register(whereto, name, variable->desc, variable->type,
- variable->min, variable->max, variable->cb_set,
- variable->cb_rm);
+ variable->min, variable->max, variable->cb_set);
}
}
/** @brief Dump a config set for debuging purpose
*
* @param name The name to give to this config set
- * @param indent what to write at the begining of each line (right number of spaces)
+ * @param indent what to write at the beginning of each line (right number of spaces)
* @param cfg the config set
*/
void xbt_cfg_dump(const char *name, const char *indent, xbt_cfg_t cfg)
size = xbt_dynar_length(variable->content);
printf
- ("%d_to_%d_%s. Actual size=%d. prerm=%p,postset=%p, List of values:\n",
- variable->min, variable->max,
- xbt_cfgelm_type_name[variable->type], size, variable->cb_rm,
- variable->cb_set);
+ ("%d_to_%d_%s. Actual size=%d. postset=%p, List of values:\n",
+ variable->min, variable->max, xbt_cfgelm_type_name[variable->type], size, variable->cb_set);
switch (variable->type) {
* @param min the minimum number of values for this config element
* @param max the maximum number of values for this config element
* @param cb_set callback function called when a value is set
- * @param cb_rm callback function called when a value is removed
*/
void xbt_cfg_register(xbt_cfg_t * cfg,
const char *name, const char *desc,
e_xbt_cfgelm_type_t type, int min,
- int max, xbt_cfg_cb_t cb_set, xbt_cfg_cb_t cb_rm)
+ int max, xbt_cfg_cb_t cb_set)
{
xbt_cfgelm_t res;
res->min = min;
res->max = max;
res->cb_set = cb_set;
- res->cb_rm = cb_rm;
res->isdefault = 1;
switch (type) {
"Invalid type in config element descriptor: %s%s", entry,
"; Should be one of 'string', 'int' or 'double'.");
- xbt_cfg_register(cfg, entrycpy, NULL, type, min, max, NULL, NULL);
+ xbt_cfg_register(cfg, entrycpy, NULL, type, min, max, NULL);
free(entrycpy); /* strdup'ed by dict mechanism, but cannot be const */
}
TRY {
while (variable == NULL) {
variable = xbt_dict_get((xbt_dict_t) cfg, key);
- while (variable->type == xbt_cfgelm_alias) {
+ if (variable->type == xbt_cfgelm_alias) {
const char *newname = (const char*)variable->content;
XBT_INFO("Note: configuration '%s' is deprecated. Please use '%s' instead.", key, newname);
key = newname;
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int);
if (variable->max == 1) {
- if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
- variable->cb_rm(name, 0);
-
xbt_dynar_set(variable->content, 0, &val);
} else {
if (variable->max
xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double);
if (variable->max == 1) {
- if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
- variable->cb_rm(name, 0);
-
xbt_dynar_set(variable->content, 0, &val);
} else {
if (variable->max
if (variable->max == 1) {
if (!xbt_dynar_is_empty(variable->content)) {
- if (variable->cb_rm)
- variable->cb_rm(name, 0);
- else if (variable->type == xbt_cfgelm_string) {
- char *sval = xbt_dynar_get_as(variable->content, 0, char *);
- free(sval);
- }
+ char *sval = xbt_dynar_get_as(variable->content, 0, char *);
+ free(sval);
}
xbt_dynar_set(variable->content, 0, &newval);
}
if (variable->max == 1) {
- if (variable->cb_rm && !xbt_dynar_is_empty(variable->content))
- variable->cb_rm(name, 0);
-
xbt_dynar_set(variable->content, 0, &bval);
} else {
if (variable->max
xbt_dynar_foreach(variable->content, cpt, seen) {
if (seen == val) {
- if (variable->cb_rm)
- variable->cb_rm(name, cpt);
xbt_dynar_cursor_rm(variable->content, &cpt);
return;
}
xbt_dynar_foreach(variable->content, cpt, seen) {
if (seen == val) {
xbt_dynar_cursor_rm(variable->content, &cpt);
- if (variable->cb_rm)
- variable->cb_rm(name, cpt);
return;
}
}
xbt_dynar_foreach(variable->content, cpt, seen) {
if (!strcpy(seen, val)) {
- if (variable->cb_rm)
- variable->cb_rm(name, cpt);
xbt_dynar_cursor_rm(variable->content, &cpt);
return;
}
xbt_dynar_foreach(variable->content, cpt, seen) {
if (seen == val) {
- if (variable->cb_rm)
- variable->cb_rm(name, cpt);
xbt_dynar_cursor_rm(variable->content, &cpt);
return;
}
"Cannot remove %dth value from the config element %s since it's already at its minimal size (=%d)",
pos, name, variable->min);
- if (variable->cb_rm)
- variable->cb_rm(name, pos);
xbt_dynar_remove_at(variable->content, pos, NULL);
}
RETHROW;
xbt_ex_free(e);
- THROWF(not_found_error, 0,
- "Can't empty '%s' since this config element does not exist",
- name);
+ THROWF(not_found_error, 0, "Can't empty '%s' since this option does not exist", name);
}
- if (variable) {
- if (variable->cb_rm) {
- unsigned int cpt;
- void *ignored;
- xbt_dynar_foreach(variable->content, cpt, ignored) {
- variable->cb_rm(name, cpt);
- }
- }
+ if (variable)
xbt_dynar_reset(variable->content);
- }
}
/*
* Say if the value is the default value
* Returns the first value from the config set under the given name.
* If there is more than one value, it will issue a warning. Consider using
* xbt_cfg_get_dynar() instead.
- *
- * \warning the returned value is the actual content of the config set
*/
int xbt_cfg_get_int(xbt_cfg_t cfg, const char *name)
{
* Returns the first value from the config set under the given name.
* If there is more than one value, it will issue a warning. Consider using
* xbt_cfg_get_dynar() instead.
- *
- * \warning the returned value is the actual content of the config set
*/
double xbt_cfg_get_double(xbt_cfg_t cfg, const char *name)
* Returns the first value from the config set under the given name.
* If there is more than one value, it will issue a warning. Consider using
* xbt_cfg_get_dynar() instead.
- *
- * \warning the returned value is the actual content of the config set
*/
int xbt_cfg_get_boolean(xbt_cfg_t cfg, const char *name)
{