1 /* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "../surf/StorageImpl.hpp"
7 #include "simgrid/s4u/Host.hpp"
8 #include "simgrid/s4u/Storage.hpp"
9 #include "simgrid/simix.hpp"
10 #include <unordered_map>
15 std::map<std::string, Storage*>* allStorages()
17 std::unordered_map<std::string, surf::StorageImpl*>* map = surf::StorageImpl::storagesMap();
18 std::map<std::string, Storage*>* res = new std::map<std::string, Storage*>;
20 res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
25 Storage* Storage::byName(const char* name)
27 surf::StorageImpl* res = surf::StorageImpl::byName(name);
33 const char* Storage::name()
35 return pimpl_->cname();
38 const char* Storage::type()
40 return pimpl_->typeId_.c_str();
48 sg_size_t Storage::sizeFree()
50 return simgrid::simix::kernelImmediate([this] { return pimpl_->getFreeSize(); });
53 sg_size_t Storage::sizeUsed()
55 return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); });
58 sg_size_t Storage::size() {
62 xbt_dict_t Storage::properties()
64 return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
67 const char* Storage::property(const char* key)
69 return static_cast<const char*>(xbt_dict_get_or_null(this->properties(), key));
72 void Storage::setProperty(const char* key, char* value)
74 xbt_dict_set(this->properties(), key, value, nullptr);
77 std::map<std::string, sg_size_t>* Storage::content()
79 return simgrid::simix::kernelImmediate([this] { return pimpl_->getContent(); });
85 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onCreation;
86 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onDestruction;
89 } /* namespace simgrid */