X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/29a3b2869c0075fc75e8ccc66fc1d9c4c8bf6a85..9184de69711560f747a3fbbb153a371375f2c38e:/src/kernel/resource/Resource.cpp diff --git a/src/kernel/resource/Resource.cpp b/src/kernel/resource/Resource.cpp index 816ae089d5..16851b210e 100644 --- a/src/kernel/resource/Resource.cpp +++ b/src/kernel/resource/Resource.cpp @@ -1,78 +1,28 @@ -/* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2019. 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. */ #include "simgrid/kernel/resource/Resource.hpp" #include "src/kernel/lmm/maxmin.hpp" // Constraint +#include "src/kernel/resource/profile/trace_mgr.hpp" #include "src/surf/surf_interface.hpp" -#include "src/surf/trace_mgr.hpp" 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 -{ - 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_trace(tmgr_trace_t trace) -{ - xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to %s", get_cname()); - - state_event_ = future_evt_set.add_trace(trace, this); -} - -kernel::lmm::Constraint* Resource::get_constraint() const +void Resource::set_state_profile(profile::Profile* profile) { - return constraint_; + xbt_assert(state_event_ == nullptr, "Cannot set a second state profile to %s", get_cname()); + state_event_ = profile->schedule(&future_evt_set, this); } } // namespace resource