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 s_val::s_val(const char *name, const char *color, type_t father){
14 if (name == nullptr || father == nullptr){
15 THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)");
17 this->ret = xbt_new0(s_val, 1);
18 this->ret->name = xbt_strdup (name);
19 this->ret->father = father;
20 this->ret->color = xbt_strdup (color);
22 char str_id[INSTR_DEFAULT_STR_SIZE];
23 snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
24 this->ret->id = xbt_strdup (str_id);
26 xbt_dict_set (father->values, name, ret, nullptr);
27 XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
28 LogEntityValue(this->ret);
31 val_t s_val::PJ_value_get_or_new (const char *name, const char *color, type_t father)
35 ret = s_val::PJ_value_get(name, father);
38 s_val rett(name, color, father);
44 val_t s_val::PJ_value_get (const char *name, type_t father)
46 if (name == nullptr || father == nullptr){
47 THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)");
50 if (father->kind == TYPE_VARIABLE)
51 THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name);
52 val_t ret = (val_t)xbt_dict_get_or_null (father->values, name);
54 THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name);