piface_->pimpl_ = this;
}
-/** @brief use destroy() instead of this destructor */
-HostImpl::~HostImpl()
-{
- for (auto mnt : storage_)
- xbt_free(mnt.name);
-}
-
simgrid::surf::Storage* HostImpl::findStorageOnMountList(const char* mount)
{
- simgrid::surf::Storage* st = nullptr;
-
XBT_DEBUG("Search for storage name '%s' on '%s'", mount, piface_->cname());
- for (auto mnt : storage_) {
- XBT_DEBUG("See '%s'", mnt.name);
- if (!strcmp(mount, mnt.name)) {
- st = static_cast<simgrid::surf::Storage*>(mnt.storage);
- break;
- }
- }
- if (!st)
+ if (storage_.find(mount) == storage_.end())
xbt_die("Can't find mount '%s' for '%s'", mount, piface_->cname());
- return st;
+
+ return storage_.at(mount);
}
xbt_dict_t HostImpl::getMountedStorageList()
char* storage_name = nullptr;
for (auto mnt : storage_) {
- storage_name = (char*)static_cast<simgrid::surf::Storage*>(mnt.storage)->cname();
- xbt_dict_set(storage_list, mnt.name, storage_name, nullptr);
+ storage_name = (char*)mnt.second->cname();
+ xbt_dict_set(storage_list, mnt.first.c_str(), storage_name, nullptr);
}
return storage_list;
}
XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath, piface_->cname());
for (auto mnt : storage_) {
- XBT_DEBUG("See '%s'", mnt.name);
- std::string file_mount_name = std::string(fullpath).substr(0, strlen(mnt.name));
-
- if (!strcmp(file_mount_name.c_str(), mnt.name) &&
- strlen(mnt.name) > longest_prefix_length) { /* The current mount name is found in the full path and is
- bigger than the previous*/
- longest_prefix_length = strlen(mnt.name);
- st = static_cast<simgrid::surf::Storage*>(mnt.storage);
+ XBT_DEBUG("See '%s'", mnt.first.c_str());
+ std::string file_mount_name = std::string(fullpath).substr(0, mnt.first.size());
+
+ if (file_mount_name == mnt.first && mnt.first.length() > longest_prefix_length) {
+ /* The current mount name is found in the full path and is bigger than the previous*/
+ longest_prefix_length = mnt.first.length();
+ st = mnt.second;
}
}
if (longest_prefix_length > 0) { /* Mount point found, split fullpath into mount_name and path+filename*/
public:
explicit HostImpl(s4u::Host* host);
- virtual ~HostImpl();
+ virtual ~HostImpl() = default;
/** @brief Return the storage of corresponding mount point */
virtual simgrid::surf::Storage* findStorageOnMountList(const char* storage);
*/
virtual int fileMove(surf_file_t fd, const char* fullpath);
- std::vector<s_mount_t> storage_;
+ std::map<std::string, simgrid::surf::Storage*> storage_;
simgrid::s4u::Host* piface_ = nullptr;
simgrid::s4u::Host* getHost() { return piface_; }
#include <string>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse);
-XBT_PRIVATE std::vector<s_mount_t> mount_list;
+XBT_PRIVATE std::map<std::string, simgrid::surf::Storage*> mount_list;
namespace simgrid {
namespace surf {
XBT_DEBUG("ROUTING Mount '%s' on '%s'",mount->storageId, mount->name);
- s_mount_t mnt;
- mnt.storage = surf_storage_resource_priv(surf_storage_resource_by_name(mount->storageId));
- mnt.name = xbt_strdup(mount->name);
-
if (mount_list.empty())
XBT_DEBUG("Create a Mount list for %s", A_surfxml_host_id);
- mount_list.push_back(mnt);
+ mount_list.insert(
+ {std::string(mount->name), surf_storage_resource_priv(surf_storage_resource_by_name(mount->storageId))});
}
void sg_platf_new_route(sg_platf_route_cbarg_t route)