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 "simgrid/s4u/Host.hpp"
7 #include "simgrid/s4u/Storage.hpp"
8 #include "simgrid/simix.hpp"
9 #include "src/plugins/file_system/FileSystem.hpp"
10 #include "src/surf/StorageImpl.hpp"
11 #include <unordered_map>
15 template class Extendable<simgrid::s4u::Storage>;
20 void getStorageList(std::map<std::string, Storage*>* whereTo)
22 for (auto const& s : *surf::StorageImpl::storagesMap())
23 whereTo->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
26 Storage* Storage::byName(std::string name)
28 surf::StorageImpl* res = surf::StorageImpl::byName(name);
34 const std::string& Storage::getName() const
36 return pimpl_->getName();
39 const char* Storage::getCname() const
41 return pimpl_->getCname();
44 const char* Storage::getType()
46 return pimpl_->typeId_.c_str();
49 Host* Storage::getHost()
55 std::map<std::string, std::string>* Storage::getProperties()
57 return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
60 const char* Storage::getProperty(std::string key)
62 return this->pimpl_->getProperty(key);
65 void Storage::setProperty(std::string key, std::string value)
67 simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); });
70 sg_size_t Storage::read(sg_size_t size)
72 return simcall_storage_read(pimpl_, size);
75 sg_size_t Storage::write(sg_size_t size)
77 return simcall_storage_write(pimpl_, size);
83 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onCreation;
84 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onDestruction;
87 } /* namespace simgrid */