+ xbt_assert(stateEvent_ == nullptr, "Cannot set a second state trace to Link %s", get_cname());
+ stateEvent_ = future_evt_set->add_trace(trace, this);
+}
+void LinkImpl::setBandwidthTrace(tmgr_trace_t trace)
+{
+ xbt_assert(bandwidth_.event == nullptr, "Cannot set a second bandwidth trace to Link %s", get_cname());
+ bandwidth_.event = future_evt_set->add_trace(trace, this);
+}
+void LinkImpl::setLatencyTrace(tmgr_trace_t trace)
+{
+ xbt_assert(latency_.event == nullptr, "Cannot set a second latency trace to Link %s", get_cname());
+ latency_.event = future_evt_set->add_trace(trace, this);
+}
+
+/**********
+ * Action *
+ **********/
+
+void NetworkAction::set_state(Action::State state)
+{
+ Action::State previous = get_state();
+ Action::set_state(state);
+ if (previous != state) // Trigger only if the state changed
+ s4u::Link::on_communication_state_change(this);
+}
+
+/** @brief returns a list of all Links that this action is using */
+std::list<LinkImpl*> NetworkAction::links()
+{
+ std::list<LinkImpl*> retlist;
+ int llen = get_variable()->get_number_of_constraint();
+
+ 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());
+ LinkImpl* link = dynamic_cast<LinkImpl*>(resource);
+ if (link != nullptr)
+ retlist.push_back(link);
+ }
+
+ return retlist;
+}
+}
+} // namespace kernel