int get_host_count() const;
/** @brief Make a host within that NetZone */
- s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count,
- const std::unordered_map<std::string, std::string>* props);
+ s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate, int core_count);
/** @brief Make a link within that NetZone */
virtual s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
- s4u::Link::SharingPolicy policy,
- const std::unordered_map<std::string, std::string>* props);
+ s4u::Link::SharingPolicy policy);
/** @brief Creates a new route in this NetZone */
virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
void seal() override;
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
- s4u::Link::SharingPolicy policy,
- const std::unordered_map<std::string, std::string>* props) override;
+ s4u::Link::SharingPolicy policy) override;
NetPoint* get_access_point() {return access_point_;}
private:
protected:
virtual ~Host(); // Call destroy() instead of manually deleting it.
- void set_netpoint(kernel::routing::NetPoint* netpoint) { pimpl_netpoint_ = netpoint; }
+ Host* set_netpoint(kernel::routing::NetPoint* netpoint);
#endif
public:
bool is_on() const;
const char* get_property(const std::string& key) const;
- void set_property(const std::string& key, const std::string& value);
+ Host* set_property(const std::string& key, const std::string& value);
const std::unordered_map<std::string, std::string>* get_properties() const;
- void set_properties(const std::unordered_map<std::string, std::string>& properties);
+ Host* set_properties(const std::unordered_map<std::string, std::string>& properties);
void set_state_profile(kernel::profile::Profile* p);
void set_speed_profile(kernel::profile::Profile* p);
void set_latency_profile(kernel::profile::Profile* profile);
const char* get_property(const std::string& key) const;
- void set_property(const std::string& key, const std::string& value);
+ Link* set_property(const std::string& key, const std::string& value);
+ const std::unordered_map<std::string, std::string>* get_properties() const;
+ Link* set_properties(const std::unordered_map<std::string, std::string>& properties);
/* The signals */
/** @brief Callback signal fired when a new Link is created */
}
s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
- s4u::Link::SharingPolicy policy,
- const std::unordered_map<std::string, std::string>* props)
+ s4u::Link::SharingPolicy policy)
{
static double last_warned_latency = sg_surf_precision;
if (latency != 0.0 && latency < last_warned_latency) {
auto* l = surf_network_model->create_link(name, bandwidths, latency, policy);
- if (props)
- l->set_properties(*props);
-
return l->get_iface();
}
+
s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate,
- int coreAmount, const std::unordered_map<std::string, std::string>* props)
+ int coreAmount)
{
- auto* res = new s4u::Host(name);
-
if (hierarchy_ == RoutingMode::unset)
hierarchy_ = RoutingMode::base;
- res->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
+ auto* res = (new s4u::Host(name))->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
surf_cpu_model_pm->create_cpu(res, speed_per_pstate, coreAmount);
- if (props != nullptr)
- res->set_properties(*props);
-
- s4u::Host::on_creation(*res); // notify the signal
-
return res;
}
}
}
s4u::Link* WifiZone::create_link(const std::string& name, const std::vector<double>& bandwidths, double latency,
- s4u::Link::SharingPolicy policy,
- const std::unordered_map<std::string, std::string>* props)
+ s4u::Link::SharingPolicy policy)
{
xbt_assert(wifi_link_ == nullptr,
"WIFI netzone %s contains more than one link. Please only declare one, the wifi link.", get_cname());
xbt_assert(policy == s4u::Link::SharingPolicy::WIFI, "Link %s in WIFI zone %s must follow the WIFI sharing policy.",
name.c_str(), get_cname());
- auto s4u_link = NetZoneImpl::create_link(name, bandwidths, latency, policy, props);
+ auto s4u_link = NetZoneImpl::create_link(name, bandwidths, latency, policy);
wifi_link_ = s4u_link->get_impl();
return s4u_link;
}
new surf::HostImpl(this);
}
+Host* Host::set_netpoint(kernel::routing::NetPoint* netpoint)
+{
+ pimpl_netpoint_ = netpoint;
+ return this;
+}
+
Host::~Host()
{
delete pimpl_;
return this->pimpl_->get_property(key);
}
-void Host::set_property(const std::string& key, const std::string& value)
+Host* Host::set_property(const std::string& key, const std::string& value)
{
kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+ return this;
}
-void Host::set_properties(const std::unordered_map<std::string, std::string>& properties)
+Host* Host::set_properties(const std::unordered_map<std::string, std::string>& properties)
{
kernel::actor::simcall([this, &properties] { this->pimpl_->set_properties(properties); });
+ return this;
}
/** Specify a profile turning the host on and off according to an exhaustive list or a stochastic law.
{
return this->pimpl_->get_property(key);
}
-void Link::set_property(const std::string& key, const std::string& value)
+Link* Link::set_property(const std::string& key, const std::string& value)
{
simgrid::kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+ return this;
}
+
+const std::unordered_map<std::string, std::string>* Link::get_properties() const
+{
+ return this->pimpl_->get_properties();
+}
+
+Link* Link::set_properties(const std::unordered_map<std::string, std::string>& properties)
+{
+ kernel::actor::simcall([this, &properties] { this->pimpl_->set_properties(properties); });
+ return this;
+}
+
} // namespace s4u
} // namespace simgrid
/** @brief Add a host to the current AS */
void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
{
- std::unordered_map<std::string, std::string> props;
+ simgrid::s4u::Host* host = routing_get_current()->create_host(args->id, args->speed_per_pstate, args->core_amount);
+
if (args->properties) {
- for (auto const& elm : *args->properties)
- props.insert({elm.first, elm.second});
+ host->set_properties(*args->properties);
delete args->properties;
}
- simgrid::s4u::Host* host =
- routing_get_current()->create_host(args->id, args->speed_per_pstate, args->core_amount, &props);
-
host->pimpl_->set_disks(args->disks, host);
/* Change from the defaults */
host->set_pstate(args->pstate);
if (not args->coord.empty())
new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
+
+ simgrid::s4u::Host::on_creation(*host); // notify the signal
}
/** @brief Add a "router" to the network element list */
static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* args, const std::string& link_name)
{
- std::unordered_map<std::string, std::string> props;
- if (args->properties)
- for (auto const& elm : *args->properties)
- props.insert({elm.first, elm.second});
+ simgrid::s4u::Link* link = routing_get_current()->create_link(link_name, args->bandwidths, args->latency, args->policy);
- const simgrid::s4u::Link* link =
- routing_get_current()->create_link(link_name, args->bandwidths, args->latency, args->policy, &props);
+ if (args->properties)
+ link->set_properties(*args->properties);
simgrid::kernel::resource::LinkImpl* l = link->get_impl();
if (args->latency_trace)
std::vector<double> speed_per_pstate;
speed_per_pstate.push_back(peer->speed);
- simgrid::s4u::Host* host = as->create_host(peer->id, speed_per_pstate, 1, nullptr);
+ simgrid::s4u::Host* host = as->create_host(peer->id, speed_per_pstate, 1);
as->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out, peer->coord);
host->set_state_profile(peer->state_trace);
if (peer->speed_trace)
host->set_speed_profile(peer->speed_trace);
+ simgrid::s4u::Host::on_creation(*host); // notify the signal
}
/* Pick the right models for CPU, net and host, and call their model_init_preparse */