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 value::value(const char* name, const char* color, type_t father)
15 if (name == nullptr || father == nullptr){
16 THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)");
18 this->ret = xbt_new0(value, 1);
19 this->ret->name = xbt_strdup (name);
20 this->ret->father = father;
21 this->ret->color = xbt_strdup (color);
23 char str_id[INSTR_DEFAULT_STR_SIZE];
24 snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
25 this->ret->id = xbt_strdup (str_id);
27 xbt_dict_set (father->values, name, ret, nullptr);
28 XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
29 LogEntityValue(this->ret);
34 /* FIXME: this should be cleanable
41 value* value::get_or_new(const char* name, const char* color, type_t father)
45 ret = value::get(name, father);
48 value rett(name, color, father);
54 value* value::get(const char* name, type_t father)
56 if (name == nullptr || father == nullptr){
57 THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)");
60 if (father->kind == TYPE_VARIABLE)
61 THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name);
62 value* ret = (value*)xbt_dict_get_or_null(father->values, name);
64 THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name);