X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8db87bde70b28b9c6fcf5be4d924f6c3a141c715..6865db1b80d2d06c80ff82e7246821958b56e2d2:/src/s4u/s4u_storage.cpp diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index 7f52311364..d010801b6c 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -1,32 +1,39 @@ -/* 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 "../surf/StorageImpl.hpp" +#include "simgrid/s4u/Storage.hpp" +#include "simgrid/simix.hpp" #include "xbt/lib.h" +#include + extern xbt_lib_t storage_lib; namespace simgrid { namespace s4u { -boost::unordered_map *Storage::storages_ = new boost::unordered_map (); +std::unordered_map* Storage::storages_ = new std::unordered_map(); + Storage::Storage(std::string name, smx_storage_t inferior) : name_(name), pimpl_(inferior) { - size_ = SIMIX_storage_get_size(pimpl_); + hostname_ = surf_storage_get_host(pimpl_); + size_ = surf_storage_get_size(pimpl_); storages_->insert({name, this}); } Storage::~Storage() = default; -smx_storage_t Storage::inferior() { +smx_storage_t Storage::inferior() +{ return pimpl_; } -Storage &Storage::byName(const char*name) { - s4u::Storage *res = nullptr; + +Storage& Storage::byName(const char* name) +{ + s4u::Storage* res = nullptr; try { res = storages_->at(name); } catch (std::out_of_range& e) { @@ -44,14 +51,19 @@ const char* Storage::name() return name_.c_str(); } +const char* Storage::host() +{ + return hostname_.c_str(); +} + sg_size_t Storage::sizeFree() { - return simcall_storage_get_free_size(pimpl_); + return simgrid::simix::kernelImmediate([this] { return surf_storage_resource_priv(pimpl_)->getFreeSize(); }); } sg_size_t Storage::sizeUsed() { - return simcall_storage_get_used_size(pimpl_); + return simgrid::simix::kernelImmediate([this] { return surf_storage_resource_priv(pimpl_)->getUsedSize(); }); } sg_size_t Storage::size() { @@ -63,9 +75,24 @@ xbt_dict_t Storage::properties() return simcall_storage_get_properties(pimpl_); } -xbt_dict_t Storage::content() +const char* Storage::property(const char* key) +{ + return static_cast(xbt_dict_get_or_null(this->properties(), key)); +} + +void Storage::setProperty(const char* key, char* value) +{ + xbt_dict_set(this->properties(), key, value, nullptr); +} + +std::map* Storage::content() +{ + return simgrid::simix::kernelImmediate([this] { return surf_storage_resource_priv(this->pimpl_)->getContent(); }); +} + +std::unordered_map* Storage::allStorages() { - return simcall_storage_get_content(pimpl_); + return storages_; } } /* namespace s4u */