Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move set_lat_factor_cb and friends to NetworkModelFactors
[simgrid.git] / src / kernel / resource / NetworkModelFactors.hpp
1 /* Copyright (c) 2004-2022. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_KERNEL_RESOURCE_NETWORKMODELFACTORS_HPP
7 #define SIMGRID_KERNEL_RESOURCE_NETWORKMODELFACTORS_HPP
8
9 #include "simgrid/sg_config.hpp"
10 #include "xbt/asserts.h"
11 #include <simgrid/forward.h>
12
13 #include <unordered_set>
14 #include <vector>
15
16 namespace simgrid::kernel::resource {
17
18 /** @ingroup SURF_interface
19  * @brief Network Model interface class
20  */
21 class XBT_PUBLIC NetworkModelIntf {
22   using NetworkFactorCb = double(double size, const s4u::Host* src, const s4u::Host* dst,
23                                  const std::vector<s4u::Link*>& links,
24                                  const std::unordered_set<s4u::NetZone*>& netzones);
25
26 protected:
27   std::function<NetworkFactorCb> lat_factor_cb_;
28   std::function<NetworkFactorCb> bw_factor_cb_;
29
30 public:
31   /**
32    * @brief Callback to set the bandwidth and latency factors used in a communication
33    *
34    * This callback offers more flexibility when setting the network factors.
35    * It is an alternative to SimGrid's configs, such as network/latency-factors
36    * and network/bandwidth-factors.
37    *
38    * @param size Communication size in bytes
39    * @param src Source host
40    * @param dst Destination host
41    * @param links Vectors with the links used in this comm
42    * @param netzones Set with NetZones involved in the comm
43    * @return Multiply factor
44    */
45   /** @brief Configure the latency factor callback */
46   void set_lat_factor_cb(const std::function<NetworkFactorCb>& cb);
47
48   /** @brief Configure the bandwidth factor callback */
49   void set_bw_factor_cb(const std::function<NetworkFactorCb>& cb);
50 };
51
52 } // namespace simgrid::kernel::resource
53
54 #endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELINTF_HPP */