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"
10 #include <unordered_map>
14 std::map<std::string, Storage*>* allStorages()
16 std::unordered_map<std::string, surf::StorageImpl*>* map = surf::StorageImpl::storagesMap();
17 std::map<std::string, Storage*>* res = new std::map<std::string, Storage*>;
19 res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
24 Storage* Storage::byName(const char* name)
26 surf::StorageImpl* res = surf::StorageImpl::byName(name);
32 const char* Storage::name()
34 return pimpl_->cname();
37 const char* Storage::host()
39 return pimpl_->attach_;
42 sg_size_t Storage::sizeFree()
44 return simgrid::simix::kernelImmediate([this] { return pimpl_->getFreeSize(); });
47 sg_size_t Storage::sizeUsed()
49 return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); });
52 sg_size_t Storage::size() {
56 xbt_dict_t Storage::properties()
58 return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
61 const char* Storage::property(const char* key)
63 return static_cast<const char*>(xbt_dict_get_or_null(this->properties(), key));
66 void Storage::setProperty(const char* key, char* value)
68 xbt_dict_set(this->properties(), key, value, nullptr);
71 std::map<std::string, sg_size_t*>* Storage::content()
73 return simgrid::simix::kernelImmediate([this] { return pimpl_->getContent(); });
79 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onCreation;
80 simgrid::xbt::signal<void(s4u::Storage&)> Storage::onDestruction;
83 } /* namespace simgrid */