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) {
18 p_inferior = inferior;
20 storages->insert({name, this});
24 // TODO Auto-generated destructor stub
27 smx_storage_t Storage::inferior() {
30 Storage &Storage::byName(const char*name) {
31 s4u::Storage *res = NULL;
33 res = storages->at(name);
34 } catch (std::out_of_range& e) {
35 smx_storage_t inferior = xbt_lib_get_elm_or_null(storage_lib,name);
37 xbt_die("Storage %s does not exist. Please only use the storages that are defined in your platform.", name);
39 res = new Storage(name,inferior);
44 const char*Storage::name() {
45 return p_name.c_str();
48 sg_size_t Storage::size_free() {
49 return simcall_storage_get_free_size(p_inferior);
51 sg_size_t Storage::size_used() {
52 return simcall_storage_get_used_size(p_inferior);
54 sg_size_t Storage::size() {
55 return SIMIX_storage_get_size(p_inferior);
59 } /* namespace simgrid */