Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
don't pass property set to the storage constructor, there is no need
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 13 Nov 2016 10:42:28 +0000 (11:42 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 13 Nov 2016 10:42:28 +0000 (11:42 +0100)
src/surf/HostImpl.hpp
src/surf/sg_platf.cpp
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp
src/surf/storage_n11.cpp
src/surf/storage_n11.hpp

index 21908ea..b727ce9 100644 (file)
@@ -66,15 +66,7 @@ public:
 class HostImpl : public simgrid::surf::PropertyHolder {
 
 public:
-  /**
-   * @brief Host constructor
-   *
-   * @param storage The Storage associated to this Host
-   */
   HostImpl(s4u::Host* host, xbt_dynar_t storage);
-
-  /* Host destruction logic */
-  /**************************/
   virtual ~HostImpl();
 
 public:
index 1a9eee7..82dde2f 100644 (file)
@@ -415,12 +415,16 @@ void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
       storage->content_type,
     storage->properties);
 
-  surf_storage_model->createStorage(storage->id,
-                                     ((storage_type_t) stype)->type_id,
-                                     storage->content,
-                                     storage->content_type,
-                   storage->properties,
-                                     storage->attach);
+  auto s = surf_storage_model->createStorage(storage->id, ((storage_type_t)stype)->type_id, storage->content,
+                                             storage->content_type, storage->attach);
+
+  if (storage->properties) {
+    xbt_dict_cursor_t cursor = nullptr;
+    char *key, *data;
+    xbt_dict_foreach (storage->properties, cursor, key, data)
+      s->setProperty(key, data);
+    xbt_dict_free(&storage->properties);
+  }
 }
 void sg_platf_new_storage_type(sg_platf_storage_type_cbarg_t storage_type){
 
index c2ae47c..26fd112 100644 (file)
@@ -49,16 +49,16 @@ StorageModel::~StorageModel(){
  * Resource *
  ************/
 
-Storage::Storage(Model *model, const char *name, xbt_dict_t props,
-                 lmm_system_t maxminSystem, double bread, double bwrite,
-                 double bconnection, const char* type_id, const char *content_name,
-                 const char *content_type, sg_size_t size, const char *attach)
: Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
, PropertyHolder(props)
, contentType_(xbt_strdup(content_type))
, size_(size), usedSize_(0)
- , typeId_(xbt_strdup(type_id))
- , writeActions_(std::vector<StorageAction*>())
+Storage::Storage(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
+                 double bconnection, const char* type_id, const char* content_name, const char* content_type,
+                 sg_size_t size, const char* attach)
+    : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
   , PropertyHolder(nullptr)
   , contentType_(xbt_strdup(content_type))
   , size_(size)
   , usedSize_(0)
   , typeId_(xbt_strdup(type_id))
   , writeActions_(std::vector<StorageAction*>())
 {
   content_ = parseContent(content_name);
   attach_ = xbt_strdup(attach);
index e271c9b..e2b39ef 100644 (file)
@@ -64,9 +64,8 @@ public:
   StorageModel();
   ~StorageModel();
 
-  virtual Storage *createStorage(const char* id, const char* type_id,
-                                 const char* content_name, const char* content_type,
-                                 xbt_dict_t properties, const char *attach) = 0;
+  virtual Storage* createStorage(const char* id, const char* type_id, const char* content_name,
+                                 const char* content_type, const char* attach) = 0;
 
   std::vector<Storage*> p_storageList;
 };
@@ -89,11 +88,8 @@ public:
    * @param name The name of the Storage
    * @param props Dictionary of properties associated to this Storage
    */
-  Storage(Model *model, const char *name, xbt_dict_t props,
-          lmm_system_t maxminSystem, double bread, double bwrite,
-          double bconnection,
-          const char* type_id, const char *content_name, const char *content_type,
-          sg_size_t size, const char *attach);
+  Storage(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
+          const char* type_id, const char* content_name, const char* content_type, sg_size_t size, const char* attach);
 
   ~Storage();
 
index 9ed638d..a986fe4 100644 (file)
@@ -61,8 +61,8 @@ namespace simgrid {
 namespace surf {
 
 #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area
-Storage *StorageN11Model::createStorage(const char* id, const char* type_id,
-    const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach)
+Storage* StorageN11Model::createStorage(const char* id, const char* type_id, const char* content_name,
+                                        const char* content_type, const char* attach)
 {
 
   xbt_assert(!surf_storage_resource_priv(surf_storage_resource_by_name(id)),
@@ -77,14 +77,12 @@ Storage *StorageN11Model::createStorage(const char* id, const char* type_id,
   double Bconnection   = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bconnection"),
       "property Bconnection, storage",type_id);
 
-  Storage *storage = new StorageN11(this, id, properties, maxminSystem_,
-      Bread, Bwrite, Bconnection, type_id, (char *)content_name,
-      content_type, storage_type->size, (char *) attach);
+  Storage* storage = new StorageN11(this, id, maxminSystem_, Bread, Bwrite, Bconnection, type_id, (char*)content_name,
+                                    content_type, storage_type->size, (char*)attach);
   storageCreatedCallbacks(storage);
   xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
 
-  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tproperties '%p'\n\t\tBread '%f'\n",
-      id, type_id, properties, Bread);
+  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tBread '%f'\n", id, type_id, Bread);
 
   p_storageList.push_back(storage);
 
@@ -167,12 +165,11 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
  * Resource *
  ************/
 
-StorageN11::StorageN11(StorageModel *model, const char* name,
-    xbt_dict_t properties, lmm_system_t maxminSystem, double bread,
-    double bwrite, double bconnection, const char* type_id, char *content_name,
-    const char *content_type, sg_size_t size, char *attach)
-: Storage(model, name, properties,
-    maxminSystem, bread, bwrite, bconnection, type_id, content_name, content_type, size, attach) {
+StorageN11::StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
+                       double bconnection, const char* type_id, char* content_name, const char* content_type,
+                       sg_size_t size, char* attach)
+    : Storage(model, name, maxminSystem, bread, bwrite, bconnection, type_id, content_name, content_type, size, attach)
+{
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
 }
 
index 04f6f0c..3a12eee 100644 (file)
@@ -28,8 +28,8 @@ class XBT_PRIVATE StorageN11Action;
 
 class StorageN11Model : public StorageModel {
 public:
-  Storage *createStorage(const char* id, const char* type_id,
-       const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach) override;
+  Storage* createStorage(const char* id, const char* type_id, const char* content_name, const char* content_type,
+                         const char* attach) override;
   double nextOccuringEvent(double now) override;
   void updateActionsState(double now, double delta) override;
 };
@@ -40,15 +40,15 @@ public:
 
 class StorageN11 : public Storage {
 public:
-  StorageN11(StorageModel *model, const char* name, xbt_dict_t properties,
-         lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
-         const char* type_id, char *content_name, const char *content_type, sg_size_t size, char *attach);
+  StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
+             double bconnection, const char* type_id, char* content_name, const char* content_type, sg_size_t size,
+             char* attach);
 
   StorageAction *open(const char* mount, const char* path);
   StorageAction *close(surf_file_t fd);
   StorageAction *ls(const char *path);
-  StorageAction *read(surf_file_t fd, sg_size_t size); //FIXME:why we have a useless param  *??
-  StorageAction *write(surf_file_t fd, sg_size_t size);//FIXME:why we have a useless param  *??
+  StorageAction* read(surf_file_t fd, sg_size_t size);
+  StorageAction* write(surf_file_t fd, sg_size_t size);
   void rename(const char *src, const char *dest);
 };