+/** @brief Aggregates the callbacks used to build clusters netzones (Torus/Dragronfly/Fat-Tree) */
+struct ClusterCallbacks {
+ /**
+ * @brief Callback used to set the netpoint and gateway located at some leaf of clusters (Torus, FatTree, etc)
+ *
+ * The netpoint can be either a host, router or another netzone.
+ * Gateway must be non-null if netpoint is a netzone
+ *
+ * @param zone: The newly create zone, needed for creating new resources (hosts, links)
+ * @param coord: the coordinates of the element
+ * @param id: Internal identifier of the element
+ * @return pair<NetPoint*, NetPoint*>: returns a pair of netpoint and gateway.
+ */
+ using ClusterNetPointCb = std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*>(
+ NetZone* zone, const std::vector<unsigned long>& coord, unsigned long id);
+ /**
+ * @brief Callback used to set the links for some leaf of the cluster (Torus, FatTree, etc)
+ *
+ * The coord parameter depends on the cluster being created:
+ * - Torus: Direct translation of the Torus' dimensions, e.g. (0, 0, 0) for a 3-D Torus
+ * - Fat-Tree: A pair (level in the tree, id), e.g. (0, 0): first leaf and (1,0): first switch at level 1.
+ * - Dragonfly: a tuple (group, chassis, blades/routers, nodes), e.g. (0, 0, 0, 0) for first node in the cluster.
+ * Important: To identify the router inside a "group, chassis, blade", we use MAX_UINT in the last parameter (e.g. 0,
+ * 0, 0, 4294967295).
+ *
+ * @param zone: The newly create zone, needed for creating new resources (hosts, links)
+ * @param coord: the coordinates of the element
+ * @param id: Internal identifier of the element
+ * @return Pointer to the Link
+ */
+ using ClusterLinkCb = Link*(NetZone* zone, const std::vector<unsigned long>& coord, unsigned long id);
+
+ std::function<ClusterNetPointCb> netpoint;
+ std::function<ClusterLinkCb> loopback = {};
+ std::function<ClusterLinkCb> limiter = {};
+ explicit ClusterCallbacks(const std::function<ClusterNetPointCb>& set_netpoint)
+ : netpoint(set_netpoint){/*nothing to do */};
+ ClusterCallbacks(const std::function<ClusterNetPointCb>& set_netpoint,
+ const std::function<ClusterLinkCb>& set_loopback, const std::function<ClusterLinkCb>& set_limiter)
+ : netpoint(set_netpoint), loopback(set_loopback), limiter(set_limiter){/*nothing to do */};
+};
+/**
+ * @brief Create a torus zone
+ *
+ * Torus clusters are characterized by:
+ * - dimensions, eg. {3,3,3} creates a torus with X = 3 elements, Y = 3 and Z = 3. In total, this cluster have 27
+ * elements
+ * - inter-node communication: (bandwidth, latency, sharing_policy) the elements are connected through regular links
+ * with these characteristics
+ * More details in: <a href="https://simgrid.org/doc/latest/Platform_examples.html?highlight=torus#torus-cluster">Torus
+ * Cluster</a>
+ *
+ * Moreover, this method accepts 3 callbacks to populate the cluster: set_netpoint, set_loopback and set_limiter .
+ *
+ * Note that the all elements in a Torus cluster must have (or not) the same elements (loopback and limiter)
+ *
+ * @param name NetZone's name
+ * @param parent Pointer to parent's netzone (nullptr if root netzone). Needed to be able to create the resources inside
+ * the netzone
+ * @param dimensions List of positive integers (> 0) which determines the torus' dimensions
+ * @param set_callbacks Callbacks to set properties from cluster elements (netpoint, loopback and limiter)
+ * @param bandwidth Characteristics of the inter-nodes link
+ * @param latency Characteristics of the inter-nodes link
+ * @param sharing_policy Characteristics of the inter-nodes link
+ * @return Pointer to new netzone
+ */
+XBT_PUBLIC NetZone* create_torus_zone(const std::string& name, const NetZone* parent,
+ const std::vector<unsigned long>& dimensions,
+ const ClusterCallbacks& set_callbacks, double bandwidth, double latency,
+ Link::SharingPolicy sharing_policy);