static int bob(int argc, char* argv[])
{
/* this host also tests the properties of the AS*/
- simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->getNetRoot();
+ simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root();
XBT_INFO("== Print the properties of the zone");
XBT_INFO(" Zone property: filename -> %s", root->getProperty("filename"));
XBT_INFO(" Zone property: date -> %s", root->getProperty("date"));
simgrid::s4u::Engine e(&argc, argv);
e.load_platform(argv[1]);
- std::vector<simgrid::kernel::routing::ClusterZone*>* clusters =
- new std::vector<simgrid::kernel::routing::ClusterZone*>;
+ std::vector<simgrid::kernel::routing::ClusterZone*> clusters =
+ e.filter_netzones_by_type<simgrid::kernel::routing::ClusterZone>();
- e.getNetzoneByType<simgrid::kernel::routing::ClusterZone>(clusters);
-
- for (auto c : *clusters) {
+ for (auto c : clusters) {
XBT_INFO("%s", c->get_cname());
std::vector<simgrid::s4u::Host*>* hosts = new std::vector<simgrid::s4u::Host*>;
c->getHosts(hosts);
delete hosts;
}
- delete clusters;
-
- std::vector<simgrid::kernel::routing::DragonflyZone*>* dragonfly_clusters =
- new std::vector<simgrid::kernel::routing::DragonflyZone*>;
-
- e.getNetzoneByType<simgrid::kernel::routing::DragonflyZone>(dragonfly_clusters);
+ std::vector<simgrid::kernel::routing::DragonflyZone*> dragonfly_clusters =
+ e.filter_netzones_by_type<simgrid::kernel::routing::DragonflyZone>();
- if (not dragonfly_clusters->empty()) {
- for (auto d : *dragonfly_clusters) {
+ if (not dragonfly_clusters.empty()) {
+ for (auto d : dragonfly_clusters) {
XBT_INFO("%s' dragonfly topology:", d->get_cname());
for (int i = 0; i < d->getHostCount(); i++) {
unsigned int coords[4];
}
}
}
- delete dragonfly_clusters;
return 0;
}
simgrid::s4u::Storage* storage_by_name_or_null(std::string name);
std::vector<simgrid::kernel::routing::NetPoint*> get_all_netpoints();
+ simgrid::kernel::routing::NetPoint* netpoint_by_name_or_null(std::string name);
- /** @brief Retrieve the root netzone, containing all others */
- simgrid::s4u::NetZone* getNetRoot();
+ simgrid::s4u::NetZone* get_netzone_root();
- simgrid::s4u::NetZone* getNetzoneByNameOrNull(const char* name);
+ simgrid::s4u::NetZone* netzone_by_name_or_null(const char* name);
- /** @brief Retrieves all netzones of the same type than the subtype of the whereto vector */
- template <class T> void getNetzoneByType(std::vector<T*> * whereto) { netzoneByTypeRecursive(getNetRoot(), whereto); }
-
- /** @brief Retrieve the netcard of the given name (or nullptr if not found) */
- simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(std::string name);
+ /** @brief Retrieves all netzones of the type indicated by the template argument */
+ template <class T> std::vector<T*> filter_netzones_by_type()
+ {
+ std::vector<T*> res;
+ filter_netzones_by_type_recursive(get_netzone_root(), &res);
+ return res;
+ }
/** Returns whether SimGrid was initialized yet -- mostly for internal use */
static bool is_initialized();
return get_all_hosts();
}
XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_count()") size_t getLinkCount() { return get_link_count(); }
- XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_list()")
- XBT_ATTRIB_DEPRECATED_v322("Engine::getLinkList() is deprecated in favor of Engine::get_all_links(). Please "
- "switch before v3.22") void getLinkList(std::vector<Link*>* list);
+ XBT_ATTRIB_DEPRECATED_v322("Engine::getLinkList() is deprecated in favor of Engine::get_all_links(). Please "
+ "switch before v3.22") void getLinkList(std::vector<Link*>* list);
XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_link_list()") std::vector<Link*> getAllLinks()
{
return get_all_links();
XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_clock()") static double getClock() { return get_clock(); }
XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_all_netpoints()") void getNetpointList(
std::vector<simgrid::kernel::routing::NetPoint*>* list);
+ XBT_ATTRIB_DEPRECATED_v323("Please use Engine::netpoint_by_name_or_null()")
+ simgrid::kernel::routing::NetPoint* getNetpointByNameOrNull(std::string name)
+ {
+ return netpoint_by_name_or_null(name);
+ }
+ XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_netzone_root()") simgrid::s4u::NetZone* getNetRoot()
+ {
+ return get_netzone_root();
+ }
+ XBT_ATTRIB_DEPRECATED_v323(
+ "Please use Engine::netzone_by_name_or_null()") simgrid::s4u::NetZone* getNetzoneByNameOrNull(const char* name)
+ {
+ return netzone_by_name_or_null(name);
+ }
+ template <class T>
+ XBT_ATTRIB_DEPRECATED_v323("Please use Engine::filter_netzones_by_type()") void getNetzoneByType(
+ std::vector<T*>* whereto)
+ {
+ filter_netzones_by_type_recursive(get_netzone_root(), whereto);
+ }
+
XBT_ATTRIB_DEPRECATED_v323("Please use Engine::get_instance()") static s4u::Engine* getInstance()
{
return get_instance();
/** Callback fired when the time cannot jump because of inter-actors deadlock */
extern XBT_PUBLIC xbt::signal<void(void)> on_deadlock;
-template <class T> XBT_PRIVATE void netzoneByTypeRecursive(s4u::NetZone* current, std::vector<T*>* whereto)
+template <class T> XBT_PRIVATE void filter_netzones_by_type_recursive(s4u::NetZone* current, std::vector<T*>* whereto)
{
for (auto const& elem : *(current->getChildren())) {
- netzoneByTypeRecursive(elem, whereto);
+ filter_netzones_by_type_recursive(elem, whereto);
if (elem == dynamic_cast<T*>(elem))
whereto->push_back(dynamic_cast<T*>(elem));
}
NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZoneContainer* father)
: Container::Container(name, "", father)
{
- netpoint_ = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name);
+ netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name);
xbt_assert(netpoint_, "Element '%s' not found", name.c_str());
if (father_) {
type_ = father_->type_->getOrCreateContainerType(std::string("L") + std::to_string(level));
{
xbt_assert(father, "Only the Root container has no father");
- netpoint_ = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name);
+ netpoint_ = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name);
xbt_assert(netpoint_, "Element '%s' not found", name.c_str());
trivaNodeTypes.insert(type_->get_name());
currentContainer.clear();
std::set<std::string>* filter = new std::set<std::string>;
XBT_DEBUG("Starting graph extraction.");
- recursiveGraphExtraction(simgrid::s4u::Engine::get_instance()->getNetRoot(), simgrid::instr::Container::getRoot(),
- filter);
+ recursiveGraphExtraction(simgrid::s4u::Engine::get_instance()->get_netzone_root(),
+ simgrid::instr::Container::getRoot(), filter);
XBT_DEBUG("Graph extraction finished.");
delete filter;
TRACE_paje_dump_buffer(true);
xbt_graph_t ret = xbt_graph_new_graph(0, nullptr);
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>;
- recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::get_instance()->getNetRoot(),
+ recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::get_instance()->get_netzone_root(),
simgrid::instr::Container::getRoot());
delete nodes;
delete edges;
*/
simgrid::kernel::routing::NetPoint* sg_netpoint_by_name_or_null(const char* name)
{
- return simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name);
+ return simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name);
}
NetZoneImpl::NetZoneImpl(NetZone* father, std::string name) : NetZone(father, name)
{
- xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(name.c_str()),
+ 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));
if (src->is_netzone()) {
std::string srcName = "router_" + src->get_name();
std::string dstName = "router_" + dst->get_name();
- route->gw_src = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(srcName.c_str());
- route->gw_dst = simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(dstName.c_str());
+ route->gw_src = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(srcName.c_str());
+ route->gw_dst = simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(dstName.c_str());
}
/* Retrieve the private links */
}
}
-s4u::NetZone* Engine::getNetRoot()
+/** @brief Retrieve the root netzone, containing all others */
+s4u::NetZone* Engine::get_netzone_root()
{
return pimpl->netzone_root_;
}
}
/** @brief Retrieve the NetZone of the given name (or nullptr if not found) */
-NetZone* Engine::getNetzoneByNameOrNull(const char* name)
+NetZone* Engine::netzone_by_name_or_null(const char* name)
{
- return netzone_by_name_recursive(getNetRoot(), name);
+ return netzone_by_name_recursive(get_netzone_root(), name);
}
/** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
-simgrid::kernel::routing::NetPoint* Engine::getNetpointByNameOrNull(std::string name)
+simgrid::kernel::routing::NetPoint* Engine::netpoint_by_name_or_null(std::string name)
{
auto netp = pimpl->netpoints_.find(name);
return netp == pimpl->netpoints_.end() ? nullptr : netp->second;
sg_netzone_t sg_zone_get_root()
{
- return simgrid::s4u::Engine::get_instance()->getNetRoot();
+ return simgrid::s4u::Engine::get_instance()->get_netzone_root();
}
const char* sg_zone_get_name(sg_netzone_t netzone)
sg_netzone_t sg_zone_get_by_name(const char* name)
{
- return simgrid::s4u::Engine::get_instance()->getNetzoneByNameOrNull(name);
+ return simgrid::s4u::Engine::get_instance()->netzone_by_name_or_null(name);
}
void sg_zone_get_sons(sg_netzone_t netzone, xbt_dict_t whereto)
if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::base;
- xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->getNetpointByNameOrNull(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());
simgrid::kernel::routing::NetPoint* netpoint =
{
if (ZONE_TAG) { // We need to retrieve the most recently opened zone
XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value);
- simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::get_instance()->getNetzoneByNameOrNull(A_surfxml_zone_id);
+ simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::get_instance()->netzone_by_name_or_null(A_surfxml_zone_id);
netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
} else {