From 2d0e2d7e6947278ab1bafd1cad44ecd78416c79c Mon Sep 17 00:00:00 2001 From: Takishipp Date: Wed, 16 Aug 2017 12:06:33 +0200 Subject: [PATCH] Add a constructor to s_type class --- src/instr/instr_paje_types.cpp | 32 +++++++++++++++----------------- src/instr/instr_private.h | 1 + 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 792fc4ce5e..a4df7a2b3d 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -20,29 +20,27 @@ type_t PJ_type_get_root () return rootType; } -static type_t newType (const char *typeNameBuff, const char *key, const char *color, e_entity_types kind, type_t father) +s_type::s_type (const char *typeNameBuff, const char *key, const char *color, e_entity_types kind, type_t father) { if (typeNameBuff == nullptr || key == nullptr){ THROWF(tracing_error, 0, "can't create a new type with name or key equal nullptr"); } - type_t ret = xbt_new0(s_type, 1); - ret->name = xbt_strdup (typeNameBuff); - ret->father = father; - ret->kind = kind; - ret->children = xbt_dict_new_homogeneous(nullptr); - ret->values = xbt_dict_new_homogeneous(nullptr); - ret->color = xbt_strdup (color); + this->name = xbt_strdup (typeNameBuff); + this->father = father; + this->kind = kind; + this->children = xbt_dict_new_homogeneous(nullptr); + this->values = xbt_dict_new_homogeneous(nullptr); + this->color = xbt_strdup (color); char str_id[INSTR_DEFAULT_STR_SIZE]; snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id()); - ret->id = xbt_strdup (str_id); + this->id = xbt_strdup (str_id); if (father != nullptr){ - xbt_dict_set (father->children, key, ret, nullptr); + xbt_dict_set (father->children, key, this, nullptr); XBT_DEBUG("new type %s, child of %s", typeNameBuff, father->name); } - return ret; } void PJ_type_free (type_t type) @@ -112,7 +110,7 @@ type_t PJ_type_container_new (const char *name, type_t father) THROWF (tracing_error, 0, "can't create a container type with a nullptr name"); } - type_t ret = newType(name, name, nullptr, TYPE_CONTAINER, father); + type_t ret = new s_type (name, name, nullptr, TYPE_CONTAINER, father); if (father == nullptr) { rootType = ret; } else { @@ -128,7 +126,7 @@ type_t PJ_type_event_new (const char *name, type_t father) THROWF (tracing_error, 0, "can't create an event type with a nullptr name"); } - type_t ret = newType (name, name, nullptr, TYPE_EVENT, father); + type_t ret = new s_type (name, name, nullptr, TYPE_EVENT, father); XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); LogDefineEventType(ret); return ret; @@ -144,9 +142,9 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father) if (not color) { char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1"; - ret = newType (name, name, white, TYPE_VARIABLE, father); + ret = new s_type (name, name, white, TYPE_VARIABLE, father); }else{ - ret = newType (name, name, color, TYPE_VARIABLE, father); + ret = new s_type (name, name, color, TYPE_VARIABLE, father); } XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); LogVariableTypeDefinition (ret); @@ -163,7 +161,7 @@ type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t char key[INSTR_DEFAULT_STR_SIZE]; snprintf (key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", name, source->id, dest->id); - ret = newType (name, key, nullptr, TYPE_LINK, father); + ret = new s_type (name, key, nullptr, 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); LogLinkTypeDefinition(ret, source, dest); @@ -178,7 +176,7 @@ type_t PJ_type_state_new (const char *name, type_t father) type_t ret = nullptr; - ret = newType (name, name, nullptr, TYPE_STATE, father); + ret = new s_type (name, name, nullptr, TYPE_STATE, father); XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); LogStateTypeDefinition(ret); return ret; diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index e8e38d4536..bedae27a32 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -73,6 +73,7 @@ class s_type : public ess_type { s_type *father; xbt_dict_t children; xbt_dict_t values; //valid for all types except variable and container + s_type (const char *typeNameBuff, const char *key, const char *color, e_entity_types kind, type_t father); }; //-------------------------------------------------- -- 2.20.1