class ClusterZone : public NetZoneImpl {
public:
- explicit ClusterZone(NetZone* father, std::string name);
+ explicit ClusterZone(NetZoneImpl* father, std::string name);
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
*/
class XBT_PRIVATE DijkstraZone : public RoutedZone {
public:
- DijkstraZone(NetZone* father, std::string name, bool cached);
+ DijkstraZone(NetZoneImpl* father, std::string name, bool cached);
void seal() override;
~DijkstraZone() override;
*/
class XBT_PUBLIC DragonflyZone : public ClusterZone {
public:
- explicit DragonflyZone(NetZone* father, std::string name);
+ explicit DragonflyZone(NetZoneImpl* father, std::string name);
~DragonflyZone() override;
// void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override;
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
class XBT_PRIVATE EmptyZone : public NetZoneImpl {
public:
- explicit EmptyZone(NetZone* father, std::string name);
+ explicit EmptyZone(NetZoneImpl* father, std::string name);
~EmptyZone() override;
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override
*/
class XBT_PRIVATE FatTreeZone : public ClusterZone {
public:
- explicit FatTreeZone(NetZone* father, std::string name);
+ explicit FatTreeZone(NetZoneImpl* father, std::string name);
~FatTreeZone() override;
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
*/
class XBT_PRIVATE FloydZone : public RoutedZone {
public:
- explicit FloydZone(NetZone* father, std::string name);
+ explicit FloydZone(NetZoneImpl* father, std::string name);
~FloydZone() override;
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
*/
class XBT_PRIVATE FullZone : public RoutedZone {
public:
- explicit FullZone(NetZone* father, std::string name);
+ explicit FullZone(NetZoneImpl* father, std::string name);
void seal() override;
~FullZone() override;
#include <xbt/graph.h>
#include <map>
+#include <vector>
namespace simgrid {
namespace kernel {
* called Autonomous Systems in this article).
*
*/
-class XBT_PUBLIC NetZoneImpl : public s4u::NetZone {
+class XBT_PUBLIC NetZoneImpl {
friend simgrid::kernel::EngineImpl; // it destroys netRoot_
protected:
- explicit NetZoneImpl(NetZone* father, std::string name);
+ explicit NetZoneImpl(NetZoneImpl* father, std::string name);
virtual ~NetZoneImpl();
+ s4u::NetZone piface_;
+
public:
+ s4u::NetZone* get_iface() { return &piface_; }
+
/** @brief Make an host within that NetZone */
simgrid::s4u::Host* create_host(const char* name, std::vector<double>* speed_per_pstate, int core_count,
std::map<std::string, std::string>* props);
/** @brief Creates a new route in this NetZone */
- void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
+ virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
+ std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
+
+ /** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
+ virtual void seal();
+ virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
+ 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);
protected:
/**
bool get_bypass_route(routing::NetPoint* src, routing::NetPoint* dst,
/* OUT */ std::vector<resource::LinkImpl*>& links, double* latency);
+private:
+ // our content, as known to our graph routing algorithm (maps vertex_id -> vertex)
+ std::vector<kernel::routing::NetPoint*> vertices_;
+
+ NetZoneImpl* father_ = nullptr;
+
+ std::vector<NetZoneImpl*> children_; // sub-netzones
+
public:
+ unsigned int get_table_size() { return vertices_.size(); }
+ std::vector<kernel::routing::NetPoint*> get_vertices() { return vertices_; }
+
+ NetZoneImpl* get_father();
+
+ std::vector<NetZoneImpl*>* get_children(); // Sub netzones
+
+private:
+ std::string name_;
+ bool sealed_ = false; // We cannot add more content when sealed
+
+public:
+ /** @brief Retrieves the name of that netzone as a C++ string */
+ const std::string& get_name() const { return name_; }
+ /** @brief Retrieves the name of that netzone as a C string */
+ const char* get_cname() const;
+
+ std::vector<s4u::Host*> get_all_hosts();
+ int get_host_count();
+
/* @brief get the route between two nodes in the full platform
*
* @param src where from
class XBT_PRIVATE RoutedZone : public NetZoneImpl {
public:
- explicit RoutedZone(NetZone* father, std::string name);
+ explicit RoutedZone(NetZoneImpl* father, std::string name);
void get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
std::map<std::string, xbt_edge_t>* edges) override;
class XBT_PRIVATE TorusZone : public ClusterZone {
public:
- explicit TorusZone(NetZone* father, std::string name);
+ explicit TorusZone(NetZoneImpl* father, std::string name);
void create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, unsigned int position) override;
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
void parse_specific_arguments(ClusterCreationArgs* cluster) override;
class XBT_PRIVATE VivaldiZone : public ClusterZone {
public:
- explicit VivaldiZone(NetZone* father, std::string name);
+ explicit VivaldiZone(NetZoneImpl* father, std::string name);
void set_peer_link(NetPoint* netpoint, double bw_in, double bw_out, std::string coord);
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
/** @brief Retrieves all netzones of the type indicated by the template argument */
template <class T> std::vector<T*> get_filtered_netzones()
{
+ static_assert(std::is_base_of<kernel::routing::NetZoneImpl, T>::value,
+ "Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
std::vector<T*> res;
get_filtered_netzones_recursive(get_netzone_root(), &res);
return res;
template <class T> XBT_PRIVATE void get_filtered_netzones_recursive(s4u::NetZone* current, std::vector<T*>* whereto)
{
- for (auto const& elem : *(current->get_children())) {
+ static_assert(std::is_base_of<kernel::routing::NetZoneImpl, T>::value,
+ "Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
+ for (auto const& elem : current->get_children()) {
get_filtered_netzones_recursive(elem, whereto);
- if (elem == dynamic_cast<T*>(elem))
- whereto->push_back(dynamic_cast<T*>(elem));
+ if (elem->get_impl() == dynamic_cast<T*>(elem->get_impl()))
+ whereto->push_back(dynamic_cast<T*>(elem->get_impl()));
}
}
}
protected:
friend simgrid::kernel::routing::NetZoneImpl;
- explicit NetZone(NetZone * father, std::string name);
- virtual ~NetZone();
+ explicit NetZone(kernel::routing::NetZoneImpl* impl);
+ ~NetZone();
+
+ kernel::routing::NetZoneImpl* pimpl_;
public:
- /** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
- virtual void seal();
/** @brief Retrieves the name of that netzone as a C++ string */
- const std::string& get_name() const { return name_; }
+ const std::string& get_name() const;
/** @brief Retrieves the name of that netzone as a C string */
const char* get_cname() const;
NetZone* get_father();
- std::vector<NetZone*>* get_children(); // Sub netzones
std::vector<Host*> get_all_hosts();
int get_host_count();
+ kernel::routing::NetZoneImpl* get_impl() { return pimpl_; }
+
private:
std::unordered_map<std::string, std::string> properties_;
/** Get the properties assigned to a netzone */
std::unordered_map<std::string, std::string>* get_properties();
+ std::vector<NetZone*> get_children();
+
/** Retrieve the property value (or nullptr if not set) */
const char* get_property(const char* key);
void set_property(const char* key, const char* value);
/* Add content to the netzone, at parsing time. It should be sealed afterward. */
- virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
- 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);
- virtual void add_bypass_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) = 0;
+ int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
+ 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);
+ void add_bypass_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);
/*** Called on each newly created regular route (not on bypass routes) */
static simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
static simgrid::xbt::signal<void(NetZone&)> on_creation;
static simgrid::xbt::signal<void(NetZone&)> on_seal;
-private:
- // our content, as known to our graph routing algorithm (maps vertex_id -> vertex)
- std::vector<kernel::routing::NetPoint*> vertices_;
-
-protected:
- unsigned int get_table_size() { return vertices_.size(); }
- std::vector<kernel::routing::NetPoint*> get_vertices() { return vertices_; }
-
-private:
- NetZone* father_ = nullptr;
- std::string name_;
-
- bool sealed_ = false; // We cannot add more content when sealed
-
- std::vector<NetZone*>* children_ = nullptr; // sub-netzones
-
public: // Deprecation wrappers
XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_father()") NetZone* getFather() { return get_father(); }
XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_name()") const std::string& getName() const { return get_name(); }
{
set_property(key, value);
}
- XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::add_component()") virtual int addComponent(
- kernel::routing::NetPoint* elm)
+ XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::add_component()") int addComponent(kernel::routing::NetPoint* elm)
{
return add_component(elm);
}
- XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_vertices()") std::vector<kernel::routing::NetPoint*> getVertices()
- {
- return get_vertices();
- }
+ XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_vertices()") std::vector<kernel::routing::NetPoint*> getVertices();
XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_host_count()") int getHostCount() { return get_host_count(); }
XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_all_hosts()") void getHosts(
std::vector<s4u::Host*>* whereto); // retrieve my content as a vector of hosts
XBT_ATTRIB_DEPRECATED_v323("Please use NetZone::get_children()") std::vector<NetZone*>* getChildren()
{
- return get_children();
+ std::vector<NetZone*>* res = new std::vector<NetZone*>();
+ for (auto child : get_children())
+ res->push_back(child);
+ return res;
}
};
}
if (not cls)
return nullptr;
- jtable = env->NewObjectArray(static_cast<jsize>(self_as->get_children()->size()), cls, nullptr);
+ jtable = env->NewObjectArray(static_cast<jsize>(self_as->get_children().size()), cls, nullptr);
if (not jtable) {
jxbt_throw_jni(env, "Hosts table allocation failed");
return nullptr;
}
- for (auto const& tmp_as : *self_as->get_children()) {
+ for (auto const& tmp_as : self_as->get_children()) {
jobject tmp_jas = jnetzone_new_instance(env);
if (not tmp_jas) {
jxbt_throw_jni(env, "java As instantiation failed");
simgrid::kernel::routing::ZoneCreationArgs AS;
AS.id = id;
AS.routing = mode_int;
- simgrid::s4u::NetZone* new_as = sg_platf_new_Zone_begin(&AS);
+ simgrid::kernel::routing::NetZoneImpl* new_as = sg_platf_new_Zone_begin(&AS);
/* Build a Lua representation of the new AS on the stack */
lua_newtable(L);
- simgrid::s4u::NetZone** lua_as =
- (simgrid::s4u::NetZone**)lua_newuserdata(L, sizeof(simgrid::s4u::NetZone*)); /* table userdatum */
+ simgrid::kernel::routing::NetZoneImpl** lua_as = (simgrid::kernel::routing::NetZoneImpl**)lua_newuserdata(
+ L, sizeof(simgrid::kernel::routing::NetZoneImpl*)); /* table userdatum */
*lua_as = new_as;
luaL_getmetatable(L, PLATF_MODULE_NAME); /* table userdatum metatable */
lua_setmetatable(L, -2); /* table userdatum */
return;
}
XBT_DEBUG("Graph extraction for NetZone = %s", netzone->get_cname());
- if (not netzone->get_children()->empty()) {
+ if (not netzone->get_children().empty()) {
// bottom-up recursion
- for (auto const& nz_son : *netzone->get_children()) {
+ for (auto const& nz_son : netzone->get_children()) {
container_t child_container = container->children_.at(nz_son->get_cname());
recursiveGraphExtraction(nz_son, child_container, filter);
}
std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
- static_cast<simgrid::kernel::routing::NetZoneImpl*>(netzone)->get_graph(graph, nodes, edges);
+ netzone->get_impl()->get_graph(graph, nodes, edges);
for (auto elm : *edges) {
xbt_edge_t edge = elm.second;
linkContainers(simgrid::instr::Container::by_name(static_cast<const char*>(edge->src->data)),
std::map<std::string, xbt_edge_t>* edges, sg_netzone_t netzone,
container_t container)
{
- if (not netzone->get_children()->empty()) {
+ if (not netzone->get_children().empty()) {
// bottom-up recursion
- for (auto const& netzone_child : *netzone->get_children()) {
+ for (auto const& netzone_child : netzone->get_children()) {
container_t child_container = container->children_.at(netzone_child->get_cname());
recursiveXBTGraphExtraction(graph, nodes, edges, netzone_child, child_container);
}
}
- static_cast<simgrid::kernel::routing::NetZoneImpl*>(netzone)->get_graph(graph, nodes, edges);
+ netzone->get_impl()->get_graph(graph, nodes, edges);
}
xbt_graph_t instr_routing_platform_graph()
void Container::create_hierarchy(sg_netzone_t from_as)
{
- if (from_as->get_children()->empty()) {
+ if (from_as->get_children().empty()) {
// I am no AS
// add hosts to jedule platform
std::vector<sg_host_t> table = from_as->get_all_hosts();
this->add_resources(table);
} else {
- for (auto const& nz : *from_as->get_children()) {
+ for (auto const& nz : from_as->get_children()) {
jed_container_t child_container = new simgrid::jedule::Container(std::string(nz->get_cname()));
this->add_child(child_container);
child_container->create_hierarchy(nz);
namespace simgrid {
namespace kernel {
namespace routing {
-ClusterZone::ClusterZone(NetZone* father, std::string name) : NetZoneImpl(father, name)
-{
-}
+ClusterZone::ClusterZone(NetZoneImpl* father, std::string name) : NetZoneImpl(father, name) {}
void ClusterZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
{
/* Creation routing model functions */
-DijkstraZone::DijkstraZone(NetZone* father, std::string name, bool cached) : RoutedZone(father, name), cached_(cached)
+DijkstraZone::DijkstraZone(NetZoneImpl* father, std::string name, bool cached)
+ : RoutedZone(father, name), cached_(cached)
{
}
namespace kernel {
namespace routing {
-DragonflyZone::DragonflyZone(NetZone* father, std::string name) : ClusterZone(father, name)
-{
-}
+DragonflyZone::DragonflyZone(NetZoneImpl* father, std::string name) : ClusterZone(father, name) {}
DragonflyZone::~DragonflyZone()
{
namespace kernel {
namespace routing {
-EmptyZone::EmptyZone(NetZone* father, std::string name) : NetZoneImpl(father, name)
-{
-}
+EmptyZone::EmptyZone(NetZoneImpl* father, std::string name) : NetZoneImpl(father, name) {}
EmptyZone::~EmptyZone() = default;
namespace kernel {
namespace routing {
-FatTreeZone::FatTreeZone(NetZone* father, std::string name) : ClusterZone(father, name)
+FatTreeZone::FatTreeZone(NetZoneImpl* father, std::string name) : ClusterZone(father, name)
{
XBT_DEBUG("Creating a new fat tree.");
}
namespace kernel {
namespace routing {
-FloydZone::FloydZone(NetZone* father, std::string name) : RoutedZone(father, name)
+FloydZone::FloydZone(NetZoneImpl* father, std::string name) : RoutedZone(father, name)
{
predecessor_table_ = nullptr;
cost_table_ = nullptr;
namespace simgrid {
namespace kernel {
namespace routing {
-FullZone::FullZone(NetZone* father, std::string name) : RoutedZone(father, name)
-{
-}
+FullZone::FullZone(NetZoneImpl* father, std::string name) : RoutedZone(father, name) {}
void FullZone::seal()
{
std::vector<resource::LinkImpl*> links;
};
-NetZoneImpl::NetZoneImpl(NetZone* father, std::string name) : NetZone(father, name)
+NetZoneImpl::NetZoneImpl(NetZoneImpl* father, std::string name) : piface_(this), father_(father), name_(name)
{
xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name.c_str()),
"Refusing to create a second NetZone called '%s'.", name.c_str());
- netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, static_cast<NetZoneImpl*>(father));
+ netpoint_ = new NetPoint(name, NetPoint::Type::NetZone, father);
XBT_DEBUG("NetZone '%s' created with the id '%u'", name.c_str(), netpoint_->id());
}
NetZoneImpl::~NetZoneImpl()
{
+ for (auto const& nz : children_)
+ delete nz;
+
for (auto const& kv : bypass_routes_)
delete kv.second;
simgrid::s4u::Engine::get_instance()->netpoint_unregister(netpoint_);
}
+const char* NetZoneImpl::get_cname() const
+{
+ return name_.c_str();
+}
+NetZoneImpl* NetZoneImpl::get_father()
+{
+ return father_;
+}
+void NetZoneImpl::seal()
+{
+ sealed_ = true;
+}
+/** @brief Returns the list of direct children (no grand-children)
+ *
+ * This returns the internal data, no copy. Don't mess with it.
+ */
+std::vector<NetZoneImpl*>* NetZoneImpl::get_children()
+{
+ return &children_;
+}
+/** @brief Returns the list of the hosts found in this NetZone (not recursively)
+ *
+ * Only the hosts that are directly contained in this NetZone are retrieved,
+ * not the ones contained in sub-netzones.
+ */
+std::vector<s4u::Host*> NetZoneImpl::get_all_hosts()
+{
+ std::vector<s4u::Host*> res;
+ for (auto const& card : get_vertices()) {
+ s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
+ if (host != nullptr)
+ res.push_back(host);
+ }
+ return res;
+}
+int NetZoneImpl::get_host_count()
+{
+ int count = 0;
+ for (auto const& card : get_vertices()) {
+ s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
+ if (host != nullptr)
+ count++;
+ }
+ return count;
+}
simgrid::s4u::Host* NetZoneImpl::create_host(const char* name, std::vector<double>* speedPerPstate, int coreAmount,
std::map<std::string, std::string>* props)
return res;
}
+int NetZoneImpl::add_component(kernel::routing::NetPoint* elm)
+{
+ vertices_.push_back(elm);
+ return vertices_.size() - 1; // The rank of the newly created object
+}
+void NetZoneImpl::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*/)
+{
+ xbt_die("NetZone '%s' does not accept new routes (wrong class).", name_.c_str());
+}
+
void NetZoneImpl::add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
{
/* (1) find the path to the root routing component */
std::vector<NetZoneImpl*> path_src;
- NetZone* current = src->get_englobing_zone();
+ NetZoneImpl* current = src->get_englobing_zone();
while (current != nullptr) {
path_src.push_back(static_cast<NetZoneImpl*>(current));
current = current->father_;
namespace kernel {
namespace routing {
-RoutedZone::RoutedZone(NetZone* father, std::string name) : NetZoneImpl(father, name)
-{
-}
+RoutedZone::RoutedZone(NetZoneImpl* father, std::string name) : NetZoneImpl(father, name) {}
void RoutedZone::get_graph(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
std::map<std::string, xbt_edge_t>* edges)
xbt_assert(src, "Cannot find a route from nullptr to %s", dst->get_cname());
xbt_assert(dst, "Cannot find a route from %s to nullptr", src->get_cname());
- NetZone* src_as = src->get_englobing_zone();
- NetZone* dst_as = dst->get_englobing_zone();
+ NetZoneImpl* src_as = src->get_englobing_zone();
+ NetZoneImpl* dst_as = dst->get_englobing_zone();
xbt_assert(src_as == dst_as,
"Internal error: %s@%s and %s@%s are not in the same netzone as expected. Please report that bug.",
dstName, gw_dst->get_cname());
}
- on_route_creation(symmetrical, src, dst, gw_src, gw_dst, link_list);
+ piface_.on_route_creation(symmetrical, src, dst, gw_src, gw_dst, link_list);
}
}
}
namespace simgrid {
namespace kernel {
namespace routing {
-TorusZone::TorusZone(NetZone* father, std::string name) : ClusterZone(father, name)
-{
-}
+TorusZone::TorusZone(NetZoneImpl* father, std::string name) : ClusterZone(father, name) {}
void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int rank, unsigned int position)
{
return &coords->coords;
}
-VivaldiZone::VivaldiZone(NetZone* father, std::string name) : ClusterZone(father, name)
-{
-}
+VivaldiZone::VivaldiZone(NetZoneImpl* father, std::string name) : ClusterZone(father, name) {}
void VivaldiZone::set_peer_link(NetPoint* netpoint, double bw_in, double bw_out, std::string coord)
{
/** @brief Retrieve the root netzone, containing all others */
s4u::NetZone* Engine::get_netzone_root()
{
- return pimpl->netzone_root_;
+ return pimpl->netzone_root_->get_iface();
}
/** @brief Set the root netzone, containing all others. Once set, it cannot be changed. */
void Engine::set_netzone_root(s4u::NetZone* netzone)
{
xbt_assert(pimpl->netzone_root_ == nullptr, "The root NetZone cannot be changed once set");
- pimpl->netzone_root_ = static_cast<kernel::routing::NetZoneImpl*>(netzone);
+ pimpl->netzone_root_ = netzone->get_impl();
}
static s4u::NetZone* netzone_by_name_recursive(s4u::NetZone* current, const char* name)
if (not strcmp(current->get_cname(), name))
return current;
- for (auto const& elem : *(current->get_children())) {
+ for (auto const& elem : current->get_children()) {
simgrid::s4u::NetZone* tmp = netzone_by_name_recursive(elem, name);
if (tmp != nullptr) {
return tmp;
simgrid::xbt::signal<void(NetZone&)> NetZone::on_creation;
simgrid::xbt::signal<void(NetZone&)> NetZone::on_seal;
-NetZone::NetZone(NetZone* father, std::string name) : father_(father), name_(name)
-{
- children_ = new std::vector<NetZone*>();
-}
-
-void NetZone::seal()
-{
- sealed_ = true;
-}
+NetZone::NetZone(kernel::routing::NetZoneImpl* impl) : pimpl_(impl) {}
NetZone::~NetZone()
{
- for (auto const& nz : *children_)
- delete nz;
- delete children_;
}
std::unordered_map<std::string, std::string>* NetZone::get_properties()
simgrid::simix::simcall([this, key, value] { properties_[key] = value; });
}
-/** @brief Returns the list of direct children (no grand-children)
- *
- * This function returns the internal copy of the children, not a copy. Don't mess with it!
- */
-std::vector<NetZone*>* NetZone::get_children()
+/** @brief Returns the list of direct children (no grand-children) */
+std::vector<NetZone*> NetZone::get_children()
{
- return children_;
+ std::vector<NetZone*> res;
+ for (auto child : *(pimpl_->get_children()))
+ res.push_back(child->get_iface());
+ return res;
}
+const std::string& NetZone::get_name() const
+{
+ return pimpl_->get_name();
+}
const char* NetZone::get_cname() const
{
- return name_.c_str();
+ return pimpl_->get_cname();
}
NetZone* NetZone::get_father()
{
- return father_;
+ return pimpl_->get_father()->get_iface();
}
/** @brief Returns the list of the hosts found in this NetZone (not recursively)
*/
std::vector<Host*> NetZone::get_all_hosts()
{
- std::vector<Host*> res;
- for (auto const& card : vertices_) {
- s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
- if (host != nullptr)
- res.push_back(host);
- }
- return res;
+ return pimpl_->get_all_hosts();
}
void NetZone::getHosts(std::vector<s4u::Host*>* whereto)
{
- for (auto const& card : vertices_) {
+ for (auto const& card : pimpl_->get_vertices()) {
s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
if (host != nullptr)
whereto->push_back(host);
int NetZone::get_host_count()
{
- int count = 0;
- for (auto const& card : vertices_) {
- s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->get_name());
- if (host != nullptr)
- count++;
- }
- return count;
+ return pimpl_->get_host_count();
}
int NetZone::add_component(kernel::routing::NetPoint* elm)
{
- vertices_.push_back(elm);
- return vertices_.size() - 1; // The rank of the newly created object
+ return pimpl_->add_component(elm);
}
-void NetZone::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*/)
+void NetZone::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)
{
- xbt_die("NetZone '%s' does not accept new routes (wrong class).", name_.c_str());
+ pimpl_->add_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
+}
+void NetZone::add_bypass_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)
+{
+ pimpl_->add_bypass_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
+}
+std::vector<kernel::routing::NetPoint*> NetZone::getVertices()
+{
+ return pimpl_->get_vertices();
}
-
} // namespace s4u
} // namespace simgrid
void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto)
{
- for (auto const& elem : *netzone->get_children()) {
+ for (auto const& elem : netzone->get_children()) {
xbt_dict_set(whereto, elem->get_cname(), static_cast<void*>(elem), nullptr);
}
}
*
* @param zone the parameters defining the Zone to build.
*/
-simgrid::s4u::NetZone* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone)
+simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone)
{
if (not surf_parse_models_setup_already_called) {
simgrid::s4u::on_platform_creation();
}
if (current_routing == nullptr) { /* it is the first one */
- simgrid::s4u::Engine::get_instance()->set_netzone_root(new_zone);
+ simgrid::s4u::Engine::get_instance()->set_netzone_root(new_zone->get_iface());
} else {
/* set the father behavior */
if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::recursive;
/* add to the sons dictionary */
- current_routing->get_children()->push_back(static_cast<simgrid::s4u::NetZone*>(new_zone));
+ current_routing->get_children()->push_back(new_zone);
}
/* set the new current component of the tree */
current_routing = new_zone;
- simgrid::s4u::NetZone::on_creation(*new_zone); // notify the signal
+ simgrid::s4u::NetZone::on_creation(*new_zone->get_iface()); // notify the signal
return new_zone;
}
{
xbt_assert(current_routing, "Cannot seal the current AS: none under construction");
current_routing->seal();
- simgrid::s4u::NetZone::on_seal(*current_routing);
+ simgrid::s4u::NetZone::on_seal(*current_routing->get_iface());
current_routing = static_cast<simgrid::kernel::routing::NetZoneImpl*>(current_routing->get_father());
}
void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb);
/*** END of the parsing cruft ***/
-XBT_PUBLIC simgrid::s4u::NetZone* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
+XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
+sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
XBT_PUBLIC void sg_platf_new_Zone_seal(); // That Zone is fully described
XBT_PUBLIC void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone