git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9448
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
/* rm every values */
XBT_PUBLIC(void) xbt_cfg_empty(xbt_cfg_t cfg, const char *name);
/* rm every values */
XBT_PUBLIC(void) xbt_cfg_empty(xbt_cfg_t cfg, const char *name);
+/* Return if configuration is set by default*/
+XBT_PUBLIC(int) xbt_cfg_is_default_value(xbt_cfg_t cfg, const char *name);
+
/* @} */
/** @defgroup XBT_cfg_decl Configuration type declaration and memory management
/* @} */
/** @defgroup XBT_cfg_decl Configuration type declaration and memory management
/** \brief Callback types. They get the name of the modified entry, and the position of the changed value */
typedef void (*xbt_cfg_cb_t) (const char *, int);
/** \brief Callback types. They get the name of the modified entry, and the position of the changed value */
typedef void (*xbt_cfg_cb_t) (const char *, int);
-/* xbt_cfgelm_t: the typedef corresponding to a config variable.
-
- Both data and DTD are mixed, but fixing it now would prevent me to ever
- defend my thesis. */
-
-typedef struct {
- /* Description */
- char *desc;
-
- /* Allowed type of the variable */
- e_xbt_cfgelm_type_t type;
- int min, max;
- int isdefault:1;
-
- /* Callbacks */
- xbt_cfg_cb_t cb_set;
- xbt_cfg_cb_t cb_rm;
-
- /* actual content
- (cannot be an union because type peer uses both str and i) */
- xbt_dynar_t content;
-} s_xbt_cfgelm_t, *xbt_cfgelm_t;
-
XBT_PUBLIC(xbt_cfg_t) xbt_cfg_new(void);
XBT_PUBLIC(void) xbt_cfg_cpy(xbt_cfg_t tocopy, /* OUT */
xbt_cfg_t * whereto);
XBT_PUBLIC(xbt_cfg_t) xbt_cfg_new(void);
XBT_PUBLIC(void) xbt_cfg_cpy(xbt_cfg_t tocopy, /* OUT */
xbt_cfg_t * whereto);
XBT_PUBLIC(void) xbt_cfg_dump(const char *name, const char *indent,
xbt_cfg_t cfg);
XBT_PUBLIC(void) xbt_cfg_dump(const char *name, const char *indent,
xbt_cfg_t cfg);
-/* Retrieve the variable we'll modify */
-XBT_PUBLIC(xbt_cfgelm_t) xbt_cfgelm_get(xbt_cfg_t cfg, const char *name,
- e_xbt_cfgelm_type_t type);
/** @} */
/** @defgroup XBT_cfg_register Registering stuff
/** @} */
/** @defgroup XBT_cfg_register Registering stuff
static void routing_parse_Econfig(void)
{
xbt_dict_cursor_t cursor = NULL;
static void routing_parse_Econfig(void)
{
xbt_dict_cursor_t cursor = NULL;
char *key;
char *elem;
char *cfg;
xbt_dict_foreach(current_property_set, cursor, key, elem) {
cfg = bprintf("%s:%s",key,elem);
char *key;
char *elem;
char *cfg;
xbt_dict_foreach(current_property_set, cursor, key, elem) {
cfg = bprintf("%s:%s",key,elem);
- variable = xbt_cfgelm_get(_surf_cfg_set, key, xbt_cfgelm_any);
- if(variable->isdefault)
+ if(xbt_cfg_is_default_value(_surf_cfg_set, key))
xbt_cfg_set_parse(_surf_cfg_set, cfg);
else
INFO1("The custom configuration '%s' is already define by user!",key);
xbt_cfg_set_parse(_surf_cfg_set, cfg);
else
INFO1("The custom configuration '%s' is already define by user!",key);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support");
+/* xbt_cfgelm_t: the typedef corresponding to a config variable.
+
+ Both data and DTD are mixed, but fixing it now would prevent me to ever
+ defend my thesis. */
+
+typedef struct {
+ /* Description */
+ char *desc;
+
+ /* Allowed type of the variable */
+ e_xbt_cfgelm_type_t type;
+ int min, max;
+ int isdefault:1;
+
+ /* Callbacks */
+ xbt_cfg_cb_t cb_set;
+ xbt_cfg_cb_t cb_rm;
+
+ /* actual content
+ (cannot be an union because type peer uses both str and i) */
+ xbt_dynar_t content;
+} s_xbt_cfgelm_t, *xbt_cfgelm_t;
+
static const char *xbt_cfgelm_type_name[xbt_cfgelm_type_count] =
{ "int", "double", "string", "peer", "any" };
/* Internal stuff used in cache to free a variable */
static void xbt_cfgelm_free(void *data);
static const char *xbt_cfgelm_type_name[xbt_cfgelm_type_count] =
{ "int", "double", "string", "peer", "any" };
/* Internal stuff used in cache to free a variable */
static void xbt_cfgelm_free(void *data);
+/* Retrieve the variable we'll modify */
+static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg, const char *name,
+ e_xbt_cfgelm_type_t type);
+
/*----[ Memory management ]-----------------------------------------------*/
/** @brief Constructor
/*----[ Memory management ]-----------------------------------------------*/
/** @brief Constructor
xbt_dict_cursor_free(&cursor);
}
xbt_dict_cursor_free(&cursor);
}
-xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg,
+static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg,
const char *name,
e_xbt_cfgelm_type_t type)
{
const char *name,
e_xbt_cfgelm_type_t type)
{
xbt_dynar_reset(variable->content);
}
}
xbt_dynar_reset(variable->content);
}
}
+/*
+ * Say if the value is the default value
+ */
+int xbt_cfg_is_default_value(xbt_cfg_t cfg, const char *name)
+{
+ xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_any);
+ return variable->isdefault;
+}
/*----[ Getting ]---------------------------------------------------------*/
/*----[ Getting ]---------------------------------------------------------*/