X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/16bbb8a8212497d9c44c81333ed2c0e689e0c5af..4a69abcc786d029bd2962537f767d12a0f808d11:/src/s4u/s4u_storage.cpp diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index 3b0841bbaa..48c58d71da 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -5,6 +5,8 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simgrid/s4u/storage.hpp" +#include "simgrid/simix.hpp" +#include "src/surf/storage_interface.hpp" #include "xbt/lib.h" extern xbt_lib_t storage_lib; @@ -12,28 +14,26 @@ extern xbt_lib_t storage_lib; namespace simgrid { namespace s4u { -boost::unordered_map *Storage::storages = new boost::unordered_map (); -Storage::Storage(std::string name, smx_storage_t inferior) { - p_name = name; - p_inferior = inferior; - - storages->insert({name, this}); +boost::unordered_map *Storage::storages_ = new boost::unordered_map (); +Storage::Storage(std::string name, smx_storage_t inferior) : + name_(name), pimpl_(inferior) +{ + size_ = SIMIX_storage_get_size(pimpl_); + storages_->insert({name, this}); } -Storage::~Storage() { - // TODO Auto-generated destructor stub -} +Storage::~Storage() = default; smx_storage_t Storage::inferior() { - return p_inferior; + return pimpl_; } Storage &Storage::byName(const char*name) { - s4u::Storage *res = NULL; + s4u::Storage *res = nullptr; try { - res = storages->at(name); + res = storages_->at(name); } catch (std::out_of_range& e) { smx_storage_t inferior = xbt_lib_get_elm_or_null(storage_lib,name); - if (inferior == NULL) + if (inferior == nullptr) xbt_die("Storage %s does not exist. Please only use the storages that are defined in your platform.", name); res = new Storage(name,inferior); @@ -41,18 +41,34 @@ Storage &Storage::byName(const char*name) { return *res; } -const char*Storage::name() { - return p_name.c_str(); +const char* Storage::name() +{ + return name_.c_str(); } -sg_size_t Storage::size_free() { - return simcall_storage_get_free_size(p_inferior); +sg_size_t Storage::sizeFree() +{ + return simcall_storage_get_free_size(pimpl_); } -sg_size_t Storage::size_used() { - return simcall_storage_get_used_size(p_inferior); + +sg_size_t Storage::sizeUsed() +{ + return simcall_storage_get_used_size(pimpl_); } + sg_size_t Storage::size() { - return SIMIX_storage_get_size(p_inferior); + return size_; +} + +xbt_dict_t Storage::properties() +{ + return simcall_storage_get_properties(pimpl_); +} + +std::map* Storage::content() +{ + return simgrid::simix::kernelImmediate( + [this] { return static_cast(surf_storage_resource_priv(this->pimpl_))->getContent(); }); } } /* namespace s4u */