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/File.hpp"
7 #include "simgrid/s4u/Host.hpp"
8 #include "simgrid/s4u/Storage.hpp"
9 #include "simgrid/simix.hpp"
10 #include "src/surf/StorageImpl.hpp"
11 #include <unordered_map>
15 template class Extendable<simgrid::s4u::Storage>;
20 std::map<std::string, Storage*>* allStorages()
22 std::unordered_map<std::string, surf::StorageImpl*>* map = surf::StorageImpl::storagesMap();
23 std::map<std::string, Storage*>* res = new std::map<std::string, Storage*>;
24 for (auto const& s : *map)
25 res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
30 Storage* Storage::byName(std::string name)
32 surf::StorageImpl* res = surf::StorageImpl::byName(name);
38 const std::string& Storage::getName() const
40 return pimpl_->getName();
43 const char* Storage::getCname() const
45 return pimpl_->getCname();
48 const char* Storage::getType()
50 return pimpl_->typeId_.c_str();
53 Host* Storage::getHost()
59 std::map<std::string, std::string>* Storage::getProperties()
61 return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
64 const char* Storage::getProperty(std::string key)
66 return this->pimpl_->getProperty(key);
69 void Storage::setProperty(std::string key, std::string value)
71 simgrid::simix::kernelImmediate([this, key, value] { this->pimpl_->setProperty(key, value); });
74 std::map<std::string, sg_size_t>* Storage::getContent()
76 FileSystemStorageExt* file_system = extension<FileSystemStorageExt>();
77 return file_system->getContent();
80 sg_size_t Storage::read(sg_size_t size)
82 return simcall_storage_read(pimpl_, size);
85 sg_size_t Storage::write(sg_size_t size)
87 return simcall_storage_write(pimpl_, size);
93 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onCreation;
94 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onDestruction;
97 } /* namespace simgrid */