Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Explicit instanciation of xbt::Extendable<> specializations.
[simgrid.git] / src / plugins / file_system / s4u_FileSystem.cpp
index 5f0ee3c..350382a 100644 (file)
@@ -1,4 +1,4 @@
-/* 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;
@@ -58,7 +60,7 @@ Storage* File::find_local_storage_on(Host* host)
   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;
@@ -405,7 +407,7 @@ int File::remote_copy(sg_host_t host, const char* fullpath)
   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());
@@ -426,7 +428,7 @@ int File::remote_copy(sg_host_t host, const char* fullpath)
   }
 
   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();
@@ -470,7 +472,7 @@ int File::remote_move(sg_host_t host, const char* fullpath)
   return res;
 }
 
-FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
+FileSystemDiskExt::FileSystemDiskExt(const Disk* ptr)
 {
   const char* size_str    = ptr->get_property("size");
   if (size_str)
@@ -487,7 +489,7 @@ FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
     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_));
 }
@@ -658,7 +660,7 @@ sg_size_t sg_file_write(sg_file_t fd, sg_size_t size)
   return fd->write(size);
 }
 
-void sg_file_close(sg_file_t fd)
+void sg_file_close(const_sg_file_t fd)
 {
   delete fd;
 }
@@ -688,7 +690,7 @@ void sg_file_dump(sg_file_t 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();
 }
@@ -760,44 +762,45 @@ int sg_file_rmove(sg_file_t file, sg_host_t host, const char* fullpath)
   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);