Skip to content

Commit

Permalink
constify a few methods
Browse files Browse the repository at this point in the history
  • Loading branch information
frs69wq committed May 17, 2024
1 parent a995310 commit a482fa6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions include/fsmod/JBODStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace simgrid::module::fs {
* @brief Retrieves the storage's RAID level
* @return A RAID level
*/
[[nodiscard]] RAID get_raid_level() { return raid_level_; }
[[nodiscard]] RAID get_raid_level() const { return raid_level_; }

void set_raid_level(RAID raid_level);


Expand All @@ -44,7 +44,7 @@ namespace simgrid::module::fs {
void write(sg_size_t size) override;

protected:
s4u::MessageQueue* mqueue() { return mq_; }
s4u::MessageQueue* mqueue() const { return mq_; }

JBODStorage(const std::string& name, const std::vector<simgrid::s4u::Disk*>& disks);
void update_parity_disk_idx() { parity_disk_idx_ = (parity_disk_idx_- 1) % num_disks_; }
Expand Down
6 changes: 3 additions & 3 deletions include/fsmod/Partition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ namespace simgrid::module::fs {

[[nodiscard]] std::shared_ptr<Storage> get_storage() const { return storage_; }

[[nodiscard]] bool directory_exists(const std::string& dir_path) { return content_.find(dir_path) != content_.end(); }
std::set<std::string> list_files_in_directory(const std::string &dir_path);
[[nodiscard]] bool directory_exists(const std::string& dir_path) const { return content_.find(dir_path) != content_.end(); }
std::set<std::string> list_files_in_directory(const std::string &dir_path) const;
void delete_directory(const std::string &dir_path);

[[nodiscard]] FileMetadata* get_file_metadata(const std::string& dir_path, const std::string& file_name);
[[nodiscard]] FileMetadata* get_file_metadata(const std::string& dir_path, const std::string& file_name) const;
void create_new_file(const std::string& dir_path,
const std::string& file_name,
sg_size_t size);
Expand Down
6 changes: 3 additions & 3 deletions src/Partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace simgrid::module::fs {
* @param file_name: the file name
* @return A pointer to MetaData, or nullptr if the directory or file is not found
*/
FileMetadata *Partition::get_file_metadata(const std::string &dir_path, const std::string &file_name) {
FileMetadata *Partition::get_file_metadata(const std::string &dir_path, const std::string &file_name) const {
try {
return content_.at(dir_path).at(file_name).get();
} catch (std::out_of_range &e) {
Expand Down Expand Up @@ -122,12 +122,12 @@ namespace simgrid::module::fs {
content_[dst_dir_path][dst_file_name] = std::move(uniq_ptr);
}

std::set<std::string> Partition::list_files_in_directory(const std::string &dir_path) {
std::set<std::string> Partition::list_files_in_directory(const std::string &dir_path) const {
if (content_.find(dir_path) == content_.end()) {
throw FileSystemException(XBT_THROW_POINT, "Directory does not exist");
}
std::set < std::string > keys;
for (auto const &key: content_[dir_path]) {
for (auto const &key: content_.at(dir_path)) {
keys.insert(key.first);
}
return keys;
Expand Down
2 changes: 1 addition & 1 deletion test/caching_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CachingTest : public ::testing::Test {
CachingTest() = default;

void setup_platform() {
XBT_INFO("Creating a platform with one host and two disks...");
XBT_INFO("Creating a platform with one host and one disk...");
auto *my_zone = sg4::create_full_zone("zone");
host_ = my_zone->create_host("my_host", "100Gf");
disk_ = host_->create_disk("disk", "1kBps", "2kBps");
Expand Down

0 comments on commit a482fa6

Please sign in to comment.