X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8db87bde70b28b9c6fcf5be4d924f6c3a141c715..12ad1e7c01058fada33cecf2d4c4cb8bf9874f9e:/src/s4u/s4u_storage.cpp diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index 7f52311364..d8f004ac63 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -1,72 +1,87 @@ -/* Copyright (c) 2006-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */ /* 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 "simgrid/s4u/storage.hpp" - -#include "xbt/lib.h" -extern xbt_lib_t storage_lib; +#include "simgrid/s4u/Host.hpp" +#include "simgrid/s4u/Storage.hpp" +#include "simgrid/simix.hpp" +#include "src/plugins/file_system/FileSystem.hpp" +#include "src/surf/StorageImpl.hpp" +#include namespace simgrid { +namespace xbt { +template class Extendable; +} + namespace s4u { -boost::unordered_map *Storage::storages_ = new boost::unordered_map (); -Storage::Storage(std::string name, smx_storage_t inferior) : - name_(name), pimpl_(inferior) +void getStorageList(std::map* whereTo) { - size_ = SIMIX_storage_get_size(pimpl_); - storages_->insert({name, this}); + for (auto const& s : *surf::StorageImpl::storagesMap()) + whereTo->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface } -Storage::~Storage() = default; +Storage* Storage::byName(std::string name) +{ + surf::StorageImpl* res = surf::StorageImpl::byName(name); + if (res == nullptr) + return nullptr; + return &res->piface_; +} + +const std::string& Storage::getName() const +{ + return pimpl_->getName(); +} -smx_storage_t Storage::inferior() { - return pimpl_; +const char* Storage::getCname() const +{ + return pimpl_->getCname(); } -Storage &Storage::byName(const char*name) { - s4u::Storage *res = nullptr; - try { - 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 == 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); - } - return *res; + +const char* Storage::getType() +{ + return pimpl_->typeId_.c_str(); } -const char* Storage::name() +Host* Storage::getHost() { - return name_.c_str(); + return attached_to_; } -sg_size_t Storage::sizeFree() + +std::map* Storage::getProperties() { - return simcall_storage_get_free_size(pimpl_); + return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); }); } -sg_size_t Storage::sizeUsed() +const char* Storage::getProperty(std::string key) { - return simcall_storage_get_used_size(pimpl_); + return this->pimpl_->getProperty(key); } -sg_size_t Storage::size() { - return size_; +void Storage::setProperty(std::string key, std::string value) +{ + simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); }); } -xbt_dict_t Storage::properties() +sg_size_t Storage::read(sg_size_t size) { - return simcall_storage_get_properties(pimpl_); + return simcall_storage_read(pimpl_, size); } -xbt_dict_t Storage::content() +sg_size_t Storage::write(sg_size_t size) { - return simcall_storage_get_content(pimpl_); + return simcall_storage_write(pimpl_, size); } +/************* + * Callbacks * + *************/ +simgrid::xbt::signal Storage::onCreation; +simgrid::xbt::signal Storage::onDestruction; + } /* namespace s4u */ } /* namespace simgrid */