From 62dcd7bdc99162b0675bbc9100a36b53ebe65f29 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 23 Dec 2015 09:44:53 +0100 Subject: [PATCH] cosmetics in Storage --- src/surf/sg_platf.cpp | 16 ++++------------ src/surf/storage_interface.cpp | 19 ++++++------------- src/surf/storage_interface.hpp | 10 +++++----- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 208484b51b..2006197702 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -140,13 +140,10 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster) void sg_platf_new_storage(sg_platf_storage_cbarg_t storage) { xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL), - "Reading a storage, processing unit \"%s\" already exists", storage->id); + "Refusing to add a second storage named \"%s\"", storage->id); - // Verification of an existing type_id -#ifndef NDEBUG - void* storage_type = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL); -#endif - xbt_assert(storage_type,"Reading a storage, type id \"%s\" does not exists", storage->type_id); + void* stype = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL); + xbt_assert(stype,"No storage type '%s'", storage->type_id); XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'", storage->id, @@ -158,12 +155,7 @@ void sg_platf_new_storage(sg_platf_storage_cbarg_t storage) ROUTING_STORAGE_LEVEL, (void *) xbt_strdup(storage->type_id)); - void* stype = xbt_lib_get_or_null(storage_type_lib, - storage->type_id, - ROUTING_STORAGE_TYPE_LEVEL); - if(!stype) xbt_die("No storage type '%s'",storage->type_id); - - // if storage content is not specified use the content of storage_type if exist + // if storage content is not specified use the content of storage_type if any if(!strcmp(storage->content,"") && strcmp(((storage_type_t) stype)->content,"")){ storage->content = ((storage_type_t) stype)->content; storage->content_type = ((storage_type_t) stype)->content_type; diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index d4479cfe66..4023e0279c 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -56,11 +56,11 @@ StorageModel::~StorageModel(){ ************/ Storage::Storage(Model *model, const char *name, xbt_dict_t props, - const char* type_id, char *content_name, char *content_type, + const char* type_id, const char *content_name, const char *content_type, sg_size_t size) : Resource(model, name) , PropertyHolder(props) - , p_contentType(content_type) + , p_contentType(xbt_strdup(content_type)) , m_size(size), m_usedSize(0) , p_typeId(xbt_strdup(type_id)) , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) @@ -71,18 +71,11 @@ Storage::Storage(Model *model, const char *name, xbt_dict_t props, 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, char *content_name, - char *content_type, sg_size_t size, char *attach) - : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection)) - , PropertyHolder(props) - , p_contentType(content_type) - , m_size(size), m_usedSize(0) - , p_typeId(xbt_strdup(type_id)) - , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) + double bconnection, const char* type_id, const char *content_name, + const char *content_type, sg_size_t size, const char *attach) + : Storage(model, name, props, type_id, content_name, content_type, size) { - p_content = parseContent(content_name); p_attach = xbt_strdup(attach); - setState(SURF_RESOURCE_ON); XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size); p_constraintRead = lmm_constraint_new(maxminSystem, this, bread); p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite); @@ -97,7 +90,7 @@ Storage::~Storage(){ free(p_attach); } -xbt_dict_t Storage::parseContent(char *filename) +xbt_dict_t Storage::parseContent(const char *filename) { m_usedSize = 0; if ((!filename) || (strcmp(filename, "") == 0)) diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index a449ac935a..631299e9f2 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -109,7 +109,7 @@ public: * @param size [description] */ Storage(Model *model, const char *name, xbt_dict_t props, - const char* type_id, char *content_name, char *content_type, + const char* type_id, const char *content_name, const char *content_type, sg_size_t size); /** @@ -131,8 +131,8 @@ public: Storage(Model *model, const char *name, xbt_dict_t props, lmm_system_t maxminSystem, double bread, double bwrite, double bconnection, - const char* type_id, char *content_name, char *content_type, - sg_size_t size, char *attach); + const char* type_id, const char *content_name, const char *content_type, + sg_size_t size, const char *attach); ~Storage(); @@ -155,7 +155,7 @@ public: sg_size_t m_size; sg_size_t m_usedSize; char * p_typeId; - char* p_attach; + char* p_attach; //FIXME: this is the name of the host. Use the host directly /** * @brief Open a file @@ -222,7 +222,7 @@ public: virtual sg_size_t getUsedSize(); - xbt_dict_t parseContent(char *filename); + xbt_dict_t parseContent(const char *filename); xbt_dynar_t p_writeActions; -- 2.20.1