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*>;
19 for (auto const& s : *map)
20 res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
25 Storage* Storage::byName(std::string name)
27 surf::StorageImpl* res = surf::StorageImpl::byName(name);
33 const std::string& Storage::getName() const
35 return pimpl_->getName();
38 const char* Storage::getCname() const
40 return pimpl_->getCname();
43 const char* Storage::getType()
45 return pimpl_->typeId_.c_str();
48 Host* Storage::getHost()
53 sg_size_t Storage::getSizeFree()
55 return simgrid::simix::kernelImmediate([this] { return pimpl_->getFreeSize(); });
58 sg_size_t Storage::getSizeUsed()
60 return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); });
63 sg_size_t Storage::getSize()
65 return pimpl_->getSize();
68 std::map<std::string, std::string>* Storage::getProperties()
70 return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
73 const char* Storage::getProperty(const char* key)
75 return this->pimpl_->getProperty(key);
78 void Storage::setProperty(const char* key, const char* value)
80 simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); });
83 std::map<std::string, sg_size_t>* Storage::getContent()
85 return simgrid::simix::kernelImmediate([this] { return pimpl_->getContent(); });
91 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onCreation;
92 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onDestruction;
95 } /* namespace simgrid */