- if (host->getProperties() == NULL)
- return;
- char* all_power_values_str =
- (char*)xbt_dict_get_or_null(host->getProperties(), "watt_per_state");
- if (all_power_values_str == NULL)
- return;
-
- xbt_dynar_t all_power_values = xbt_str_split(all_power_values_str, ",");
- int pstate_nb = xbt_dynar_length(all_power_values);
-
- for (int i=0; i< pstate_nb; i++)
- {
- /* retrieve the power values associated with the current pstate */
- xbt_dynar_t current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
- xbt_assert(xbt_dynar_length(current_power_values) > 1,
- "Power properties incorrectly defined - "
- "could not retrieve min and max power values for host %s",
- host->getName().c_str());
-
- /* min_power corresponds to the idle power (cpu load = 0) */
- /* max_power is the power consumed at 100% cpu load */
- power_range_watts_list.push_back(power_range(
- atof(xbt_dynar_get_as(current_power_values, 0, char*)),
- atof(xbt_dynar_get_as(current_power_values, 1, char*))
- ));
- }
- xbt_dynar_free(&all_power_values);
+ if (host->properties() == nullptr)
+ return;
+ char* all_power_values_str = static_cast<char*>(xbt_dict_get_or_null(host->properties(), "watt_per_state"));
+ if (all_power_values_str == nullptr)
+ return;
+
+ xbt_dynar_t all_power_values = xbt_str_split(all_power_values_str, ",");
+ int pstate_nb = xbt_dynar_length(all_power_values);
+
+ for (int i=0; i< pstate_nb; i++) {
+ /* retrieve the power values associated with the current pstate */
+ xbt_dynar_t current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
+ xbt_assert(xbt_dynar_length(current_power_values) == 3,
+ "Power properties incorrectly defined - could not retrieve idle, min and max power values for host %s",
+ host->name().c_str());
+
+ /* min_power corresponds to the idle power (cpu load = 0) */
+ /* max_power is the power consumed at 100% cpu load */
+ char *msg_idle = bprintf("Invalid idle value for pstate %d on host %s: %%s", i, host->name().c_str());
+ char *msg_min = bprintf("Invalid min value for pstate %d on host %s: %%s", i, host->name().c_str());
+ char *msg_max = bprintf("Invalid max value for pstate %d on host %s: %%s", i, host->name().c_str());
+ PowerRange range(
+ xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 0, char*), msg_idle),
+ xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 1, char*), msg_min),
+ xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 2, char*), msg_max)
+ );
+ power_range_watts_list.push_back(range);
+ xbt_free(msg_idle);
+ xbt_free(msg_min);
+ xbt_free(msg_max);
+
+ xbt_dynar_free(¤t_power_values);
+ }
+ xbt_dynar_free(&all_power_values);