From: Frederic Suter Date: Fri, 13 Oct 2017 09:49:43 +0000 (+0200) Subject: More objectification of instr::Type (wip) X-Git-Tag: v3.18~477 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9d62905a9c7ddccca81ac0b1b51677b8798026ca More objectification of instr::Type (wip) --- diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index fa1917b93e..43c3aa40ad 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -148,7 +148,7 @@ void TRACE_declare_mark(const char *mark_type) } XBT_DEBUG("MARK,declare %s", mark_type); - simgrid::instr::Type::eventNew(mark_type, PJ_type_get_root()); + PJ_type_get_root()->addEventType(mark_type); declared_marks.insert(mark_type); } diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 5d194eb8e3..abf732b4ad 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -7,13 +7,6 @@ #include "simgrid/s4u/Host.hpp" #include "src/instr/instr_private.hpp" #include "surf/surf.h" -#include -#ifdef WIN32 -#include // _mkdir -#endif - -#include /** std::setprecision **/ -#include #include XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_containers, instr, "Paje tracing event system (containers)"); @@ -47,7 +40,7 @@ namespace simgrid { namespace instr { Container::Container(std::string name, e_container_types kind, Container* father) - : name_(name), kind_(kind), father_(father) + : kind_(kind), name_(name), father_(father) { static long long int container_id = 0; id_ = std::to_string(container_id); // id (or alias) of the container diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index 6ec46dbc21..e077289654 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -11,10 +11,6 @@ #include "typeinfo" #include "xbt/virtu.h" /* sg_cmdline */ -#include -#include -#include /** std::setprecision **/ - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system"); static std::stringstream stream; @@ -186,7 +182,7 @@ void TRACE_paje_end() { XBT_DEBUG("Filename %s is closed", filename); } -void LogContainerTypeDefinition(simgrid::instr::Type* type) +void simgrid::instr::Type::logContainerTypeDefinition() { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineContainerType); //print it @@ -195,7 +191,7 @@ void LogContainerTypeDefinition(simgrid::instr::Type* type) TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); stream << simgrid::instr::PAJE_DefineContainerType; - stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName(); + stream << " " << id_ << " " << father_->getId() << " " << name_; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -204,7 +200,7 @@ void LogContainerTypeDefinition(simgrid::instr::Type* type) } } -void LogVariableTypeDefinition(simgrid::instr::Type* type) +void simgrid::instr::Type::logVariableTypeDefinition() { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineVariableType); @@ -214,9 +210,9 @@ void LogVariableTypeDefinition(simgrid::instr::Type* type) TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); stream << simgrid::instr::PAJE_DefineVariableType; - stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName(); - if (type->isColored()) - stream << " \"" << type->color_ << "\""; + stream << " " << id_ << " " << father_->getId() << " " << name_; + if (isColored()) + stream << " \"" << color_ << "\""; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -225,16 +221,16 @@ void LogVariableTypeDefinition(simgrid::instr::Type* type) } } -void LogStateTypeDefinition(simgrid::instr::Type* type) +void simgrid::instr::Type::logStateTypeDefinition() { //print it -if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType, TRACE_precision(), - 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << simgrid::instr::PAJE_DefineStateType; - stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName(); - print_row(); + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineStateType, + TRACE_precision(), 0.); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << simgrid::instr::PAJE_DefineStateType; + stream << " " << id_ << " " << father_->getId() << " " << name_; + print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ } else { @@ -242,7 +238,7 @@ if (instr_fmt_type == instr_fmt_paje) { } } -void LogDefineEventType(simgrid::instr::Type* type) +void simgrid::instr::Type::logDefineEventType() { //print it if (instr_fmt_type == instr_fmt_paje) { @@ -250,7 +246,7 @@ void LogDefineEventType(simgrid::instr::Type* type) TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); stream << simgrid::instr::PAJE_DefineEventType; - stream << " " << type->getId() << " " << type->father_->getId() << " " << type->getName(); + stream << " " << id_ << " " << father_->getId() << " " << name_; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -259,18 +255,17 @@ void LogDefineEventType(simgrid::instr::Type* type) } } -void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest) +void simgrid::instr::Type::logLinkTypeDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest) { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType); //print it -if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(), - 0.); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << simgrid::instr::PAJE_DefineLinkType; - stream << " " << type->getId() << " " << type->father_->getId() << " " << source->getId() << " " << dest->getId() - << " " << type->getName(); - print_row(); + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, simgrid::instr::PAJE_DefineLinkType, TRACE_precision(), + 0.); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << simgrid::instr::PAJE_DefineLinkType; + stream << " " << id_ << " " << father_->getId() << " " << source->getId() << " " << dest->getId() << " " << name_; + print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ } else { diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index d5d3e148fc..978009be63 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -18,17 +18,17 @@ simgrid::instr::Type* PJ_type_get_root() namespace simgrid { namespace instr { -Type::Type(std::string name, const char* key, std::string color, e_entity_types kind, Type* father) +Type::Type(std::string name, std::string alias, std::string color, e_entity_types kind, Type* father) : name_(name), color_(color), kind_(kind), father_(father) { - if (name.empty() || key == nullptr) { + if (name.empty() || alias.empty()) { THROWF(tracing_error, 0, "can't create a new type with name or key equal nullptr"); } id_ = std::to_string(instr_new_paje_id()); if (father != nullptr){ - father->children_.insert({key, this}); + father->children_.insert({alias, this}); XBT_DEBUG("new type %s, child of %s", name_.c_str(), father->getCname()); } } @@ -69,7 +69,7 @@ Type* Type::getChildOrNull(std::string name) return ret; } -Type* simgrid::instr::Type::containerNew(const char* name, Type* father) +Type* Type::containerNew(const char* name, Type* father) { if (name == nullptr){ THROWF (tracing_error, 0, "can't create a container type with a nullptr name"); @@ -81,66 +81,55 @@ Type* simgrid::instr::Type::containerNew(const char* name, Type* father) } else { XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(), father->getId()); - LogContainerTypeDefinition(ret); + ret->logContainerTypeDefinition(); } return ret; } -Type* Type::eventNew(const char* name, Type* father) +Type* Type::addEventType(std::string name) { - if (name == nullptr){ - THROWF (tracing_error, 0, "can't create an event type with a nullptr name"); + if (name.empty()) { + THROWF(tracing_error, 0, "can't create an event type with no name"); } - Type* ret = new Type(name, name, "", TYPE_EVENT, father); - XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(), father->getId()); - LogDefineEventType(ret); + Type* ret = new Type(name, name, "", TYPE_EVENT, this); + XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), getCname(), getId()); + ret->logDefineEventType(); return ret; } -Type* Type::variableNew(const char* name, std::string color, Type* father) +Type* Type::addVariableType(std::string name, std::string color) { - if (name == nullptr){ - THROWF (tracing_error, 0, "can't create a variable type with a nullptr name"); - } + if (name.empty()) + THROWF(tracing_error, 0, "can't create a variable type with no name"); - Type* ret = nullptr; + Type* ret = new Type(name, name, color.empty() ? "1 1 1" : color, TYPE_VARIABLE, this); + + XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), getCname(), getId()); + ret->logVariableTypeDefinition(); - if (color.empty()) { - char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1"; - ret = new Type (name, name, white, TYPE_VARIABLE, father); - }else{ - ret = new Type (name, name, color, TYPE_VARIABLE, father); - } - XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(), father->getId()); - LogVariableTypeDefinition (ret); return ret; } -Type* Type::linkNew(const char* name, Type* father, Type* source, Type* dest) +Type* Type::addLinkType(std::string name, Type* source, Type* dest) { - if (name == nullptr){ - THROWF (tracing_error, 0, "can't create a link type with a nullptr name"); + if (name.empty()) { + THROWF(tracing_error, 0, "can't create a link type with no name"); } - char key[INSTR_DEFAULT_STR_SIZE]; - 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->getCname(), ret->getId(), father->getCname(), - father->getId(), source->getCname(), source->getId(), dest->getCname(), dest->getId()); - LogLinkTypeDefinition(ret, source, dest); + std::string alias = name + "-" + source->id_ + "-" + dest->id_; + Type* ret = new Type(name, alias, "", TYPE_LINK, this); + XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->getCname(), ret->getId(), getCname(), getId(), + source->getCname(), source->getId(), dest->getCname(), dest->getId()); + ret->logLinkTypeDefinition(source, dest); return ret; } -Type* Type::stateNew(const char* name, Type* father) +Type* Type::addStateType(std::string name) { - if (name == nullptr){ - THROWF (tracing_error, 0, "can't create a state type with a nullptr name"); - } - - Type* ret = new Type(name, name, "", TYPE_STATE, father); - XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), father->getCname(), father->getId()); - LogStateTypeDefinition(ret); + Type* ret = new Type(name, name, "", TYPE_STATE, this); + XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->getCname(), ret->getId(), getCname(), getId()); + ret->logStateTypeDefinition(); return ret; } } diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index b9e498d199..e77f9f67fe 100644 --- a/src/instr/instr_paje_values.cpp +++ b/src/instr/instr_paje_values.cpp @@ -41,7 +41,7 @@ Value* Value::byName(std::string name, Type* father) THROWF(tracing_error, 0, "can't get a value with no name (or a nullptr father)"); } - if (father->kind_ == TYPE_VARIABLE) + if (father->getKind() == TYPE_VARIABLE) THROWF(tracing_error, 0, "variables can't have different values (%s)", father->getCname()); auto ret = father->values_.find(name); if (ret == father->values_.end()) { diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index dffb962f2e..9f535fa50b 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -13,13 +13,16 @@ #include "simgrid_config.h" #include "src/internal_config.h" #include "xbt/graph.h" +#include /** std::setprecision **/ #include #include +#include #include - +#include +#ifdef WIN32 +#include // _mkdir /* Need to define function drand48 for Windows */ /* FIXME: use _drand48() defined in src/surf/random_mgr.c instead */ -#ifdef _WIN32 #define drand48() (rand() / (RAND_MAX + 1.0)) #endif @@ -51,34 +54,44 @@ enum e_event_type { PAJE_NewEvent }; -enum e_entity_types { TYPE_VARIABLE, TYPE_LINK, TYPE_CONTAINER, TYPE_STATE, TYPE_EVENT }; - //-------------------------------------------------- +enum e_entity_types { TYPE_VARIABLE, TYPE_LINK, TYPE_CONTAINER, TYPE_STATE, TYPE_EVENT }; class Type { std::string id_; std::string name_; - -public: std::string color_; e_entity_types kind_; Type* father_; + +public: std::map children_; std::map values_; // valid for all types except variable and container - Type(std::string name, const char* key, std::string color, e_entity_types kind, Type* father); + + Type(std::string name, std::string alias, std::string color, e_entity_types kind, Type* father); ~Type(); - Type* byName(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(); } + e_entity_types getKind() { return kind_; } bool isColored() { return not color_.empty(); } + + Type* byName(std::string name); + + Type* addEventType(std::string name); + Type* addLinkType(std::string name, Type* source, Type* dest); + Type* addStateType(std::string name); + Type* addVariableType(std::string name, std::string color); + + void logContainerTypeDefinition(); + void logVariableTypeDefinition(); + void logStateTypeDefinition(); + void logLinkTypeDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest); + void logDefineEventType(); + + Type* getChildOrNull(std::string name); + static Type* containerNew(const char* name, Type* father); }; //-------------------------------------------------- @@ -112,9 +125,10 @@ enum e_container_types { INSTR_MSG_TASK }; -//-------------------------------------------------- - class Container { + e_container_types kind_; /* This container is of what kind */ + int level_ = 0; /* Level in the hierarchy, root level is 0 */ + public: Container(std::string name, simgrid::instr::e_container_types kind, Container* father); virtual ~Container(); @@ -123,8 +137,6 @@ public: std::string name_; /* Unique name of this container */ std::string id_; /* Unique id of this container */ Type* type_; /* Type of this container */ - int level_ = 0; /* Level in the hierarchy, root level is 0 */ - e_container_types kind_; /* This container is of what kind */ Container* father_; std::map children_; static Container* byNameOrNull(std::string name); @@ -388,10 +400,4 @@ enum instr_fmt_type_t { instr_fmt_paje, instr_fmt_TI }; extern instr_fmt_type_t instr_fmt_type; } -void LogContainerTypeDefinition(simgrid::instr::Type* type); -void LogVariableTypeDefinition(simgrid::instr::Type* type); -void LogStateTypeDefinition(simgrid::instr::Type* type); -void LogLinkTypeDefinition(simgrid::instr::Type* type, simgrid::instr::Type* source, simgrid::instr::Type* dest); -void LogDefineEventType(simgrid::instr::Type* type); - #endif diff --git a/src/smpi/colls/smpi_automatic_selector.cpp b/src/smpi/colls/smpi_automatic_selector.cpp index c86f3152a7..2407223a3a 100644 --- a/src/smpi/colls/smpi_automatic_selector.cpp +++ b/src/smpi/colls/smpi_automatic_selector.cpp @@ -18,7 +18,7 @@ if (TRACE_is_enabled()) { \ simgrid::instr::Type* type = PJ_type_get_root()->getChildOrNull(#cat); \ if (not type) { \ - type = simgrid::instr::Type::eventNew(#cat, PJ_type_get_root()); \ + type = PJ_type_get_root()->addEventType(#cat); \ } \ char cont_name[25]; \ snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \ diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index 7451da2a98..6881fbde33 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -101,7 +101,7 @@ static void linkContainers(container_t src, container_t dst, std::settype_->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_); + link_type = father->type_->addLinkType(link_typename, src->type_, dst->type_); //register EDGE types for triva configuration trivaEdgeTypes.insert(link_type->getName()); @@ -169,8 +169,8 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone) if (mpi == nullptr){ mpi = simgrid::instr::Type::containerNew("MPI", root->type_); if (not TRACE_smpi_is_grouped()) - simgrid::instr::Type::stateNew("MPI_STATE", mpi); - simgrid::instr::Type::linkNew("MPI_LINK", PJ_type_get_root(), mpi, mpi); + mpi->addStateType("MPI_STATE"); + PJ_type_get_root()->addLinkType("MPI_LINK", mpi, mpi); } } @@ -208,17 +208,17 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link) if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) { simgrid::instr::Type* bandwidth = container->type_->getChildOrNull("bandwidth"); if (bandwidth == nullptr) - bandwidth = simgrid::instr::Type::variableNew("bandwidth", "", container->type_); + bandwidth = container->type_->addVariableType("bandwidth", ""); simgrid::instr::Type* latency = container->type_->getChildOrNull("latency"); if (latency == nullptr) - latency = simgrid::instr::Type::variableNew("latency", "", container->type_); + latency = container->type_->addVariableType("latency", ""); new simgrid::instr::SetVariableEvent(0, container, bandwidth, bandwidth_value); new simgrid::instr::SetVariableEvent(0, container, latency, latency_value); } if (TRACE_uncategorized()) { simgrid::instr::Type* bandwidth_used = container->type_->getChildOrNull("bandwidth_used"); if (bandwidth_used == nullptr) - simgrid::instr::Type::variableNew("bandwidth_used", "0.5 0.5 0.5", container->type_); + container->type_->addVariableType("bandwidth_used", "0.5 0.5 0.5"); } } @@ -230,7 +230,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) { simgrid::instr::Type* speed = container->type_->getChildOrNull("power"); if (speed == nullptr){ - speed = simgrid::instr::Type::variableNew("power", "", container->type_); + speed = container->type_->addVariableType("power", ""); } double current_speed_state = host.getSpeed(); @@ -239,7 +239,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) if (TRACE_uncategorized()){ simgrid::instr::Type* speed_used = container->type_->getChildOrNull("power_used"); if (speed_used == nullptr){ - simgrid::instr::Type::variableNew("power_used", "0.5 0.5 0.5", container->type_); + container->type_->addVariableType("power_used", "0.5 0.5 0.5"); } } @@ -247,7 +247,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) simgrid::instr::Type* mpi = container->type_->getChildOrNull("MPI"); if (mpi == nullptr){ mpi = simgrid::instr::Type::containerNew("MPI", container->type_); - simgrid::instr::Type::stateNew("MPI_STATE", mpi); + mpi->addStateType("MPI_STATE"); } } @@ -255,14 +255,14 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) simgrid::instr::Type* msg_process = container->type_->getChildOrNull("MSG_PROCESS"); if (msg_process == nullptr){ msg_process = simgrid::instr::Type::containerNew("MSG_PROCESS", container->type_); - simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_PROCESS_STATE", msg_process); + simgrid::instr::Type* state = msg_process->addStateType("MSG_PROCESS_STATE"); simgrid::instr::Value::byNameOrCreate("suspend", "1 0 1", state); simgrid::instr::Value::byNameOrCreate("sleep", "1 1 0", state); simgrid::instr::Value::byNameOrCreate("receive", "1 0 0", state); simgrid::instr::Value::byNameOrCreate("send", "0 0 1", state); simgrid::instr::Value::byNameOrCreate("task_execute", "0 1 1", state); - simgrid::instr::Type::linkNew("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process); - simgrid::instr::Type::linkNew("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process); + PJ_type_get_root()->addLinkType("MSG_PROCESS_LINK", msg_process, msg_process); + PJ_type_get_root()->addLinkType("MSG_PROCESS_TASK_LINK", msg_process, msg_process); } } @@ -270,14 +270,14 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) simgrid::instr::Type* msg_vm = container->type_->getChildOrNull("MSG_VM"); if (msg_vm == nullptr){ msg_vm = simgrid::instr::Type::containerNew("MSG_VM", container->type_); - simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_VM_STATE", msg_vm); + simgrid::instr::Type* state = msg_vm->addStateType("MSG_VM_STATE"); simgrid::instr::Value::byNameOrCreate("suspend", "1 0 1", state); simgrid::instr::Value::byNameOrCreate("sleep", "1 1 0", state); simgrid::instr::Value::byNameOrCreate("receive", "1 0 0", state); simgrid::instr::Value::byNameOrCreate("send", "0 0 1", state); simgrid::instr::Value::byNameOrCreate("task_execute", "0 1 1", state); - simgrid::instr::Type::linkNew("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm); - simgrid::instr::Type::linkNew("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm); + PJ_type_get_root()->addLinkType("MSG_VM_LINK", msg_vm, msg_vm); + PJ_type_get_root()->addLinkType("MSG_VM_PROCESS_LINK", msg_vm, msg_vm); } } } @@ -323,22 +323,12 @@ void instr_routing_define_callbacks () */ static void recursiveNewVariableType(const char* new_typename, const char* color, simgrid::instr::Type* root) { + if (root->getName() == "HOST" || root->getName() == "MSG_VM") + root->addVariableType(std::string("p") + new_typename, color == nullptr ? "" : color); + + if (root->getName() == "LINK") + root->addVariableType(std::string("b") + new_typename, color == nullptr ? "" : color); - 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 (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 (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); - } for (auto elm : root->children_) { recursiveNewVariableType(new_typename, color == nullptr ? "" : color, elm.second); } @@ -353,7 +343,7 @@ static void recursiveNewUserVariableType(const char* father_type, const char* ne simgrid::instr::Type* root) { if (root->getName() == father_type) { - simgrid::instr::Type::variableNew(new_typename, color == nullptr ? "" : color, root); + root->addVariableType(new_typename, color == nullptr ? "" : color); } for (auto elm : root->children_) recursiveNewUserVariableType(father_type, new_typename, color, elm.second); @@ -367,7 +357,7 @@ void instr_new_user_variable_type (const char *father_type, const char *new_typ static void recursiveNewUserStateType(const char* father_type, const char* new_typename, simgrid::instr::Type* root) { if (root->getName() == father_type) { - simgrid::instr::Type::stateNew(new_typename, root); + root->addStateType(new_typename); } for (auto elm : root->children_) recursiveNewUserStateType(father_type, new_typename, elm.second);