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 // attached_to_ = Host::by_name_or_null(pimpl->attach_);
16 std::map<std::string, Storage*>* allStorages()
18 std::unordered_map<std::string, surf::StorageImpl*>* map = surf::StorageImpl::storagesMap();
19 std::map<std::string, Storage*>* res = new std::map<std::string, Storage*>;
21 res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
26 Storage* Storage::byName(const char* name)
28 surf::StorageImpl* res = surf::StorageImpl::byName(name);
34 const char* Storage::name()
36 return pimpl_->cname();
39 const char* Storage::type()
41 return pimpl_->typeId_;
49 sg_size_t Storage::sizeFree()
51 return simgrid::simix::kernelImmediate([this] { return pimpl_->getFreeSize(); });
54 sg_size_t Storage::sizeUsed()
56 return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); });
59 sg_size_t Storage::size() {
63 xbt_dict_t Storage::properties()
65 return simgrid::simix::kernelImmediate([this] { return pimpl_->getProperties(); });
68 const char* Storage::property(const char* key)
70 return static_cast<const char*>(xbt_dict_get_or_null(this->properties(), key));
73 void Storage::setProperty(const char* key, char* value)
75 xbt_dict_set(this->properties(), key, value, nullptr);
78 std::map<std::string, sg_size_t>* Storage::content()
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 */