Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[S4U] Engine: Add Engine::get_filtered_links
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Fri, 1 Jun 2018 17:58:07 +0000 (19:58 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Fri, 1 Jun 2018 17:59:30 +0000 (19:59 +0200)
include/simgrid/s4u/Engine.hpp
src/s4u/s4u_Engine.cpp

index eabfef2..8d9477c 100644 (file)
@@ -104,6 +104,7 @@ public:
 
   size_t get_link_count();
   std::vector<Link*> get_all_links();
 
   size_t get_link_count();
   std::vector<Link*> get_all_links();
+  std::vector<Link*> get_filtered_links(std::function<bool(Link*)> filter);
 
   size_t get_storage_count();
   std::vector<Storage*> get_all_storages();
 
   size_t get_storage_count();
   std::vector<Storage*> get_all_storages();
index d522abf..c311f1d 100644 (file)
@@ -190,6 +190,20 @@ std::vector<Link*> Engine::get_all_links()
   return res;
 }
 
   return res;
 }
 
+std::vector<Link*> Engine::get_filtered_links(std::function<bool(Link*)> filter)
+{
+  // FIXME: This is a terrible implementation and should be done
+  // without getting all links first.
+  std::vector<Link*> res;
+  kernel::resource::LinkImpl::linksList(&res);
+  std::vector<Link*> filtered_list;
+  for (auto& link : res) {
+    if (filter(link))
+      filtered_list.push_back(link);
+  }
+  return filtered_list;
+}
+
 void Engine::run()
 {
   if (MC_is_active()) {
 void Engine::run()
 {
   if (MC_is_active()) {