X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/65c756c0c3ce5659e16c2dfff3ad48784edda884..263f137c6dc42876eb1dff3701e3bebd5306ffc2:/examples/s4u/engine-filtering/s4u-engine-filtering.cpp diff --git a/examples/s4u/engine-filtering/s4u-engine-filtering.cpp b/examples/s4u/engine-filtering/s4u-engine-filtering.cpp index c3e0e7eabd..d34e21f775 100644 --- a/examples/s4u/engine-filtering/s4u-engine-filtering.cpp +++ b/examples/s4u/engine-filtering/s4u-engine-filtering.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2017-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2017-2020. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -19,9 +19,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_engine_filtering, "Messages specific for this s namespace filter { /* First example of thing that we can use as a filtering criteria: a simple boolean function */ -static bool filter_speed_more_than_50Mf(simgrid::s4u::Host* host) +static bool filter_speed_more_than_50Mf(const simgrid::s4u::Host* host) { - return host->getSpeed() > 50E6; + return host->get_speed() > 50E6; } /* Second kind of thing that we can use as a filtering criteria: a functor (=function object). @@ -29,17 +29,17 @@ static bool filter_speed_more_than_50Mf(simgrid::s4u::Host* host) */ class SingleCore { public: - bool operator()(simgrid::s4u::Host* host) { return host->get_core_count() == 1; } + bool operator()(const simgrid::s4u::Host* host) const { return host->get_core_count() == 1; } }; /* This functor is a bit more complex, as it saves the current state when created. - * Then, it allows to easily retrieve the hosts which frequency changed since the functor creation. + * Then, it allows one to easily retrieve the hosts which frequency changed since the functor creation. */ class FrequencyChanged { std::map host_list; public: - explicit FrequencyChanged(simgrid::s4u::Engine& e) + explicit FrequencyChanged(const simgrid::s4u::Engine& e) { std::vector list = e.get_all_hosts(); for (auto& host : list) { @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) /* Use a lambda function to filter hosts: We only want multicore hosts */ XBT_INFO("Hosts currently registered with this engine: %zu", e.get_host_count()); std::vector list = - e.get_filtered_hosts([](simgrid::s4u::Host* host) { return host->get_core_count() > 1; }); + e.get_filtered_hosts([](const simgrid::s4u::Host* host) { return host->get_core_count() > 1; }); for (auto& host : list) XBT_INFO("The following hosts have more than one core: %s", host->get_cname()); @@ -80,7 +80,8 @@ int main(int argc, char* argv[]) list = e.get_filtered_hosts(filter); for (auto& host : list) - XBT_INFO("The following hosts changed their frequency: %s (from %.1ff to %.1ff)", host->get_cname(), host->getPstateSpeed(filter.get_old_speed(host)), host->getSpeed()); + XBT_INFO("The following hosts changed their frequency: %s (from %.1ff to %.1ff)", host->get_cname(), + host->get_pstate_speed(filter.get_old_speed(host)), host->get_speed()); /* You can also just use any regular function (namespaced on need) to filter */ list = e.get_filtered_hosts(filter::filter_speed_more_than_50Mf);