1 /* Copyright (c) 2006-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid/s4u/storage.hpp"
10 extern xbt_lib_t storage_lib;
15 boost::unordered_map <std::string, Storage *> *Storage::storages_ = new boost::unordered_map<std::string, Storage*> ();
16 Storage::Storage(std::string name, smx_storage_t inferior) :
17 name_(name), pimpl_(inferior)
19 storages_->insert({name, this});
22 Storage::~Storage() = default;
24 smx_storage_t Storage::inferior() {
27 Storage &Storage::byName(const char*name) {
28 s4u::Storage *res = nullptr;
30 res = storages_->at(name);
31 } catch (std::out_of_range& e) {
32 smx_storage_t inferior = xbt_lib_get_elm_or_null(storage_lib,name);
33 if (inferior == nullptr)
34 xbt_die("Storage %s does not exist. Please only use the storages that are defined in your platform.", name);
36 res = new Storage(name,inferior);
41 const char*Storage::name() {
45 sg_size_t Storage::sizeFree() {
46 return simcall_storage_get_free_size(pimpl_);
48 sg_size_t Storage::sizeUsed() {
49 return simcall_storage_get_used_size(pimpl_);
51 sg_size_t Storage::size() {
52 return SIMIX_storage_get_size(pimpl_);
56 } /* namespace simgrid */