From: Frederic Suter Date: Wed, 24 May 2017 14:15:16 +0000 (+0200) Subject: simgrid::surf::Storage => simgrid::surf::StorageImpl X-Git-Tag: v3.16~219 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/66f8d6364c9d16e5ba469db4c93d98da40ae007a simgrid::surf::Storage => simgrid::surf::StorageImpl this avoids confusion with simgrid::s4u::Storage --- diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 628f1e5e7d..8ae6a89cd4 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -35,7 +35,7 @@ namespace simgrid { class Cpu; class LinkImpl; class HostImpl; - class Storage; + class StorageImpl; } namespace trace_mgr { class trace; diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 09941a4c09..4a3c1094ba 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -16,7 +16,6 @@ #include "surf/surf_routing.h" #include "surf/datatypes.h" #include "xbt/lib.h" -#include "surf/surf_routing.h" #include "simgrid/datatypes.h" #include "simgrid/forward.h" @@ -52,7 +51,7 @@ typedef simgrid::surf::CpuModel surf_CpuModel; typedef simgrid::surf::Cpu surf_Cpu; typedef simgrid::surf::HostModel surf_HostModel; typedef simgrid::surf::NetworkModel surf_NetworkModel; -typedef simgrid::surf::Storage surf_Storage; +typedef simgrid::surf::StorageImpl surf_Storage; typedef simgrid::surf::StorageModel surf_StorageModel; typedef simgrid::surf::Resource surf_Resource; typedef simgrid::surf::HostImpl surf_Host; @@ -65,7 +64,7 @@ typedef struct surf_CpuModel surf_CpuModel; typedef struct surf_Cpu surf_Cpu; typedef struct surf_HostModel surf_HostModel; typedef struct surf_NetworkModel surf_NetworkModel; -typedef struct surf_Storage surf_Storage; +typedef struct surf_StorageImpl surf_Storage; typedef struct surf_StorageModel surf_StorageModel; typedef struct surf_Resource surf_Resource; typedef struct surf_Host surf_Host; diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index 2331428610..ef67c5befd 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -3,9 +3,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "../surf/StorageImpl.hpp" #include "simgrid/s4u/Host.hpp" #include "src/msg/msg_private.h" -#include "src/surf/storage_interface.hpp" #include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg, "Logging specific to MSG (io)"); diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index ba1820b07a..d010801b6c 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -3,9 +3,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "../surf/StorageImpl.hpp" #include "simgrid/s4u/Storage.hpp" #include "simgrid/simix.hpp" -#include "src/surf/storage_interface.hpp" #include "xbt/lib.h" #include diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 25c861ecd0..8fc4bcac57 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -16,13 +16,14 @@ #include "simgrid/s4u/Host.hpp" #include "src/surf/surf_interface.hpp" -#include "src/surf/storage_interface.hpp" #include "src/surf/xml/platf.hpp" #include "smx_private.h" #include "xbt/ex.h" /* ex_backtrace_display */ + #include "mc/mc.h" -#include "src/mc/mc_replay.h" #include "simgrid/sg_config.h" +#include "src/mc/mc_replay.h" +#include "src/surf/StorageImpl.hpp" #include "src/smpi/smpi_process.hpp" @@ -233,7 +234,7 @@ void SIMIX_global_init(int *argc, char **argv) host.extension_set(new simgrid::simix::Host()); }); - simgrid::surf::storageCreatedCallbacks.connect([](simgrid::surf::Storage* storage) { + simgrid::surf::storageCreatedCallbacks.connect([](simgrid::surf::StorageImpl* storage) { const char* name = storage->cname(); // TODO, create sg_storage_by_name sg_storage_t s = xbt_lib_get_elm_or_null(storage_lib, name); diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index 48e0d3667a..b8ca1e8dd9 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -106,7 +106,7 @@ HostImpl::HostImpl(s4u::Host* host) : piface_(host) piface_->pimpl_ = this; } -simgrid::surf::Storage* HostImpl::findStorageOnMountList(const char* mount) +simgrid::surf::StorageImpl* HostImpl::findStorageOnMountList(const char* mount) { XBT_DEBUG("Search for storage name '%s' on '%s'", mount, piface_->cname()); if (storage_.find(mount) == storage_.end()) @@ -135,7 +135,7 @@ void HostImpl::getAttachedStorageList(std::vector* storages) xbt_lib_foreach(storage_lib, cursor, key, data) { if (xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) { - simgrid::surf::Storage* storage = static_cast( + simgrid::surf::StorageImpl* storage = static_cast( xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL)); if (not strcmp(static_cast(storage->attach_), piface_->cname())) { storages->push_back(storage->cname()); @@ -146,7 +146,7 @@ void HostImpl::getAttachedStorageList(std::vector* storages) Action* HostImpl::open(const char* fullpath) { - simgrid::surf::Storage* st = nullptr; + simgrid::surf::StorageImpl* st = nullptr; size_t longest_prefix_length = 0; std::string path; std::string mount_name; @@ -175,21 +175,21 @@ Action* HostImpl::open(const char* fullpath) Action* HostImpl::close(surf_file_t fd) { - simgrid::surf::Storage* st = findStorageOnMountList(fd->mount); + simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount); XBT_DEBUG("CLOSE %s on disk '%s'", fd->name, st->cname()); return st->close(fd); } Action* HostImpl::read(surf_file_t fd, sg_size_t size) { - simgrid::surf::Storage* st = findStorageOnMountList(fd->mount); + simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount); XBT_DEBUG("READ %s on disk '%s'", fd->name, st->cname()); return st->read(fd, size); } Action* HostImpl::write(surf_file_t fd, sg_size_t size) { - simgrid::surf::Storage* st = findStorageOnMountList(fd->mount); + simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount); XBT_DEBUG("WRITE %s on disk '%s'", fd->name, st->cname()); return st->write(fd, size); } @@ -201,7 +201,7 @@ int HostImpl::unlink(surf_file_t fd) return -1; } else { - simgrid::surf::Storage* st = findStorageOnMountList(fd->mount); + simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount); /* Check if the file is on this storage */ if (st->content_->find(fd->name) == st->content_->end()) { XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name, st->cname()); @@ -230,7 +230,7 @@ sg_size_t HostImpl::getSize(surf_file_t fd) xbt_dynar_t HostImpl::getInfo(surf_file_t fd) { - simgrid::surf::Storage* st = findStorageOnMountList(fd->mount); + simgrid::surf::StorageImpl* st = findStorageOnMountList(fd->mount); sg_size_t* psize = xbt_new(sg_size_t, 1); *psize = fd->size; xbt_dynar_t info = xbt_dynar_new(sizeof(void*), nullptr); diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index 12287e32f0..4d7c3ea990 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -4,11 +4,11 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "surf_interface.hpp" -#include "storage_interface.hpp" #include "cpu_interface.hpp" #include "network_interface.hpp" #include "src/surf/PropertyHolder.hpp" +#include "StorageImpl.hpp" #include #ifndef SURF_HOST_INTERFACE_HPP_ @@ -67,7 +67,7 @@ public: virtual ~HostImpl() = default; /** @brief Return the storage of corresponding mount point */ - virtual simgrid::surf::Storage* findStorageOnMountList(const char* storage); + virtual simgrid::surf::StorageImpl* findStorageOnMountList(const char* storage); /** @brief Get the xbt_dict_t of mount_point: Storage */ virtual xbt_dict_t getMountedStorageList(); @@ -173,7 +173,7 @@ public: */ virtual int fileMove(surf_file_t fd, const char* fullpath); - std::map storage_; + std::map storage_; simgrid::s4u::Host* piface_ = nullptr; simgrid::s4u::Host* getHost() { return piface_; } diff --git a/src/surf/storage_interface.cpp b/src/surf/StorageImpl.cpp similarity index 73% rename from src/surf/storage_interface.cpp rename to src/surf/StorageImpl.cpp index d0c8e8f98d..3eb9910a3d 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/StorageImpl.cpp @@ -4,7 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "storage_interface.hpp" +#include "StorageImpl.hpp" + #include "surf_private.h" #include #include @@ -14,9 +15,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module"); xbt_lib_t storage_lib; -int MSG_STORAGE_LEVEL = -1; // Msg storage level -int SURF_STORAGE_LEVEL = -1; -simgrid::surf::StorageModel *surf_storage_model = nullptr; +int MSG_STORAGE_LEVEL = -1; // Msg storage level +int SURF_STORAGE_LEVEL = -1; +simgrid::surf::StorageModel* surf_storage_model = nullptr; namespace simgrid { namespace surf { @@ -25,21 +26,22 @@ namespace surf { * Callbacks * *************/ -simgrid::xbt::signal storageCreatedCallbacks; -simgrid::xbt::signal storageDestructedCallbacks; -simgrid::xbt::signal storageStateChangedCallbacks; // signature: wasOn, isOn +simgrid::xbt::signal storageCreatedCallbacks; +simgrid::xbt::signal storageDestructedCallbacks; +simgrid::xbt::signal storageStateChangedCallbacks; // signature: wasOn, isOn simgrid::xbt::signal storageActionStateChangedCallbacks; /********* * Model * *********/ -StorageModel::StorageModel(): Model() +StorageModel::StorageModel() : Model() { maxminSystem_ = lmm_system_new(true /* lazy update */); } -StorageModel::~StorageModel(){ +StorageModel::~StorageModel() +{ lmm_system_free(maxminSystem_); surf_storage_model = nullptr; } @@ -48,8 +50,8 @@ StorageModel::~StorageModel(){ * Resource * ************/ -Storage::Storage(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite, - const char* type_id, const char* content_name, sg_size_t size, const char* attach) +StorageImpl::StorageImpl(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite, + const char* type_id, const char* content_name, sg_size_t size, const char* attach) : Resource(model, name, lmm_constraint_new(maxminSystem, this, MAX(bread, bwrite))) , size_(size) , usedSize_(0) @@ -64,7 +66,8 @@ Storage::Storage(Model* model, const char* name, lmm_system_t maxminSystem, doub constraintWrite_ = lmm_constraint_new(maxminSystem, this, bwrite); } -Storage::~Storage(){ +StorageImpl::~StorageImpl() +{ storageDestructedCallbacks(this); if (content_ != nullptr) { for (auto entry : *content_) @@ -75,7 +78,7 @@ Storage::~Storage(){ free(attach_); } -std::map* Storage::parseContent(const char* filename) +std::map* StorageImpl::parseContent(const char* filename) { usedSize_ = 0; if ((not filename) || (strcmp(filename, "") == 0)) @@ -97,7 +100,7 @@ std::map* Storage::parseContent(const char* filename) usedSize_ += size; sg_size_t* psize = new sg_size_t; - *psize = size; + *psize = size; parse_content->insert({tokens.front(), psize}); } } while (not fs->eof()); @@ -105,66 +108,70 @@ std::map* Storage::parseContent(const char* filename) return parse_content; } -bool Storage::isUsed() +bool StorageImpl::isUsed() { THROW_UNIMPLEMENTED; return false; } -void Storage::apply_event(tmgr_trace_event_t /*event*/, double /*value*/) +void StorageImpl::apply_event(tmgr_trace_event_t /*event*/, double /*value*/) { THROW_UNIMPLEMENTED; } -void Storage::turnOn() { +void StorageImpl::turnOn() +{ if (isOff()) { Resource::turnOn(); storageStateChangedCallbacks(this, 0, 1); } } -void Storage::turnOff() { +void StorageImpl::turnOff() +{ if (isOn()) { Resource::turnOff(); storageStateChangedCallbacks(this, 1, 0); } } -std::map* Storage::getContent() +std::map* StorageImpl::getContent() { /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */ return content_; } -sg_size_t Storage::getFreeSize(){ +sg_size_t StorageImpl::getFreeSize() +{ return size_ - usedSize_; } -sg_size_t Storage::getUsedSize(){ +sg_size_t StorageImpl::getUsedSize() +{ return usedSize_; } /********** * Action * **********/ -StorageAction::StorageAction(Model* model, double cost, bool failed, Storage* storage, +StorageAction::StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type) : Action(model, cost, failed), type_(type), storage_(storage), file_(nullptr) { progress_ = 0; }; -StorageAction::StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, Storage* storage, +StorageAction::StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage, e_surf_action_storage_type_t type) : Action(model, cost, failed, var), type_(type), storage_(storage), file_(nullptr) { progress_ = 0; } -void StorageAction::setState(Action::State state){ +void StorageAction::setState(Action::State state) +{ Action::State old = getState(); Action::setState(state); storageActionStateChangedCallbacks(this, old, state); } - } } diff --git a/src/surf/storage_interface.hpp b/src/surf/StorageImpl.hpp similarity index 67% rename from src/surf/storage_interface.hpp rename to src/surf/StorageImpl.hpp index 9e79f47658..b02503e94e 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/StorageImpl.hpp @@ -31,25 +31,29 @@ class StorageAction; * @brief Callbacks handler which emit the callbacks after Storage creation * * @details Callback functions have the following signature: `void(Storage*)` */ -XBT_PUBLIC_DATA(simgrid::xbt::signal) storageCreatedCallbacks; +XBT_PUBLIC_DATA(simgrid::xbt::signal) storageCreatedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Storage destruction * * @details Callback functions have the following signature: `void(StoragePtr)` */ -XBT_PUBLIC_DATA(simgrid::xbt::signal) storageDestructedCallbacks; +XBT_PUBLIC_DATA(simgrid::xbt::signal) storageDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Storage State changed * - * @details Callback functions have the following signature: `void(StorageAction *action, int previouslyOn, int currentlyOn)` + * @details Callback functions have the following signature: `void(StorageAction *action, int previouslyOn, int + * currentlyOn)` */ -XBT_PUBLIC_DATA(simgrid::xbt::signal) storageStateChangedCallbacks; +XBT_PUBLIC_DATA(simgrid::xbt::signal) storageStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after StorageAction State changed * - * @details Callback functions have the following signature: `void(StorageAction *action, simgrid::surf::Action::State old, simgrid::surf::Action::State current)` + * @details Callback functions have the following signature: `void(StorageAction *action, simgrid::surf::Action::State + * old, simgrid::surf::Action::State current)` */ -XBT_PUBLIC_DATA(simgrid::xbt::signal) storageActionStateChangedCallbacks; +XBT_PUBLIC_DATA(simgrid::xbt::signal) +storageActionStateChangedCallbacks; /********* * Model * @@ -63,9 +67,10 @@ public: StorageModel(); ~StorageModel(); - virtual Storage* createStorage(const char* id, const char* type_id, const char* content_name, const char* attach) = 0; + virtual StorageImpl* createStorage(const char* id, const char* type_id, const char* content_name, + const char* attach) = 0; - std::vector p_storageList; + std::vector p_storageList; }; /************ @@ -75,15 +80,13 @@ public: * @brief SURF storage interface class * @details A Storage represent a storage unit (e.g.: hard drive, usb key) */ -class Storage : public simgrid::surf::Resource, - public simgrid::surf::PropertyHolder { +class StorageImpl : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder { public: - /** @brief Storage constructor */ - Storage(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite, const char* type_id, - const char* content_name, sg_size_t size, const char* attach); + StorageImpl(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite, + const char* type_id, const char* content_name, sg_size_t size, const char* attach); - ~Storage(); + ~StorageImpl(); /** @brief Check if the Storage is used (if an action currently uses its resources) */ bool isUsed() override; @@ -96,8 +99,8 @@ public: std::map* content_; sg_size_t size_; sg_size_t usedSize_; - char * typeId_; - char* attach_; //FIXME: this is the name of the host. Use the host directly + char* typeId_; + char* attach_; // FIXME: this is the name of the host. Use the host directly /** * @brief Open a file @@ -107,7 +110,7 @@ public: * * @return The StorageAction corresponding to the opening */ - virtual StorageAction *open(const char* mount, const char* path)=0; + virtual StorageAction* open(const char* mount, const char* path) = 0; /** * @brief Close a file @@ -115,7 +118,7 @@ public: * @param fd The file descriptor to close * @return The StorageAction corresponding to the closing */ - virtual StorageAction *close(surf_file_t fd)=0; + virtual StorageAction* close(surf_file_t fd) = 0; /** * @brief Read a file @@ -124,7 +127,7 @@ public: * @param size The size in bytes to read * @return The StorageAction corresponding to the reading */ - virtual StorageAction *read(surf_file_t fd, sg_size_t size)=0; + virtual StorageAction* read(surf_file_t fd, sg_size_t size) = 0; /** * @brief Write a file @@ -133,7 +136,7 @@ public: * @param size The size in bytes to write * @return The StorageAction corresponding to the writing */ - virtual StorageAction *write(surf_file_t fd, sg_size_t size)=0; + virtual StorageAction* write(surf_file_t fd, sg_size_t size) = 0; /** * @brief Get the content of the current Storage @@ -160,8 +163,8 @@ public: std::vector writeActions_; - lmm_constraint_t constraintWrite_; /* Constraint for maximum write bandwidth*/ - lmm_constraint_t constraintRead_; /* Constraint for maximum write bandwidth*/ + lmm_constraint_t constraintWrite_; /* Constraint for maximum write bandwidth*/ + lmm_constraint_t constraintRead_; /* Constraint for maximum write bandwidth*/ }; /********** @@ -172,11 +175,11 @@ public: * @brief The possible type of action for the storage component */ typedef enum { - READ=0, /**< Read a file */ - WRITE, /**< Write in a file */ - STAT, /**< Stat a file */ - OPEN, /**< Open a file */ - CLOSE /**< Close a file */ + READ = 0, /**< Read a file */ + WRITE, /**< Write in a file */ + STAT, /**< Stat a file */ + OPEN, /**< Open a file */ + CLOSE /**< Close a file */ } e_surf_action_storage_type_t; /** @ingroup SURF_storage_interface @@ -193,37 +196,35 @@ public: * @param storage The Storage associated to this StorageAction * @param type [description] */ - StorageAction(Model *model, double cost, bool failed, Storage *storage, - e_surf_action_storage_type_t type); + StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type); - /** - * @brief StorageAction constructor - * - * @param model The StorageModel associated to this StorageAction - * @param cost The cost of this StorageAction in [TODO] - * @param failed [description] - * @param var The lmm variable associated to this StorageAction if it is part of a LMM component - * @param storage The Storage associated to this StorageAction - * @param type [description] - */ - StorageAction(Model *model, double cost, bool failed, lmm_variable_t var, - Storage *storage, e_surf_action_storage_type_t type); + /** + * @brief StorageAction constructor + * + * @param model The StorageModel associated to this StorageAction + * @param cost The cost of this StorageAction in [TODO] + * @param failed [description] + * @param var The lmm variable associated to this StorageAction if it is part of a LMM component + * @param storage The Storage associated to this StorageAction + * @param type [description] + */ + StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage, + e_surf_action_storage_type_t type); void setState(simgrid::surf::Action::State state) override; e_surf_action_storage_type_t type_; - Storage* storage_; + StorageImpl* storage_; surf_file_t file_; double progress_; }; - } } typedef struct s_storage_type { - char *model; - char *content; - char *type_id; + char* model; + char* content; + char* type_id; xbt_dict_t properties; std::map* model_properties; sg_size_t size; @@ -231,8 +232,8 @@ typedef struct s_storage_type { typedef s_storage_type_t* storage_type_t; typedef struct surf_file { - char *name; - char *mount; + char* name; + char* mount; sg_size_t size; sg_size_t current_position; } s_surf_file_t; diff --git a/src/surf/host_clm03.hpp b/src/surf/host_clm03.hpp index 6dfffde1be..b9da9f5421 100644 --- a/src/surf/host_clm03.hpp +++ b/src/surf/host_clm03.hpp @@ -6,10 +6,10 @@ #include -#include "storage_interface.hpp" +#include "StorageImpl.hpp" #include "cpu_interface.hpp" -#include "src/surf/HostImpl.hpp" #include "network_interface.hpp" +#include "src/surf/HostImpl.hpp" #ifndef SURF_HOST_CLM03_HPP_ #define SURF_HOST_CLM03_HPP_ diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index d369a11524..0b49f04701 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -28,7 +28,7 @@ #include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse); -XBT_PRIVATE std::map mount_list; +XBT_PRIVATE std::map mount_list; XBT_PRIVATE std::vector known_storages; namespace simgrid { diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 688d59aae8..5cffd796e2 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -22,8 +22,8 @@ static void check_disk_attachment() void** data; xbt_lib_foreach(storage_lib, cursor, key, data) { if (xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) { - simgrid::surf::Storage* storage = - static_cast(xbt_lib_get_or_null(storage_lib, key, SURF_STORAGE_LEVEL)); + simgrid::surf::StorageImpl* storage = + static_cast(xbt_lib_get_or_null(storage_lib, key, SURF_STORAGE_LEVEL)); simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(storage->attach_); if (not host_elm) surf_parse_error("Unable to attach storage %s: host %s does not exist.", storage->cname(), storage->attach_); @@ -36,9 +36,8 @@ void storage_register_callbacks() simgrid::s4u::onPlatformCreated.connect(check_disk_attachment); instr_routing_define_callbacks(); - SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, [](void *self) { - delete static_cast(self); - }); + SURF_STORAGE_LEVEL = + xbt_lib_add_level(storage_lib, [](void* self) { delete static_cast(self); }); } /********* @@ -54,8 +53,8 @@ void surf_storage_model_init_default() namespace simgrid { namespace surf { -Storage* StorageN11Model::createStorage(const char* id, const char* type_id, const char* content_name, - const char* attach) +StorageImpl* StorageN11Model::createStorage(const char* id, const char* type_id, const char* content_name, + const char* attach) { storage_type_t storage_type = storage_types.at(type_id); @@ -64,8 +63,8 @@ Storage* StorageN11Model::createStorage(const char* id, const char* type_id, con double Bwrite = surf_parse_get_bandwidth(storage_type->model_properties->at("Bwrite").c_str(), "property Bwrite, storage", type_id); - Storage* storage = new StorageN11(this, id, maxminSystem_, Bread, Bwrite, type_id, (char*)content_name, - storage_type->size, (char*)attach); + StorageImpl* storage = new StorageN11(this, id, maxminSystem_, Bread, Bwrite, type_id, (char*)content_name, + storage_type->size, (char*)attach); xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage); storageCreatedCallbacks(storage); @@ -156,7 +155,7 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta) StorageN11::StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite, const char* type_id, char* content_name, sg_size_t size, char* attach) - : Storage(model, name, maxminSystem, bread, bwrite, type_id, content_name, size, attach) + : StorageImpl(model, name, maxminSystem, bread, bwrite, type_id, content_name, size, attach) { XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size); } @@ -246,10 +245,10 @@ StorageAction *StorageN11::write(surf_file_t fd, sg_size_t size) * Action * **********/ -StorageN11Action::StorageN11Action(Model *model, double cost, bool failed, Storage *storage, e_surf_action_storage_type_t type) -: StorageAction(model, cost, failed, - lmm_variable_new(model->getMaxminSystem(), this, 1.0, -1.0 , 3), - storage, type) { +StorageN11Action::StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage, + e_surf_action_storage_type_t type) + : StorageAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, -1.0, 3), storage, type) +{ XBT_IN("(%s,%g", storage->cname(), cost); // Must be less than the max bandwidth for all actions diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index 9c8d8665ea..00bd08d9ab 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -6,7 +6,7 @@ #include -#include "storage_interface.hpp" +#include "StorageImpl.hpp" #ifndef STORAGE_N11_HPP_ #define STORAGE_N11_HPP_ @@ -28,7 +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* attach) override; + StorageImpl* createStorage(const char* id, const char* type_id, const char* content_name, + const char* attach) override; double nextOccuringEvent(double now) override; void updateActionsState(double now, double delta) override; }; @@ -37,7 +38,7 @@ public: * Resource * ************/ -class StorageN11 : public Storage { +class StorageN11 : public StorageImpl { public: StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite, const char* type_id, char* content_name, sg_size_t size, char* attach); @@ -55,7 +56,7 @@ public: class StorageN11Action : public StorageAction { public: - StorageN11Action(Model *model, double cost, bool failed, Storage *storage, e_surf_action_storage_type_t type); + StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type); void suspend(); int unref(); void cancel(); @@ -63,7 +64,6 @@ public: bool isSuspended(); void setMaxDuration(double duration); void setPriority(double priority); - }; } diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index c35e6d18ab..23cc5cc12a 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -207,27 +207,27 @@ int surf_host_file_move(sg_host_t host, surf_file_t fd, const char* fullpath){ } sg_size_t surf_storage_get_size(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->size_; + return static_cast(surf_storage_resource_priv(resource))->size_; } sg_size_t surf_storage_get_free_size(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->getFreeSize(); + return static_cast(surf_storage_resource_priv(resource))->getFreeSize(); } sg_size_t surf_storage_get_used_size(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->getUsedSize(); + return static_cast(surf_storage_resource_priv(resource))->getUsedSize(); } xbt_dict_t surf_storage_get_properties(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->getProperties(); + return static_cast(surf_storage_resource_priv(resource))->getProperties(); } const char* surf_storage_get_host(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->attach_; + return static_cast(surf_storage_resource_priv(resource))->attach_; } const char* surf_storage_get_name(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->cname(); + return static_cast(surf_storage_resource_priv(resource))->cname(); } void surf_cpu_action_set_bound(surf_action_t action, double bound) { diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 845a9248e8..d168c3311d 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -259,7 +259,7 @@ int find_model_description(s_surf_model_description_t * table, static inline void surf_storage_free(void *r) { - delete static_cast(r); + delete static_cast(r); } void sg_version_check(int lib_version_major,int lib_version_minor,int lib_version_patch) { diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 17f25b1271..ddb333ad7b 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -60,7 +60,7 @@ set(EXTRA_DIST src/surf/xml/simgrid_dtd.c src/surf/xml/surfxml_sax_cb.cpp - src/surf/storage_interface.hpp + src/surf/StorageImpl.hpp src/surf/storage_n11.hpp src/surf/surf_interface.hpp src/surf/surf_private.h @@ -343,7 +343,7 @@ set(SURF_SRC src/surf/plugins/host_load.cpp src/surf/PropertyHolder.cpp src/surf/sg_platf.cpp - src/surf/storage_interface.cpp + src/surf/StorageImpl.cpp src/surf/storage_n11.cpp src/surf/surf_c_bindings.cpp src/surf/surf_interface.cpp