X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/29761dde7ce7fb8919138c1abd961cdfe9a4c9a3..9104957deccc59e0e804215d5db498fabfd40d29:/include/simgrid/plugins/file_system.h diff --git a/include/simgrid/plugins/file_system.h b/include/simgrid/plugins/file_system.h index e95a56f80b..6c92f19916 100644 --- a/include/simgrid/plugins/file_system.h +++ b/include/simgrid/plugins/file_system.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2017-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. */ @@ -16,7 +16,7 @@ #include #include #include -#endif +#endif /* C++ */ // C interface //////////////// @@ -27,12 +27,12 @@ XBT_PUBLIC void sg_storage_file_system_init(); XBT_PUBLIC sg_file_t sg_file_open(const char* fullpath, void* data); XBT_PUBLIC sg_size_t sg_file_read(sg_file_t fd, sg_size_t size); XBT_PUBLIC sg_size_t sg_file_write(sg_file_t fd, sg_size_t size); -XBT_PUBLIC void sg_file_close(sg_file_t fd); +XBT_PUBLIC void sg_file_close(const_sg_file_t fd); XBT_PUBLIC const char* sg_file_get_name(sg_file_t fd); XBT_PUBLIC sg_size_t sg_file_get_size(sg_file_t fd); XBT_PUBLIC void sg_file_dump(sg_file_t fd); -XBT_PUBLIC void* sg_file_get_data(sg_file_t fd); +XBT_PUBLIC void* sg_file_get_data(const_sg_file_t fd); XBT_PUBLIC void sg_file_set_data(sg_file_t fd, void* data); XBT_PUBLIC void sg_file_seek(sg_file_t fd, sg_offset_t offset, int origin); XBT_PUBLIC sg_size_t sg_file_tell(sg_file_t fd); @@ -41,15 +41,15 @@ XBT_PUBLIC void sg_file_unlink(sg_file_t fd); XBT_PUBLIC int sg_file_rcopy(sg_file_t file, sg_host_t host, const char* fullpath); XBT_PUBLIC int sg_file_rmove(sg_file_t file, sg_host_t host, const char* fullpath); -XBT_PUBLIC sg_size_t sg_disk_get_size_free(sg_disk_t d); -XBT_PUBLIC sg_size_t sg_disk_get_size_used(sg_disk_t d); -XBT_PUBLIC sg_size_t sg_disk_get_size(sg_disk_t d); -XBT_PUBLIC const char* sg_disk_get_mount_point(sg_disk_t d); +XBT_PUBLIC sg_size_t sg_disk_get_size_free(const_sg_disk_t d); +XBT_PUBLIC sg_size_t sg_disk_get_size_used(const_sg_disk_t d); +XBT_PUBLIC sg_size_t sg_disk_get_size(const_sg_disk_t d); +XBT_PUBLIC const char* sg_disk_get_mount_point(const_sg_disk_t d); -XBT_PUBLIC sg_size_t sg_storage_get_size_free(sg_storage_t st); -XBT_PUBLIC sg_size_t sg_storage_get_size_used(sg_storage_t st); -XBT_PUBLIC sg_size_t sg_storage_get_size(sg_storage_t st); -XBT_PUBLIC xbt_dict_t sg_storage_get_content(sg_storage_t storage); +XBT_PUBLIC sg_size_t sg_storage_get_size_free(const_sg_storage_t st); +XBT_PUBLIC sg_size_t sg_storage_get_size_used(const_sg_storage_t st); +XBT_PUBLIC sg_size_t sg_storage_get_size(const_sg_storage_t st); +XBT_PUBLIC xbt_dict_t sg_storage_get_content(const_sg_storage_t storage); XBT_PUBLIC xbt_dict_t sg_host_get_storage_content(sg_host_t host); @@ -85,9 +85,13 @@ SG_END_DECL #ifdef __cplusplus namespace simgrid { + +extern template class XBT_PUBLIC xbt::Extendable; + namespace s4u { /** @brief A simulated file + * @addtogroup Plugin_filesystem * * Used to simulate the time it takes to access to a file, but does not really store any information. * @@ -100,9 +104,13 @@ class XBT_PUBLIC File : public xbt::Extendable { std::string path_; std::string fullpath_; sg_size_t current_position_ = SEEK_SET; + int desc_id = 0; + Disk* local_disk_ = nullptr; + Storage* local_storage_ = nullptr; + std::string mount_point_; Storage* find_local_storage_on(Host* host); - Disk* find_local_disk_on(Host* host); + Disk* find_local_disk_on(const Host* host); sg_size_t write_on_storage(sg_size_t size, bool write_inside); sg_size_t write_on_disk(sg_size_t size, bool write_inside); @@ -139,17 +147,18 @@ public: int unlink(); /** Remove a file from the contents of a disk */ void dump(); - - int desc_id = 0; - Disk* local_disk_ = nullptr; - Storage* local_storage_ = nullptr; - std::string mount_point_; }; class XBT_PUBLIC FileSystemDiskExt { + std::unique_ptr> content_; + std::map remote_mount_points_; + std::string mount_point_; + sg_size_t used_size_ = 0; + sg_size_t size_ = static_cast(500 * 1024) * 1024 * 1024; + public: static simgrid::xbt::Extension EXTENSION_ID; - explicit FileSystemDiskExt(Disk* ptr); + explicit FileSystemDiskExt(const Disk* ptr); FileSystemDiskExt(const FileSystemDiskExt&) = delete; FileSystemDiskExt& operator=(const FileSystemDiskExt&) = delete; std::map* parse_content(const std::string& filename); @@ -164,19 +173,16 @@ public: sg_size_t get_used_size() const { return used_size_; } void decr_used_size(sg_size_t size) { used_size_ -= size; } void incr_used_size(sg_size_t size) { used_size_ += size; } +}; -private: +class XBT_PUBLIC FileSystemStorageExt { std::unique_ptr> content_; - std::map remote_mount_points_; - std::string mount_point_; sg_size_t used_size_ = 0; - sg_size_t size_ = static_cast(500 * 1024) * 1024 * 1024; -}; + sg_size_t size_ = 0; -class XBT_PUBLIC FileSystemStorageExt { public: static simgrid::xbt::Extension EXTENSION_ID; - explicit FileSystemStorageExt(Storage* ptr); + explicit FileSystemStorageExt(const Storage* ptr); FileSystemStorageExt(const FileSystemStorageExt&) = delete; FileSystemStorageExt& operator=(const FileSystemStorageExt&) = delete; std::map* parse_content(const std::string& filename); @@ -185,11 +191,6 @@ public: sg_size_t get_used_size() { return used_size_; } void decr_used_size(sg_size_t size) { used_size_ -= size; } void incr_used_size(sg_size_t size) { used_size_ += size; } - -private: - std::unique_ptr> content_; - sg_size_t used_size_ = 0; - sg_size_t size_ = 0; }; class XBT_PUBLIC FileDescriptorHostExt {