class LegacyUpdateCb {
std::vector<StochasticDatedValue> pattern;
-
- bool stochastic;
-
+ bool stochastic = false;
bool loop;
-
- double loop_delay;
+ double loop_delay = 0.0;
static bool is_comment_or_empty_line(const std::string& val)
{
static bool is_uniform_distribution(const std::string& val) { return (val == "UNIF" || val == "UNIFORM"); }
public:
- LegacyUpdateCb(const std::string& input, double periodicity) : stochastic(false), loop(periodicity > 0), loop_delay(0)
+ LegacyUpdateCb(const std::string& input, double periodicity) : loop(periodicity > 0)
{
int linecount = 0;
std::vector<std::string> list;
}
xbt_assert(splittedval.size() > i, "Invalid profile line");
- if (i == 1 or i == 2) {
+ if (i == 1 || i == 2) {
stochevent.date_params = {std::stod(splittedval[i - 1])};
} else if (i == 3) {
stochevent.date_params = {std::stod(splittedval[1]), std::stod(splittedval[2])};
}
xbt_assert(splittedval.size() > i + j, "Invalid profile line");
- if (j == 0 or j == 1) {
+ if (j == 0 || j == 1) {
stochevent.value_params = {std::stod(splittedval[i + j])};
} else if (j == 2) {
stochevent.value_params = {std::stod(splittedval[i + 1]), std::stod(splittedval[i + 2])};
pattern.emplace_back(stochevent);
}
- xbt_assert(not stochastic or periodicity <= 0, "If you want periodicity with stochastic profiles, use LOOP_AFTER");
+ xbt_assert(not stochastic || periodicity <= 0, "If you want periodicity with stochastic profiles, use LOOP_AFTER");
if (periodicity > 0) {
- xbt_assert(loop and loop_delay == 0);
+ xbt_assert(loop && loop_delay == 0);
loop_delay = periodicity - last_date;
}
xbt_assert(loop_delay >= 0, "Profile loop conditions are not realizable!");
}
- double get_repeat_delay()
+ double get_repeat_delay() const
{
- if (not stochastic and loop)
+ if (not stochastic && loop)
return loop_delay;
return -1.0;
}
- void operator()(std::vector<DatedValue>& event_list)
+ void operator()(std::vector<DatedValue>& event_list) const
{
size_t initial_size = event_list.size();
- if (loop or not initial_size) {
- for (auto dv : pattern)
+ if (loop || not initial_size) {
+ for (auto const& dv : pattern)
event_list.emplace_back(dv.get_datedvalue());
if (initial_size)
event_list.at(initial_size).date_ += loop_delay;
Profile* ProfileBuilder::from_void() {
- static Profile void_profile("__void__",[](std::vector<DatedValue>&){},-1.0);
+ static Profile void_profile("__void__", nullptr, -1.0);
return &void_profile;
}