Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / kernel / resource / profile / Profile.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_PROFILE_HPP
7 #define SIMGRID_KERNEL_PROFILE_HPP
8
9 #include "simgrid/forward.h"
10 #include "src/kernel/resource/profile/DatedValue.hpp"
11 #include "src/kernel/resource/profile/FutureEvtSet.hpp"
12 #include "src/kernel/resource/profile/StochasticDatedValue.hpp"
13
14 #include <queue>
15 #include <vector>
16
17 namespace simgrid {
18 namespace kernel {
19 namespace profile {
20
21 /** @brief A profile is a set of timed values, encoding the value that a variable takes at what time
22  *
23  * It is useful to model dynamic platforms, where an external load that makes the resource availability change over
24  * time. To model that, you have to set several profiles per resource: one for the on/off state and one for each
25  * numerical value (computational speed, bandwidth and/or latency).
26  */
27 class XBT_PUBLIC Profile {
28 public:
29   /**  Creates an empty trace */
30   explicit Profile();
31   virtual ~Profile();
32   Event* schedule(FutureEvtSet* fes, resource::Resource* resource);
33   DatedValue next(Event* event);
34
35   const std::vector<DatedValue>& get_event_list() const { return event_list; }
36   const std::vector<StochasticDatedValue>& get_stochastic_event_list() const { return stochastic_event_list; }
37
38   static Profile* from_file(const std::string& path);
39   static Profile* from_string(const std::string& name, const std::string& input, double periodicity);
40
41 private:
42   std::vector<DatedValue> event_list;
43   std::vector<StochasticDatedValue> stochastic_event_list;
44
45   FutureEvtSet* fes_  = nullptr;
46   bool stochastic     = false;
47   bool stochasticloop = false;
48   DatedValue futureDV;
49 };
50
51 } // namespace profile
52 } // namespace kernel
53 } // namespace simgrid
54
55 /** Module finalizer: frees all profiles */
56 XBT_PUBLIC void tmgr_finalize();
57
58 #endif