1 /* Copyright (c) 2012-2017. 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.hpp"
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) : father_(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->name_ = xbt_strdup(name);
19 this->color_ = xbt_strdup(color);
21 this->id_ = bprintf("%lld", instr_new_paje_id());
23 xbt_dict_set(father->values_, name, this, nullptr);
24 XBT_DEBUG("new value %s, child of %s", name_, father_->name_);
28 simgrid::instr::Value::~Value()
35 simgrid::instr::Value* simgrid::instr::Value::get_or_new(const char* name, const char* color,
36 simgrid::instr::Type* father)
40 ret = Value::get(name, father);
43 ret = new Value(name, color, father);
48 simgrid::instr::Value* simgrid::instr::Value::get(const char* name, Type* father)
50 if (name == nullptr || father == nullptr){
51 THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)");
54 if (father->kind_ == TYPE_VARIABLE)
55 THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name_);
56 Value* ret = (Value*)xbt_dict_get_or_null(father->values_, name);
58 THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name_);