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 simgrid::instr::Value::Value(const char* name, const char* color, simgrid::instr::Type* 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_);
32 simgrid::instr::Value::~Value()
34 /* FIXME: this should be cleanable
41 simgrid::instr::Value* simgrid::instr::Value::get_or_new(const char* name, const char* color,
42 simgrid::instr::Type* father)
46 ret = Value::get(name, father);
49 Value rett(name, color, father);
55 simgrid::instr::Value* simgrid::instr::Value::get(const char* name, Type* father)
57 if (name == nullptr || father == nullptr){
58 THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)");
61 if (father->kind_ == TYPE_VARIABLE)
62 THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name_);
63 Value* ret = (Value*)xbt_dict_get_or_null(father->values_, name);
65 THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name_);