Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Also simplify the API of Engine::getLinkList
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 9 Mar 2018 15:39:20 +0000 (16:39 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 9 Mar 2018 15:39:20 +0000 (16:39 +0100)
include/simgrid/s4u/Engine.hpp
src/s4u/s4u_engine.cpp
src/surf/plugins/link_energy.cpp

index bc7d410..8b2f0cd 100644 (file)
@@ -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<Host*> * whereTo);
   std::vector<Host*> getHostList();
+
   size_t getLinkCount();
   void getLinkList(std::vector<Link*> * list);
+  std::vector<Link*> getLinkList();
 
   /** @brief Run the simulation */
   void run();
index e5fce94..5a231d6 100644 (file)
@@ -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<Link*>* list)
 {
   simgrid::surf::LinkImpl::linksList(list);
 }
+/** @brief Returns the list of all links found in the platform */
+std::vector<Link*> Engine::getLinkList()
+{
+  std::vector<Link*> res;
+  simgrid::surf::LinkImpl::linksList(&res);
+  return res;
+}
 
 void Engine::run() {
   if (MC_is_active()) {
index 34e71ae..cee5ad2 100644 (file)
@@ -164,8 +164,7 @@ static void onCommunicate(simgrid::surf::NetworkAction* action, simgrid::s4u::Ho
 
 static void onSimulationEnd()
 {
-  std::vector<simgrid::s4u::Link*> links;
-  simgrid::s4u::Engine::getInstance()->getLinkList(&links);
+  std::vector<simgrid::s4u::Link*> links = simgrid::s4u::Engine::getInstance()->getLinkList();
 
   double total_energy = 0.0; // Total dissipated energy (whole platform)
   for (const auto link : links) {