public:
enum class Type { Host, Router, NetZone };
- NetPoint(const std::string& name, NetPoint::Type component_type, NetZoneImpl* netzone_p);
+ NetPoint(const std::string& name, NetPoint::Type component_type);
// Our rank in the vertices_ array of the netzone that contains us.
unsigned int id() const { return id_; }
const char* get_cname() const { return name_.c_str(); }
/** @brief the NetZone in which this NetPoint is included */
NetZoneImpl* get_englobing_zone() { return englobing_zone_; }
+ /** @brief Set the NetZone in which this NetPoint is included */
+ NetPoint* set_englobing_zone(NetZoneImpl* netzone_p);
bool is_netzone() const { return component_type_ == Type::NetZone; }
bool is_host() const { return component_type_ == Type::Host; }
bool operator<(const NetPoint& rhs) const { return name_ < rhs.name_; }
private:
- unsigned int id_;
+ unsigned int id_ = -1;
std::string name_;
NetPoint::Type component_type_;
NetZoneImpl* englobing_zone_;
virtual void do_seal(){};
protected:
- explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model);
+ explicit NetZoneImpl(const std::string& name);
NetZoneImpl(const NetZoneImpl&) = delete;
NetZoneImpl& operator=(const NetZoneImpl&) = delete;
virtual ~NetZoneImpl();
virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
+ /** @brief Set parent of this Netzone */
+ void set_parent(NetZoneImpl* parent);
+ /** @brief Set network model for this Netzone */
+ void set_network_model(simgrid::kernel::resource::NetworkModel* netmodel);
/* @brief get the route between two nodes in the full platform
*
namespace kernel {
namespace routing {
ClusterZone::ClusterZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel)
- : NetZoneImpl(father, name, netmodel)
+ : NetZoneImpl(name)
{
}
namespace kernel {
namespace routing {
-EmptyZone::EmptyZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel)
- : NetZoneImpl(father, name, netmodel)
+EmptyZone::EmptyZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel) : NetZoneImpl(name)
{
}
simgrid::xbt::signal<void(NetPoint&)> NetPoint::on_creation;
-NetPoint::NetPoint(const std::string& name, NetPoint::Type componentType, NetZoneImpl* netzone_p)
- : name_(name), component_type_(componentType), englobing_zone_(netzone_p)
+NetPoint::NetPoint(const std::string& name, NetPoint::Type componentType) : name_(name), component_type_(componentType)
{
- if (netzone_p != nullptr)
- id_ = netzone_p->add_component(this);
- else
- id_ = static_cast<decltype(id_)>(-1);
simgrid::s4u::Engine::get_instance()->netpoint_register(this);
simgrid::kernel::routing::NetPoint::on_creation(*this);
}
+
+NetPoint* NetPoint::set_englobing_zone(NetZoneImpl* netzone_p)
+{
+ englobing_zone_ = netzone_p;
+ if (netzone_p != nullptr)
+ id_ = netzone_p->add_component(this);
+ return this;
}
-}
-} // namespace simgrid::kernel::routing
+
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid
/** @brief Retrieve a netpoint from its name
*
namespace kernel {
namespace routing {
-NetZoneImpl::NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model)
- : piface_(this), father_(father), name_(name), network_model_(network_model)
+NetZoneImpl::NetZoneImpl(const std::string& name) : piface_(this), name_(name)
{
xbt_assert(nullptr == s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()),
"Refusing to create a second NetZone called '%s'.", get_cname());
-
- netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone, father_);
+ netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone);
cpu_model_vm_ = static_cast<simgrid::kernel::resource::CpuModel*>(
simgrid::kernel::EngineImpl::get_instance()->get_default_model(simgrid::kernel::resource::Model::Type::CPU_VM));
cpu_model_pm_ = static_cast<simgrid::kernel::resource::CpuModel*>(
hierarchy_ = RoutingMode::base;
auto* res = new s4u::Host(name);
- res->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
+ res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this));
cpu_model_pm_->create_cpu(res, speed_per_pstate)->set_core_count(core_amount)->seal();
sealed_ = true;
}
+void NetZoneImpl::set_parent(NetZoneImpl* parent)
+{
+ xbt_assert(sealed_ == false, "Impossible to set father to an already sealed NetZone(%s)", this->get_cname());
+ father_ = parent;
+ netpoint_->set_englobing_zone(father_);
+}
+
+void NetZoneImpl::set_network_model(simgrid::kernel::resource::NetworkModel* netmodel)
+{
+ network_model_ = netmodel;
+}
+
} // namespace routing
} // namespace kernel
} // namespace simgrid
namespace routing {
RoutedZone::RoutedZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel)
- : NetZoneImpl(father, name, netmodel)
+ : NetZoneImpl(name)
{
}
xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name),
"Refusing to create a router named '%s': this name already describes a node.", name.c_str());
- auto* netpoint =
- new simgrid::kernel::routing::NetPoint(name, simgrid::kernel::routing::NetPoint::Type::Router, current_routing);
+ auto* netpoint = new simgrid::kernel::routing::NetPoint(name, simgrid::kernel::routing::NetPoint::Type::Router);
+ netpoint->set_englobing_zone(current_routing);
XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id());
if (coords && strcmp(coords, ""))
} else {
xbt_die("Not a valid model!");
}
+ new_zone->set_parent(current_routing);
+ new_zone->set_network_model(netmodel);
if (current_routing == nullptr) { /* it is the first one */
simgrid::s4u::Engine::get_instance()->set_netzone_root(new_zone->get_iface());