for (int i = 0; i < n; i++) {
double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i);
/* Beware of composite actions: ptasks put links and cpus together. Extra pb: we cannot dynamic_cast from void* */
- simgrid::kernel::resource::Resource* resource =
- static_cast<simgrid::kernel::resource::Resource*>(action.get_variable()->get_constraint(i)->get_id());
+ simgrid::kernel::resource::Resource* resource = action.get_variable()->get_constraint(i)->get_id();
simgrid::kernel::resource::Cpu* cpu = dynamic_cast<simgrid::kernel::resource::Cpu*>(resource);
if (cpu != nullptr)
delete cnst;
}
-Constraint::Constraint(void* id_value, double bound_value) : bound_(bound_value), id_(id_value)
+Constraint::Constraint(resource::Resource* id_value, double bound_value) : bound_(bound_value), id_(id_value)
{
rank_ = next_rank_++;
cnst_light_ = nullptr;
}
-Constraint* System::constraint_new(void* id, double bound_value)
+Constraint* System::constraint_new(resource::Resource* id, double bound_value)
{
Constraint* cnst = new Constraint(id, bound_value);
insert_constraint(cnst);
class XBT_PUBLIC Constraint {
public:
Constraint() = delete;
- Constraint(void* id_value, double bound_value);
+ Constraint(resource::Resource* id_value, double bound_value);
/** @brief Unshare a constraint. */
void unshare() { sharing_policy_ = s4u::Link::SharingPolicy::FATPIPE; }
* @brief Get the data associated to a constraint
* @return The data associated to the constraint
*/
- void* get_id() const { return id_; }
+ resource::Resource* get_id() const { return id_; }
/* hookup to system */
boost::intrusive::list_member_hook<> constraint_set_hook_;
static int next_rank_; // To give a separate rank_ to each contraint
int concurrency_limit_; /* The maximum number of variables that may be enabled at any time (stage variables if
* necessary) */
- void* id_;
+ resource::Resource* id_;
};
/**
* @param id Data associated to the constraint (e.g.: a network link)
* @param bound_value The bound value of the constraint
*/
- Constraint* constraint_new(void* id, double bound_value);
+ Constraint* constraint_new(resource::Resource* id, double bound_value);
/**
* @brief Create a new Linear MaxMin variable
for (int i = 0; i < llen; i++) {
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
- Resource* resource = static_cast<Resource*>(get_variable()->get_constraint(i)->get_id());
+ Resource* resource = get_variable()->get_constraint(i)->get_id();
Cpu* cpu = dynamic_cast<Cpu*>(resource);
if (cpu != nullptr)
retlist.push_back(cpu);
for (int i = 0; i < llen; i++) {
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
- Resource* resource = static_cast<Resource*>(get_variable()->get_constraint(i)->get_id());
+ Resource* resource = get_variable()->get_constraint(i)->get_id();
LinkImpl* link = dynamic_cast<LinkImpl*>(resource);
if (link != nullptr)
retlist.push_back(link);
kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
while (cnst != nullptr) {
i++;
- void* constraint_id = cnst->get_id();
- if (not static_cast<simgrid::kernel::resource::Resource*>(constraint_id)->is_on()) {
+ kernel::resource::Resource* constraint_id = cnst->get_id();
+ if (not constraint_id->is_on()) {
XBT_DEBUG("Action (%p) Failed!!", &action);
action.finish(kernel::resource::Action::State::FAILED);
break;