Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dict to map for storage model properties
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 26 Mar 2017 13:31:59 +0000 (15:31 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 26 Mar 2017 13:31:59 +0000 (15:31 +0200)
src/include/surf/surf.h
src/surf/storage_interface.hpp
src/surf/storage_n11.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp

index 8e0fe1f..665dbb8 100644 (file)
@@ -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);
index b1d56c7..b872646 100644 (file)
@@ -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<std::string, std::string>* 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;
index 5e3b24b..31b8fe3 100644 (file)
@@ -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);
index 3e0cfe6..9768c00 100644 (file)
@@ -11,8 +11,9 @@
 
 #include "simgrid/host.h"
 #include "src/surf/xml/platf.hpp"
-#include <vector>
+#include <map>
 #include <string>
+#include <vector>
 
 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<std::string, std::string>* model_properties;
   sg_size_t size;
 } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
 
index 44f8c1d..b0c48e4 100644 (file)
@@ -296,7 +296,7 @@ static std::vector<double> 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<std::string, std::string>* 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<std::string, std::string>();
 
-  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 */}