X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/618862bd2860e2d350d43aeab911e5b220184276..3879bc8993c5725fafe2ee5012ca2e3bee48aec2:/src/kernel/resource/profile/ProfileBuilder.cpp diff --git a/src/kernel/resource/profile/ProfileBuilder.cpp b/src/kernel/resource/profile/ProfileBuilder.cpp index bbfb98d805..ee634f07ac 100644 --- a/src/kernel/resource/profile/ProfileBuilder.cpp +++ b/src/kernel/resource/profile/ProfileBuilder.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2023. 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. */ @@ -8,6 +8,7 @@ #include "src/kernel/resource/profile/Profile.hpp" #include "src/kernel/resource/profile/StochasticDatedValue.hpp" #include "src/surf/surf_interface.hpp" +#include "xbt/file.hpp" #include #include @@ -213,7 +214,7 @@ public: } } - std::vector get_pattern() { return pattern; } + std::vector get_pattern() const { return pattern; } }; Profile* ProfileBuilder::from_string(const std::string& name, const std::string& input, double periodicity) @@ -222,23 +223,23 @@ Profile* ProfileBuilder::from_string(const std::string& name, const std::string& return new Profile(name,cb,cb.get_repeat_delay()); } -Profile* ProfileBuilder::from_file(const std::string& path) +Profile* ProfileBuilder::from_file(const std::string& filename) { - xbt_assert(not path.empty(), "Cannot parse a trace from an empty filename"); - auto f = std::unique_ptr(surf_ifsopen(path)); - xbt_assert(not f->fail(), "Cannot open file '%s' (path=%s)", path.c_str(), (boost::join(surf_path, ":")).c_str()); + xbt_assert(not filename.empty(), "Cannot parse a trace from an empty filename"); + auto f = std::unique_ptr(simgrid::xbt::ifsopen_path(filename, surf_path)); + xbt_assert(not f->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(), (boost::join(surf_path, ":")).c_str()); std::stringstream buffer; buffer << f->rdbuf(); LegacyUpdateCb cb(buffer.str(), -1); - return new Profile(path,cb,cb.get_repeat_delay()); + return new Profile(filename, cb, cb.get_repeat_delay()); } Profile* ProfileBuilder::from_void() { - static Profile void_profile("__void__", nullptr, -1.0); - return &void_profile; + static auto* void_profile = new Profile("__void__", nullptr, -1.0); + return void_profile; } Profile* ProfileBuilder::from_callback(const std::string& name, const std::function& cb, double repeat_delay) {