X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9cb40402d4b88cb4690592949dbae63147f92f32..42a3fc7bf956d263989efdd841e07ff0ebe4cbac:/include/simgrid/kernel/resource/Resource.hpp?ds=sidebyside diff --git a/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index c377153841..f1edd894f6 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -7,6 +7,8 @@ #define SIMGRID_KERNEL_RESOURCE_RESOURCE_HPP #include "src/kernel/lmm/maxmin.hpp" // Constraint +#include "src/kernel/resource/profile/FutureEvtSet.hpp" +#include "src/kernel/resource/profile/Profile.hpp" #include #include #include @@ -61,8 +63,6 @@ public: virtual void turn_on() { is_on_ = true; } /** @brief Turn off the current Resource */ virtual void turn_off() { is_on_ = false; } - /** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */ - virtual void set_state_profile(profile::Profile* profile); }; template class Resource_T : public Resource { @@ -71,6 +71,17 @@ template class Resource_T : public Resource { public: using Resource::Resource; + /** @brief setup the profile file with states events (ON or OFF). The profile must contain boolean values. */ + AnyResource* set_state_profile(profile::Profile* profile) + { + if (profile) { + xbt_assert(state_event_ == nullptr, "Cannot set a second state profile to %s", get_cname()); + state_event_ = profile->schedule(&profile::future_evt_set, this); + } + + return static_cast(this); + } + AnyResource* set_model(Model* model) { model_ = model;