From a079934fedd2dbda265e0511fd5ba6b344404875 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 9 Mar 2018 16:39:20 +0100 Subject: [PATCH] Also simplify the API of Engine::getLinkList --- include/simgrid/s4u/Engine.hpp | 3 +++ src/s4u/s4u_engine.cpp | 9 ++++++++- src/surf/plugins/link_energy.cpp | 3 +-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index bc7d410db6..8b2f0cdc93 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -62,11 +62,14 @@ protected: public: simgrid::s4u::Host* hostByName(std::string name); simgrid::s4u::Host* hostByNameOrNull(std::string name); + size_t getHostCount(); void getHostList(std::vector * whereTo); std::vector getHostList(); + size_t getLinkCount(); void getLinkList(std::vector * list); + std::vector getLinkList(); /** @brief Run the simulation */ void run(); diff --git a/src/s4u/s4u_engine.cpp b/src/s4u/s4u_engine.cpp index e5fce94804..5a231d6b1a 100644 --- a/src/s4u/s4u_engine.cpp +++ b/src/s4u/s4u_engine.cpp @@ -122,11 +122,18 @@ size_t Engine::getLinkCount() { return simgrid::surf::LinkImpl::linksCount(); } -/** @brief Fills the passed list with all hosts found in the platform */ +/** @brief Fills the passed list with all links found in the platform */ void Engine::getLinkList(std::vector* list) { simgrid::surf::LinkImpl::linksList(list); } +/** @brief Returns the list of all links found in the platform */ +std::vector Engine::getLinkList() +{ + std::vector res; + simgrid::surf::LinkImpl::linksList(&res); + return res; +} void Engine::run() { if (MC_is_active()) { diff --git a/src/surf/plugins/link_energy.cpp b/src/surf/plugins/link_energy.cpp index 34e71ae6fc..cee5ad2bcf 100644 --- a/src/surf/plugins/link_energy.cpp +++ b/src/surf/plugins/link_energy.cpp @@ -164,8 +164,7 @@ static void onCommunicate(simgrid::surf::NetworkAction* action, simgrid::s4u::Ho static void onSimulationEnd() { - std::vector links; - simgrid::s4u::Engine::getInstance()->getLinkList(&links); + std::vector links = simgrid::s4u::Engine::getInstance()->getLinkList(); double total_energy = 0.0; // Total dissipated energy (whole platform) for (const auto link : links) { -- 2.20.1