1 /* Copyright (c) 2016-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef RESOURCE_FACTORSET_HPP
7 #define RESOURCE_FACTORSET_HPP
13 #include <string_view>
16 // Methods used to parse and store the values for timing injections in smpi
17 struct s_smpi_factor_t {
19 std::vector<double> values;
22 namespace simgrid::kernel::resource {
25 const std::string name_;
26 std::vector<s_smpi_factor_t> factors_;
27 double default_value_;
28 const std::function<double(std::vector<double> const&, double)> lambda_;
29 bool initialized_ = false;
32 // Parse the factor from a string
34 const std::string& name, double default_value = 1,
35 std::function<double(std::vector<double> const&, double)> const& lambda = [](std::vector<double> const& values,
36 double) { return values.front(); });
37 void parse(const std::string& string_values);
38 bool is_initialized() const { return initialized_; }
39 // Get the default value
40 double operator()() const;
41 // Get the factor to use for the provided size
42 double operator()(double size) const;
45 } // namespace simgrid::kernel::resource