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/Storage.hpp"
8 #include "simgrid/simix.hpp"
9 #include <unordered_map>
13 std::map<std::string, Storage*>* allStorages()
15 std::unordered_map<std::string, surf::StorageImpl*>* map = surf::StorageImpl::storagesMap();
16 std::map<std::string, Storage*>* res = new std::map<std::string, Storage*>;
18 res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
23 Storage* Storage::byName(const char* name)
25 surf::StorageImpl* res = surf::StorageImpl::byName(name);
31 const char* Storage::name()
33 return pimpl_->cname();
36 const char* Storage::host()
38 return pimpl_->attach_;
41 sg_size_t Storage::sizeFree()
43 return simgrid::simix::kernelImmediate([this] { return pimpl_->getFreeSize(); });
46 sg_size_t Storage::sizeUsed()
48 return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); });
51 sg_size_t Storage::size() {
55 xbt_dict_t Storage::properties()
57 return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
60 const char* Storage::property(const char* key)
62 return static_cast<const char*>(xbt_dict_get_or_null(this->properties(), key));
65 void Storage::setProperty(const char* key, char* value)
67 xbt_dict_set(this->properties(), key, value, nullptr);
70 std::map<std::string, sg_size_t*>* Storage::content()
72 return simgrid::simix::kernelImmediate([this] { return pimpl_->getContent(); });
78 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onCreation;
79 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onDestruction;
82 } /* namespace simgrid */