s4u::Link::SharingPolicy policy)
{
if (policy == s4u::Link::SharingPolicy::WIFI)
- return new NetworkWifiLink(this, name, bandwidths, get_maxmin_system());
+ return new NetworkWifiLink(name, bandwidths, get_maxmin_system());
xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth.");
- return new NetworkCm02Link(this, name, bandwidths[0], policy, get_maxmin_system());
+ return new NetworkCm02Link(name, bandwidths[0], policy, get_maxmin_system());
}
void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
/************
* Resource *
************/
-NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth,
- s4u::Link::SharingPolicy policy, kernel::lmm::System* system)
- : LinkImpl(model, name, system->constraint_new(this, sg_bandwidth_factor * bandwidth))
+NetworkCm02Link::NetworkCm02Link(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy,
+ kernel::lmm::System* system)
+ : LinkImpl(name, system->constraint_new(this, sg_bandwidth_factor * bandwidth))
{
bandwidth_.scale = 1.0;
bandwidth_.peak = bandwidth;
class NetworkCm02Link : public LinkImpl {
public:
- NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth,
- s4u::Link::SharingPolicy policy, lmm::System* system);
+ NetworkCm02Link(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy, lmm::System* system);
~NetworkCm02Link() override = default;
void apply_event(kernel::profile::Event* event, double value) override;
void set_bandwidth(double value) override;
* Resource *
************/
-LinkImpl::LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint)
- : Resource(name), piface_(this)
+LinkImpl::LinkImpl(const std::string& name, lmm::Constraint* constraint) : Resource(name), piface_(this)
{
- this->set_model(model)->set_constraint(constraint);
+ this->set_constraint(constraint);
if (name != "__loopback__")
xbt_assert(not s4u::Link::by_name_or_null(name), "Link '%s' declared several times in the platform.", name.c_str());
}
void LinkImpl::seal()
{
+ this->set_model(surf_network_model);
+
simgrid::s4u::Link::on_creation(*get_iface());
}
void LinkImpl::on_bandwidth_change() const
s4u::Link piface_;
protected:
- LinkImpl(NetworkModel* model, const std::string& name, lmm::Constraint* constraint);
+ LinkImpl(const std::string& name, lmm::Constraint* constraint);
LinkImpl(const LinkImpl&) = delete;
LinkImpl& operator=(const LinkImpl&) = delete;
~LinkImpl() override = default; // Use destroy() instead of this destructor.
s4u::Link::SharingPolicy policy)
{
xbt_assert(bandwidths.size() == 1, "ns-3 links must use only 1 bandwidth.");
- return new LinkNS3(this, name, bandwidths[0], policy);
+ return new LinkNS3(name, bandwidths[0], policy);
}
Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
* Resource *
************/
-LinkNS3::LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy)
- : LinkImpl(model, name, nullptr), sharing_policy_(policy)
+LinkNS3::LinkNS3(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy)
+ : LinkImpl(name, nullptr), sharing_policy_(policy)
{
bandwidth_.peak = bandwidth;
}
************/
class LinkNS3 : public LinkImpl {
public:
- explicit LinkNS3(NetworkNS3Model* model, const std::string& name, double bandwidth,
- s4u::Link::SharingPolicy policy);
+ explicit LinkNS3(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy);
~LinkNS3() override;
s4u::Link::SharingPolicy sharing_policy_;
* Resource *
************/
-NetworkWifiLink::NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
- lmm::System* system)
- : LinkImpl(model, name, system->constraint_new(this, 1))
+NetworkWifiLink::NetworkWifiLink(const std::string& name, std::vector<double> bandwidths, lmm::System* system)
+ : LinkImpl(name, system->constraint_new(this, 1))
{
for (auto bandwidth : bandwidths)
bandwidths_.push_back({bandwidth, 1.0, nullptr});
std::vector<Metric> decay_bandwidths_;
public:
- NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
- lmm::System* system);
+ NetworkWifiLink(const std::string& name, std::vector<double> bandwidths, lmm::System* system);
void set_host_rate(const s4u::Host* host, int rate_level);
/** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */
s4u::Link::SharingPolicy policy)
{
xbt_assert(bandwidths.size() == 1, "Non WIFI link must have only 1 bandwidth.");
- return new LinkL07(this, name, bandwidths[0], policy);
+ return new LinkL07(name, bandwidths[0], policy, get_maxmin_system());
}
/************
CpuL07::~CpuL07()=default;
-LinkL07::LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy)
- : LinkImpl(model, name, model->get_maxmin_system()->constraint_new(this, bandwidth))
+LinkL07::LinkL07(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy,
+ kernel::lmm::System* system)
+ : LinkImpl(name, system->constraint_new(this, bandwidth))
{
bandwidth_.peak = bandwidth;
}
}
-}
-}
+} // namespace surf
+} // namespace simgrid
class LinkL07 : public kernel::resource::LinkImpl {
public:
- LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy);
+ LinkL07(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy, kernel::lmm::System* system);
LinkL07(const LinkL07&) = delete;
LinkL07& operator=(const LinkL07&) = delete;
~LinkL07() override;