Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] fix comment
[simgrid.git] / src / instr / instr_paje_values.c
1 /* Copyright (c) 2012. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5   * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "instr/instr_private.h"
7
8 #ifdef HAVE_TRACING
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)");
11
12 val_t PJ_value_new (const char *name, const char *color, type_t father)
13 {
14   if (name == NULL || father == NULL){
15     THROWF (tracing_error, 0, "can't create a value with a NULL name (or a NULL father)");
16   }
17
18   val_t ret = xbt_new0(s_val_t, 1);
19   ret->name = xbt_strdup (name);
20   ret->father = father;
21   ret->color = xbt_strdup (color);
22
23   char str_id[INSTR_DEFAULT_STR_SIZE];
24   snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
25   ret->id = xbt_strdup (str_id);
26
27   xbt_dict_set (father->values, name, ret, NULL);
28   XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
29   new_pajeDefineEntityValue(ret);
30   return ret;
31 }
32
33 val_t PJ_value_get (const char *name, type_t father)
34 {
35   if (name == NULL || father == NULL){
36     THROWF (tracing_error, 0, "can't get a value with a NULL name (or a NULL father)");
37   }
38
39   if (father->kind == TYPE_VARIABLE) return NULL; //Variables can't have different values
40   val_t ret = (val_t)xbt_dict_get_or_null (father->values, name);
41   if (ret == NULL){
42     return NULL;
43   }
44   return ret;
45 }
46
47 void PJ_value_free (val_t value)
48 {
49   XBT_DEBUG("free value %s, child of %s", value->name, value->father->name);
50   xbt_free(((val_t)value)->name);
51   xbt_free(((val_t)value)->color);
52   xbt_free(((val_t)value)->id);
53   xbt_free(value);
54 }
55
56
57 #endif