From: Martin Quinson Date: Sun, 13 Nov 2016 10:42:28 +0000 (+0100) Subject: don't pass property set to the storage constructor, there is no need X-Git-Tag: v3_14~214 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ddc2e5141b85593da4b84cc214674e68c6b49e27 don't pass property set to the storage constructor, there is no need --- diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 21908ea70c..b727ce945c 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -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: diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 1a9eee7c01..82dde2f05d 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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){ diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index c2ae47cc57..26fd1126a8 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -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()) +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()) { content_ = parseContent(content_name); attach_ = xbt_strdup(attach); diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index e271c9b87d..e2b39efafc 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -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 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(); diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 9ed638d3ba..a986fe426d 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -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); } diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index 04f6f0c3cb..3a12eee2a5 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -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); };