1 /* Copyright (c) 2012-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
9 #include "src/instr/instr_private.h"
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)");
13 val_t s_val::PJ_value_update (const char *name, const char *color, type_t father)
15 this->ret = xbt_new0(s_val, 1);
16 this->ret->name = xbt_strdup (name);
17 this->ret->father = father;
18 this->ret->color = xbt_strdup (color);
20 char str_id[INSTR_DEFAULT_STR_SIZE];
21 snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
22 this->ret->id = xbt_strdup (str_id);
24 xbt_dict_set (father->values, name, ret, nullptr);
25 XBT_DEBUG("new value %s, child of %s", this->ret->name, this->ret->father->name);
26 LogEntityValue(this->ret);
30 s_val::s_val(const char *name, const char *color, type_t father){
31 if (name == nullptr || father == nullptr){
32 THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)");
34 this->ret = xbt_new0(s_val, 1);
35 this->ret->name = xbt_strdup (name);
36 this->ret->father = father;
37 this->ret->color = xbt_strdup (color);
39 char str_id[INSTR_DEFAULT_STR_SIZE];
40 snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
41 this->ret->id = xbt_strdup (str_id);
43 xbt_dict_set (father->values, name, ret, nullptr);
44 XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
45 LogEntityValue(this->ret);
48 val_t paje_value :: PJ_value_get_or_new (const char *name, const char *color, type_t father)
49 { paje_value pj_value;
52 ret = pj_value.PJ_value_get(name, father);
55 s_val rett(name, color, father);
61 val_t paje_value::PJ_value_get (const char *name, type_t father)
63 if (name == nullptr || father == nullptr){
64 THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)");
67 if (father->kind == TYPE_VARIABLE)
68 THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name);
69 val_t ret = (val_t)xbt_dict_get_or_null (father->values, name);
71 THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name);