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->name_ = xbt_strdup(name);
19 this->father_ = father;
20 this->color_ = xbt_strdup(color);
22 this->id_ = bprintf("%lld", instr_new_paje_id());
24 xbt_dict_set(father->values_, name, this, nullptr);
25 XBT_DEBUG("new value %s, child of %s", name_, father_->name_);
29 simgrid::instr::Value::~Value()
36 simgrid::instr::Value* simgrid::instr::Value::get_or_new(const char* name, const char* color,
37 simgrid::instr::Type* father)
41 ret = Value::get(name, father);
44 ret = new Value(name, color, father);
49 simgrid::instr::Value* simgrid::instr::Value::get(const char* name, Type* father)
51 if (name == nullptr || father == nullptr){
52 THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)");
55 if (father->kind_ == TYPE_VARIABLE)
56 THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name_);
57 Value* ret = (Value*)xbt_dict_get_or_null(father->values_, name);
59 THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name, father->name_);