- char state[100];
- char *val_one = NULL;
- if (!TRACE_is_active())
- return 1;
-
- //check if type is defined
- if (!xbt_dict_get_or_null(defined_types, type)) {
- THROW1(tracing_error, TRACE_ERROR_TYPE_NOT_DEFINED,
- "Type %s is not defined", type);
- return 1;
- }
- //check if parent_category exists
- if (strcmp(parent_category, "0")
- && !xbt_dict_get_or_null(created_categories, parent_category)) {
- THROW1(tracing_error, TRACE_ERROR_CATEGORY_NOT_DEFINED,
- "Category (used as parent) %s is not created", parent_category);
- return 1;
- }
- //check if category is created
- if (xbt_dict_get_or_null(created_categories, category)) {
- return 1;
- }
-
- pajeCreateContainer(MSG_get_clock(), category, type, parent_category,
- category);
-
- char final_color[INSTR_DEFAULT_STR_SIZE];
- if (!color){
- //generate a random color
- double red = drand48();
- double green = drand48();
- double blue = drand48();
- snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%f %f %f", red, green, blue);
- }else{
- snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
- }
-
- /* for registering application categories on top of platform */
- snprintf(state, 100, "b%s", category);
- if (TRACE_platform_is_enabled())
- pajeDefineVariableTypeWithColor(state, "LINK", state, final_color);
- snprintf(state, 100, "p%s", category);
- if (TRACE_platform_is_enabled())
- pajeDefineVariableTypeWithColor(state, "HOST", state, final_color);
-
- val_one = xbt_strdup("1");
- xbt_dict_set(created_categories, category, &val_one, xbt_free);
- return 0;