+ links->insert({name, this});
+ XBT_DEBUG("Create link '%s'",name);
+
+ }
+
+ /** @brief use destroy() instead of this destructor */
+ Link::~Link() {
+ xbt_assert(currentlyDestroying_, "Don't delete Links directly. Call destroy() instead.");
+ }
+ /** @brief Fire the require callbacks and destroy the object
+ *
+ * Don't delete directly an Link, call l->destroy() instead.
+ */
+ void Link::destroy()
+ {
+ if (!currentlyDestroying_) {
+ currentlyDestroying_ = true;
+ onDestruction(this);
+ delete this;
+ }
+ }
+
+ bool Link::isUsed()
+ {
+ return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
+ }
+
+ double Link::getLatency()
+ {
+ return m_latency.peak * m_latency.scale;
+ }
+
+ double Link::getBandwidth()
+ {
+ return m_bandwidth.peak * m_bandwidth.scale;
+ }
+
+ int Link::sharingPolicy()
+ {
+ return lmm_constraint_sharing_policy(getConstraint());
+ }
+
+ void Link::turnOn(){
+ if (isOff()) {
+ Resource::turnOn();
+ onStateChange(this);
+ }
+ }
+ void Link::turnOff(){
+ if (isOn()) {
+ Resource::turnOff();
+ onStateChange(this);
+ }
+ }
+ void Link::setStateTrace(tmgr_trace_t trace) {
+ xbt_assert(m_stateEvent==NULL,"Cannot set a second state trace to Link %s", getName());
+ m_stateEvent = future_evt_set->add_trace(trace, 0.0, this);
+ }
+ void Link::setBandwidthTrace(tmgr_trace_t trace)
+ {
+ xbt_assert(m_bandwidth.event==NULL,"Cannot set a second bandwidth trace to Link %s", getName());
+ m_bandwidth.event = future_evt_set->add_trace(trace, 0.0, this);
+ }
+ void Link::setLatencyTrace(tmgr_trace_t trace)
+ {
+ xbt_assert(m_latency.event==NULL,"Cannot set a second latency trace to Link %s", getName());
+ m_latency.event = future_evt_set->add_trace(trace, 0.0, this);
+ }
+
+
+ /**********
+ * Action *
+ **********/
+
+ void NetworkAction::setState(Action::State state){
+ Action::State old = getState();
+ Action::setState(state);
+ networkActionStateChangedCallbacks(this, old, state);
+ }
+
+ }