-/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_file, s4u, "S4U files");
int sg_storage_max_file_descriptors = 1024;
-/** @defgroup plugin_filesystem
- @beginrst
-
- @endrst
+/** @defgroup plugin_filesystem Plugin FileSystem
+ *
+ * This adds the notion of Files on top of the storage notion that provided by the core of SimGrid.
+ * Activate this plugin at will.
*/
-
namespace simgrid {
+
+template class xbt::Extendable<s4u::File>;
+
namespace s4u {
simgrid::xbt::Extension<Disk, FileSystemDiskExt> FileSystemDiskExt::EXTENSION_ID;
simgrid::xbt::Extension<Storage, FileSystemStorageExt> FileSystemStorageExt::EXTENSION_ID;
return st;
}
-Disk* File::find_local_disk_on(Host* host)
+Disk* File::find_local_disk_on(const Host* host)
{
Disk* d = nullptr;
size_t longest_prefix_length = 0;
size_t longest_prefix_length = 0;
if (local_storage_) {
/* Find the host that owns the storage where the file has to be copied */
- Storage* storage_dest = nullptr;
+ const Storage* storage_dest = nullptr;
for (auto const& elm : host->get_mounted_storages()) {
std::string mount_point = std::string(fullpath).substr(0, elm.first.size());
}
if (local_disk_) {
- Disk* dst_disk = nullptr;
+ const Disk* dst_disk = nullptr;
for (auto const& disk : host->get_disks()) {
std::string current_mount = disk->extension<FileSystemDiskExt>()->get_mount_point();
return res;
}
-FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
+FileSystemDiskExt::FileSystemDiskExt(const Disk* ptr)
{
const char* size_str = ptr->get_property("size");
if (size_str)
content_.reset(parse_content(content_str));
}
-FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr) : size_(ptr->get_impl()->size_)
+FileSystemStorageExt::FileSystemStorageExt(const Storage* ptr) : size_(ptr->get_impl()->size_)
{
content_.reset(parse_content(ptr->get_impl()->content_name_));
}
return fd->write(size);
}
-void sg_file_close(sg_file_t fd)
+void sg_file_close(const_sg_file_t fd)
{
delete fd;
}
/** Retrieves the user data associated with the file
* @ingroup plugin_filesystem
*/
-void* sg_file_get_data(sg_file_t fd)
+void* sg_file_get_data(const_sg_file_t fd)
{
return fd->get_data();
}
return file->remote_move(host, fullpath);
}
-sg_size_t sg_disk_get_size_free(sg_disk_t d)
+sg_size_t sg_disk_get_size_free(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_size() - d->extension<FileSystemDiskExt>()->get_used_size();
}
-sg_size_t sg_disk_get_size_used(sg_disk_t d)
+sg_size_t sg_disk_get_size_used(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_used_size();
}
-sg_size_t sg_disk_get_size(sg_disk_t d)
+sg_size_t sg_disk_get_size(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_size();
}
-const char* sg_disk_get_mount_point(sg_disk_t d)
+const char* sg_disk_get_mount_point(const_sg_disk_t d)
{
return d->extension<FileSystemDiskExt>()->get_mount_point();
}
-sg_size_t sg_storage_get_size_free(sg_storage_t st)
+sg_size_t sg_storage_get_size_free(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_size() - st->extension<FileSystemStorageExt>()->get_used_size();
}
-sg_size_t sg_storage_get_size_used(sg_storage_t st)
+sg_size_t sg_storage_get_size_used(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_used_size();
}
-sg_size_t sg_storage_get_size(sg_storage_t st)
+sg_size_t sg_storage_get_size(const_sg_storage_t st)
{
return st->extension<FileSystemStorageExt>()->get_size();
}
-xbt_dict_t sg_storage_get_content(sg_storage_t storage)
+xbt_dict_t sg_storage_get_content(const_sg_storage_t storage)
{
- std::map<std::string, sg_size_t>* content = storage->extension<simgrid::s4u::FileSystemStorageExt>()->get_content();
+ const std::map<std::string, sg_size_t>* content =
+ storage->extension<simgrid::s4u::FileSystemStorageExt>()->get_content();
// Note: ::operator delete is ok here (no destructor called) since the dict elements are of POD type sg_size_t.
xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(::operator delete);