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 char* Storage::getName()
35 return pimpl_->cname();
38 const char* Storage::getType()
40 return pimpl_->typeId_.c_str();
43 Host* Storage::getHost()
48 sg_size_t Storage::getSizeFree()
50 return simgrid::simix::kernelImmediate([this] { return pimpl_->getFreeSize(); });
53 sg_size_t Storage::getSizeUsed()
55 return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); });
58 sg_size_t Storage::getSize()
60 return pimpl_->getSize();
63 std::map<std::string, std::string>* Storage::getProperties()
65 return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
68 const char* Storage::getProperty(const char* key)
70 return this->pimpl_->getProperty(key);
73 void Storage::setProperty(const char* key, const char* value)
75 simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); });
78 std::map<std::string, sg_size_t>* Storage::getContent()
80 return simgrid::simix::kernelImmediate([this] { return pimpl_->getContent(); });
86 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onCreation;
87 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onDestruction;
90 } /* namespace simgrid */