From: Arnaud Giersch Date: Thu, 14 Mar 2019 14:35:47 +0000 (+0100) Subject: Inline methods of simgrid::kernel::Resource. X-Git-Tag: v3_22~96^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/19ca59d0255c2f0f93cb221ad75c01f05b50349c Inline methods of simgrid::kernel::Resource. --- diff --git a/include/simgrid/kernel/resource/Resource.hpp b/include/simgrid/kernel/resource/Resource.hpp index 2ab078fe6f..ebab496355 100644 --- a/include/simgrid/kernel/resource/Resource.hpp +++ b/include/simgrid/kernel/resource/Resource.hpp @@ -30,19 +30,22 @@ public: * @param name The name of the Resource * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component */ - Resource(Model* model, const std::string& name, lmm::Constraint* constraint); + Resource(Model* model, const std::string& name, lmm::Constraint* constraint) + : name_(name), model_(model), constraint_(constraint) + { + } virtual ~Resource(); /** @brief Get the Model of the current Resource */ - Model* get_model() const; + Model* get_model() const { return model_; } /** @brief Get the name of the current Resource */ - const std::string& get_name() const; + const std::string& get_name() const { return name_; } /** @brief Get the name of the current Resource */ - const char* get_cname() const; + const char* get_cname() const { return name_.c_str(); } - bool operator==(const Resource& other) const; + bool operator==(const Resource& other) const { return name_ == other.name_; } /** @brief Apply an event of external load event to that resource */ virtual void apply_event(profile::Event* event, double value) = 0; @@ -53,16 +56,16 @@ public: /** @brief returns the current load due to activities (in flops per second, byte per second or similar) * * The load due to external usages modeled by profile files is ignored.*/ - virtual double get_load(); + virtual double get_load() const; /** @brief Check if the current Resource is active */ - virtual bool is_on() const; + virtual bool is_on() const { return is_on_; } /** @brief Check if the current Resource is shut down */ - XBT_ATTRIB_DEPRECATED_v325("Please use !is_on()") virtual bool is_off() const; + XBT_ATTRIB_DEPRECATED_v325("Please use !is_on()") virtual bool is_off() const { return not is_on_; } /** @brief Turn on the current Resource */ - virtual void turn_on(); + virtual void turn_on() { is_on_ = true; } /** @brief Turn off the current Resource */ - virtual void turn_off(); + 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); @@ -78,7 +81,7 @@ private: public: /* LMM */ /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */ - lmm::Constraint* get_constraint() const; + lmm::Constraint* get_constraint() const { return constraint_; } private: kernel::lmm::Constraint* const constraint_; diff --git a/src/kernel/resource/Resource.cpp b/src/kernel/resource/Resource.cpp index 28d84cf6fe..16851b210e 100644 --- a/src/kernel/resource/Resource.cpp +++ b/src/kernel/resource/Resource.cpp @@ -12,69 +12,19 @@ namespace simgrid { namespace kernel { namespace resource { -Resource::Resource(Model* model, const std::string& name, lmm::Constraint* constraint) - : name_(name), model_(model), constraint_(constraint) -{ -} - Resource::~Resource() = default; -bool Resource::is_on() const -{ - return is_on_; -} -bool Resource::is_off() const // deprecated -{ - return not is_on_; -} - -void Resource::turn_on() -{ - is_on_ = true; -} - -void Resource::turn_off() -{ - is_on_ = false; -} - -double Resource::get_load() +double Resource::get_load() const { return constraint_->get_usage(); } -Model* Resource::get_model() const -{ - return model_; -} - -const std::string& Resource::get_name() const -{ - return name_; -} - -const char* Resource::get_cname() const -{ - return name_.c_str(); -} - -bool Resource::operator==(const Resource& other) const -{ - return name_ == other.name_; -} - void Resource::set_state_profile(profile::Profile* profile) { xbt_assert(state_event_ == nullptr, "Cannot set a second state profile to %s", get_cname()); - state_event_ = profile->schedule(&future_evt_set, this); } -kernel::lmm::Constraint* Resource::get_constraint() const -{ - return constraint_; -} - } // namespace resource } // namespace kernel } // namespace simgrid