X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2d208a737e63d5fbbd8a7fc8a3d94f867610a85b..211acce5bb9cf1a60e14cab26b54367028474d79:/src/instr/instr_paje.c diff --git a/src/instr/instr_paje.c b/src/instr/instr_paje.c index 678d1d0f0d..ef88e61775 100644 --- a/src/instr/instr_paje.c +++ b/src/instr/instr_paje.c @@ -24,10 +24,44 @@ void instr_paje_init (container_t root) rootContainer = root; } -static long long int newTypeId () +static long long int new_type_id (void) { - static long long int counter = 0; - return counter++; + static long long int type_id = 0; + return type_id++; +} + +static val_t newValue (const char *valuename, const char *color, type_t father) +{ + val_t ret = xbt_new0(s_val_t, 1); + ret->name = xbt_strdup (valuename); + ret->father = father; + ret->color = xbt_strdup (color); + + char str_id[INSTR_DEFAULT_STR_SIZE]; + snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", new_type_id()); + ret->id = xbt_strdup (str_id); + + xbt_dict_set (father->values, valuename, ret, NULL); + DEBUG2("new value %s, child of %s", ret->name, ret->father->name); + return ret; +} + +val_t getValue (const char *valuename, const char *color, type_t father) +{ + if (father->kind == TYPE_VARIABLE) return NULL; //Variables can't have different values + + val_t ret = (val_t)xbt_dict_get_or_null (father->values, valuename); + if (ret == NULL){ + ret = newValue (valuename, color, father); + DEBUG4("EntityValue %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); + new_pajeDefineEntityValue(ret); + } + return ret; +} + +val_t getValueByName (const char *valuename, type_t father) +{ + return getValue (valuename, NULL, father); } static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father) @@ -37,11 +71,11 @@ static type_t newType (const char *typename, const char *key, const char *color, ret->father = father; ret->kind = kind; ret->children = xbt_dict_new (); + ret->values = xbt_dict_new (); ret->color = xbt_strdup (color); - long long int id = newTypeId(); char str_id[INSTR_DEFAULT_STR_SIZE]; - snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", id); + snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", new_type_id()); ret->id = xbt_strdup (str_id); if (father != NULL){ @@ -141,18 +175,11 @@ type_t getStateType (const char *typename, type_t father) return ret; } - -static long long int newContainedId () -{ - static long long counter = 0; - return counter++; -} - container_t newContainer (const char *name, e_container_types kind, container_t father) { - long long int counter = newContainedId(); + static long long int container_id = 0; char id_str[INSTR_DEFAULT_STR_SIZE]; - snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", counter); + snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", container_id++); container_t new = xbt_new0(s_container_t, 1); new->name = xbt_strdup (name); // name of the container @@ -225,7 +252,7 @@ container_t getContainer (const char *name) container_t getContainerByName (const char *name) { - return (container_t)xbt_dict_get (allContainers, name); + return (container_t)xbt_dict_get_or_null (allContainers, name); } char *getContainerIdByName (const char *name) @@ -252,9 +279,9 @@ static type_t recursiveGetType (const char *name, type_t root) return NULL; } -type_t getType (const char *name) +type_t getType (const char *name, type_t father) { - return recursiveGetType (name, rootType); + return recursiveGetType (name, father); } void destroyContainer (container_t container) @@ -266,13 +293,13 @@ void destroyContainer (container_t container) DEBUG1("destroy container %s", container->name); - //trace my destruction - new_pajeDestroyContainer(container); - //obligation to dump previous events because they might //reference the container that is about to be destroyed TRACE_last_timestamp_to_dump = surf_get_clock(); - TRACE_paje_dump_buffer(); + TRACE_paje_dump_buffer(1); + + //trace my destruction + new_pajeDestroyContainer(container); //free xbt_free (container->name); @@ -304,6 +331,7 @@ static void recursiveDestroyType (type_t type) xbt_free (type->name); xbt_free (type->id); xbt_free (type->children); + xbt_free (type->values); xbt_free (type); type = NULL; }