From: Frederic Suter Date: Sun, 26 Mar 2017 13:31:59 +0000 (+0200) Subject: dict to map for storage model properties X-Git-Tag: v3.16~446 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7e514459de04ede1aaa32d4c4dfd6397e805ed07 dict to map for storage model properties --- diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 8e0fe1f00c..665dbb8ef0 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -607,8 +607,6 @@ XBT_PUBLIC(void) surf_exit(); /* Prototypes of the functions that handle the properties */ XBT_PUBLIC_DATA(xbt_dict_t) current_property_set;// the prop set for the currently parsed element (also used in SIMIX) -/* The same for model_prop set*/ -XBT_PUBLIC_DATA(xbt_dict_t) current_model_property_set; /* surf parse file related (public because called from a test suite) */ XBT_PUBLIC(void) parse_platform_file(const char *file); diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index b1d56c76e3..b872646c0a 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -236,14 +236,16 @@ typedef struct s_storage_type { char *content_type; char *type_id; xbt_dict_t properties; - xbt_dict_t model_properties; + std::map* model_properties; sg_size_t size; -} s_storage_type_t, *storage_type_t; +} s_storage_type_t; +typedef s_storage_type_t* storage_type_t; typedef struct s_mount { void *storage; char *name; -} s_mount_t, *mount_t; +} s_mount_t; +typedef s_mount_t* mount_t; typedef struct surf_file { char *name; diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 5e3b24b9f5..31b8fe3863 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -24,7 +24,7 @@ static inline void routing_storage_type_free(void *r) free(stype->content); free(stype->content_type); xbt_dict_free(&(stype->properties)); - xbt_dict_free(&(stype->model_properties)); + delete stype->model_properties; free(stype); } @@ -76,14 +76,15 @@ Storage* StorageN11Model::createStorage(const char* id, const char* type_id, con xbt_assert(!surf_storage_resource_priv(surf_storage_resource_by_name(id)), "Storage '%s' declared several times in the platform file", id); - storage_type_t storage_type = (storage_type_t) xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL); + storage_type_t storage_type = + (storage_type_t)xbt_lib_get_or_null(storage_type_lib, type_id, ROUTING_STORAGE_TYPE_LEVEL); - double Bread = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bread"), - "property Bread, storage",type_id); - double Bwrite = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bwrite"), - "property Bwrite, storage",type_id); - double Bconnection = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bconnection"), - "property Bconnection, storage",type_id); + double Bread = + surf_parse_get_bandwidth(storage_type->model_properties->at("Bread").c_str(), "property Bread, storage", type_id); + double Bwrite = surf_parse_get_bandwidth(storage_type->model_properties->at("Bwrite").c_str(), + "property Bwrite, storage", type_id); + double Bconnection = surf_parse_get_bandwidth(storage_type->model_properties->at("Bconnection").c_str(), + "property Bconnection, storage", type_id); Storage* storage = new StorageN11(this, id, maxminSystem_, Bread, Bwrite, Bconnection, type_id, (char*)content_name, content_type, storage_type->size, (char*)attach); diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index 3e0cfe68ed..9768c00699 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -11,8 +11,9 @@ #include "simgrid/host.h" #include "src/surf/xml/platf.hpp" -#include +#include #include +#include SG_BEGIN_DECL() #include "src/surf/xml/simgrid_dtd.h" @@ -139,7 +140,7 @@ typedef struct { const char* content; const char* content_type; xbt_dict_t properties; - xbt_dict_t model_properties; + std::map* model_properties; sg_size_t size; } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t; diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 44f8c1d36e..b0c48e4f73 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -296,7 +296,7 @@ static std::vector surf_parse_get_all_speeds(char* speeds, const char* e /* The default current property receiver. Setup in the corresponding opening callbacks. */ xbt_dict_t current_property_set = nullptr; -xbt_dict_t current_model_property_set = nullptr; +std::map* current_model_property_set = nullptr; int AS_TAG = 0; // Whether we just opened an AS tag (to see what to do with the properties) /* dictionary of random generator data */ @@ -984,9 +984,10 @@ void STag_surfxml_argument(){ void STag_surfxml_model___prop(){ if (!current_model_property_set) - current_model_property_set = xbt_dict_new_homogeneous(xbt_free_f); + current_model_property_set = new std::map(); - xbt_dict_set(current_model_property_set, A_surfxml_model___prop_id, xbt_strdup(A_surfxml_model___prop_value), nullptr); + current_model_property_set->insert( + {std::string(A_surfxml_model___prop_id), std::string(A_surfxml_model___prop_value)}); } void ETag_surfxml_prop(){/* Nothing to do */}