//register NODE types for triva configuration
if (this->kind_ == simgrid::instr::INSTR_HOST || this->kind_ == simgrid::instr::INSTR_LINK ||
this->kind_ == simgrid::instr::INSTR_ROUTER) {
- trivaNodeTypes.insert(this->type_->name_);
+ trivaNodeTypes.insert(this->type_->getName());
}
}
simgrid::instr::Container::~Container()
TRACE_precision(), 0.);
stream << std::fixed << std::setprecision(TRACE_precision());
stream << simgrid::instr::PAJE_DefineContainerType;
- stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_;
+ stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName();
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
TRACE_precision(), 0.);
stream << std::fixed << std::setprecision(TRACE_precision());
stream << simgrid::instr::PAJE_DefineVariableType;
- stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_;
+ stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName();
if (type->isColored())
stream << " \"" << type->color_ << "\"";
print_row();
0.);
stream << std::fixed << std::setprecision(TRACE_precision());
stream << simgrid::instr::PAJE_DefineStateType;
- stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_;
+ stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName();
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
TRACE_precision(), 0.);
stream << std::fixed << std::setprecision(TRACE_precision());
stream << simgrid::instr::PAJE_DefineEventType;
- stream << " " << type->id_ << " " << type->father_->id_ << " " << type->name_;
+ stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName();
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
0.);
stream << std::fixed << std::setprecision(TRACE_precision());
stream << simgrid::instr::PAJE_DefineLinkType;
- stream << " " << type->id_ << " " << type->father_->id_ << " " << source->id_ << " " << dest->id_ << " "
- << type->name_;
+ stream << " " << type->getId() << " " << type->father_->getId() << " " << source->getId() << " " << dest->getId()
+ << " " << type->getName();
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
if (instr_fmt_type == instr_fmt_paje) {
stream << std::fixed << std::setprecision(TRACE_precision());
stream << simgrid::instr::PAJE_DefineEntityValue;
- stream << " " << id_ << " " << father_->id_ << " " << name_;
+ stream << " " << id_ << " " << father_->getId() << " " << name_;
if (isColored())
stream << " \"" << color_ << "\"";
print_row();
stream << 0;
else
stream << timestamp;
- stream << " " << container->id_ << " " << container->type_->id_ << " " << container->father_->id_ << " \""
+ stream << " " << container->id_ << " " << container->type_->getId() << " " << container->father_->id_ << " \""
<< container->name_ << "\"";
print_row();
stream << 0;
else
stream << timestamp;
- stream << " " << container->type_->id_ << " " << container->id_;
+ stream << " " << container->type_->getId() << " " << container->id_;
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || tracing_files.size() == 1) {
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_ << " " << value;
+ stream << " " << type->getId() << " " << container->id_ << " " << value;
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_ << " " << value;
+ stream << " " << type->getId() << " " << container->id_ << " " << value;
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_ << " " << value;
+ stream << " " << type->getId() << " " << container->id_ << " " << value;
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_;
+ stream << " " << type->getId() << " " << container->id_;
stream << " " << value->getId();
#if HAVE_SMPI
if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_;
+ stream << " " << type->getId() << " " << container->id_;
stream << " " << value->getId();
if (TRACE_display_sizes()) {
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_;
+ stream << " " << type->getId() << " " << container->id_;
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_;
+ stream << " " << type->getId() << " " << container->id_;
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_ << " " << value_;
+ stream << " " << type->getId() << " " << container->id_ << " " << value_;
stream << " " << sourceContainer_->id_ << " " << key_;
if (TRACE_display_sizes()) {
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_ << " " << value;
+ stream << " " << type->getId() << " " << container->id_ << " " << value;
stream << " " << destContainer->id_ << " " << key;
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
stream << std::fixed << std::setprecision(TRACE_precision());
stream << (int)this->eventType_;
print_timestamp(this);
- stream << " " << type->id_ << " " << container->id_ << " " << val->getId();
+ stream << " " << type->getId() << " " << container->id_ << " " << val->getId();
print_row();
} else if (instr_fmt_type == instr_fmt_TI) {
/* Nothing to do */
return rootType;
}
-simgrid::instr::Type::Type(const char* typeNameBuff, const char* key, std::string color, e_entity_types kind,
- Type* father)
- : color_(color), kind_(kind), father_(father)
+simgrid::instr::Type::Type(std::string name, const char* key, std::string color, e_entity_types kind, Type* father)
+ : name_(name), color_(color), kind_(kind), father_(father)
{
- if (typeNameBuff == nullptr || key == nullptr){
+ if (name.empty() || key == nullptr) {
THROWF(tracing_error, 0, "can't create a new type with name or key equal nullptr");
}
- this->name_ = xbt_strdup(typeNameBuff);
- this->id_ = bprintf("%lld", instr_new_paje_id());
+ this->id_ = std::to_string(instr_new_paje_id());
if (father != nullptr){
father->children_.insert({key, this});
- XBT_DEBUG("new type %s, child of %s", typeNameBuff, father->name_);
+ XBT_DEBUG("new type %s, child of %s", name_.c_str(), father->getCname());
}
}
simgrid::instr::Type::~Type()
{
for (auto elm : values_) {
- XBT_DEBUG("free value %s, child of %s", elm.second->getCname(), elm.second->father_->name_);
+ XBT_DEBUG("free value %s, child of %s", elm.second->getCname(), elm.second->father_->getCname());
delete elm.second;
}
for (auto elm : children_) {
delete elm.second;
}
- xbt_free(name_);
- xbt_free(id_);
}
-simgrid::instr::Type* simgrid::instr::Type::getChild(const char* name)
+simgrid::instr::Type* simgrid::instr::Type::getChild(std::string name)
{
simgrid::instr::Type* ret = this->getChildOrNull(name);
if (ret == nullptr)
- THROWF(tracing_error, 2, "type with name (%s) not found in father type (%s)", name, this->name_);
+ THROWF(tracing_error, 2, "type with name (%s) not found in father type (%s)", name.c_str(), getCname());
return ret;
}
-simgrid::instr::Type* simgrid::instr::Type::getChildOrNull(const char* name)
+simgrid::instr::Type* simgrid::instr::Type::getChildOrNull(std::string name)
{
- xbt_assert(name != nullptr, "can't get type with a nullptr name");
+ xbt_assert(not name.empty(), "can't get type with a nullptr name");
simgrid::instr::Type* ret = nullptr;
for (auto elm : children_) {
- if (strcmp(elm.second->name_, name) == 0) {
+ if (elm.second->name_ == name) {
if (ret != nullptr) {
THROWF (tracing_error, 0, "there are two children types with the same name?");
} else {
if (father == nullptr) {
rootType = ret;
} else {
- XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->name_, ret->id_, father->name_, father->id_);
+ XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(),
+ father->getId());
LogContainerTypeDefinition(ret);
}
return ret;
}
Type* ret = new Type(name, name, "", TYPE_EVENT, father);
- XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name_, ret->id_, father->name_, father->id_);
+ XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(), father->getId());
LogDefineEventType(ret);
return ret;
}
}else{
ret = new Type (name, name, color, TYPE_VARIABLE, father);
}
- XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name_, ret->id_, father->name_, father->id_);
+ XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(), father->getId());
LogVariableTypeDefinition (ret);
return ret;
}
}
char key[INSTR_DEFAULT_STR_SIZE];
- snprintf(key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", name, source->id_, dest->id_);
+ snprintf(key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", name, source->getId(), dest->getId());
Type* ret = new Type(name, key, "", TYPE_LINK, father);
- XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->name_, ret->id_, father->name_, father->id_,
- source->name_, source->id_, dest->name_, dest->id_);
+ XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->getCname(), ret->getId(), father->getCname(),
+ father->getId(), source->getCname(), source->getId(), dest->getCname(), dest->getId());
LogLinkTypeDefinition(ret, source, dest);
return ret;
}
}
Type* ret = new Type(name, name, "", TYPE_STATE, father);
- XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name_, ret->id_, father->name_, father->id_);
+ XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(), father->getId());
LogStateTypeDefinition(ret);
return ret;
}
this->id_ = std::to_string(instr_new_paje_id());
father->values_.insert({name, this});
- XBT_DEBUG("new value %s, child of %s", name_.c_str(), father_->name_);
+ XBT_DEBUG("new value %s, child of %s", name_.c_str(), father_->getCname());
print();
};
}
if (father->kind_ == TYPE_VARIABLE)
- THROWF(tracing_error, 0, "variables can't have different values (%s)", father->name_);
+ THROWF(tracing_error, 0, "variables can't have different values (%s)", father->getCname());
auto ret = father->values_.find(name);
if (ret == father->values_.end()) {
- THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name.c_str(), father->name_);
+ THROWF(tracing_error, 2, "value with name (%s) not found in father type (%s)", name.c_str(), father->getCname());
}
return ret->second;
}
//--------------------------------------------------
class Type {
+ std::string id_;
+ std::string name_;
+
public:
- char* id_;
- char* name_;
std::string color_;
-
e_entity_types kind_;
Type* father_;
std::map<std::string, Type*> children_;
std::map<std::string, Value*> values_; // valid for all types except variable and container
- Type(const char* typeNameBuff, const char* key, std::string color, e_entity_types kind, Type* father);
+ Type(std::string name, const char* key, std::string color, e_entity_types kind, Type* father);
~Type();
- Type* getChild(const char* name);
- Type* getChildOrNull(const char* name);
+ Type* getChild(std::string name);
+ Type* getChildOrNull(std::string name);
static Type* containerNew(const char* name, Type* father);
static Type* eventNew(const char* name, Type* father);
static Type* variableNew(const char* name, std::string color, Type* father);
static Type* linkNew(const char* name, Type* father, Type* source, Type* dest);
static Type* stateNew(const char* name, Type* father);
+ std::string getName() { return name_; }
+ const char* getCname() { return name_.c_str(); }
+ const char* getId() { return id_.c_str(); }
bool isColored() { return not color_.empty(); }
};
//--------------------------------------------------
class Value {
-private:
std::string name_;
std::string id_;
std::string color_;
static void instr_event(double now, double delta, simgrid::instr::Type* variable, container_t resource, double value)
{
- __TRACE_surf_check_variable_set_to_zero(now, variable->name_, resource->name_);
+ __TRACE_surf_check_variable_set_to_zero(now, variable->getCname(), resource->name_);
new simgrid::instr::AddVariableEvent(now, resource, variable, value);
new simgrid::instr::SubVariableEvent(now + delta, resource, variable, value);
}
//declare type
char link_typename[INSTR_DEFAULT_STR_SIZE];
- snprintf(link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s%s-%s%s", father->type_->name_, src->type_->name_,
- src->type_->id_, dst->type_->name_, dst->type_->id_);
+ snprintf(link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s%s-%s%s", father->type_->getCname(), src->type_->getCname(),
+ src->type_->getId(), dst->type_->getCname(), dst->type_->getId());
simgrid::instr::Type* link_type = father->type_->getChildOrNull(link_typename);
if (link_type == nullptr)
link_type = simgrid::instr::Type::linkNew(link_typename, father->type_, src->type_, dst->type_);
//register EDGE types for triva configuration
- trivaEdgeTypes.insert(link_type->name_);
+ trivaEdgeTypes.insert(link_type->getName());
//create the link
static long long counter = 0;
static void recursiveNewVariableType(const char* new_typename, const char* color, simgrid::instr::Type* root)
{
- if (not strcmp(root->name_, "HOST")) {
+ if (root->getName() == "HOST") {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
}
- if (not strcmp(root->name_, "MSG_VM")) {
+ if (root->getName() == "MSG_VM") {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
}
- if (not strcmp(root->name_, "LINK")) {
+ if (root->getName() == "LINK") {
char tnstr[INSTR_DEFAULT_STR_SIZE];
snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "b%s", new_typename);
simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
static void recursiveNewUserVariableType(const char* father_type, const char* new_typename, const char* color,
simgrid::instr::Type* root)
{
- if (not strcmp(root->name_, father_type)) {
+ if (root->getName() == father_type) {
simgrid::instr::Type::variableNew(new_typename, color == nullptr ? "" : color, root);
}
for (auto elm : root->children_)
static void recursiveNewUserStateType(const char* father_type, const char* new_typename, simgrid::instr::Type* root)
{
- if (not strcmp(root->name_, father_type)) {
+ if (root->getName() == father_type) {
simgrid::instr::Type::stateNew(new_typename, root);
}
for (auto elm : root->children_)
static void recursiveNewValueForUserStateType(const char* type_name, const char* val, const char* color,
simgrid::instr::Type* root)
{
- if (not strcmp(root->name_, type_name))
+ if (root->getName() == type_name)
simgrid::instr::Value::byNameOrCreate(val, color, root);
for (auto elm : root->children_)