1 /* Copyright (c) 2004-2018. The SimGrid Team. All rights reserved. */
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. */
6 #include "simgrid/kernel/resource/Resource.hpp"
7 #include "src/kernel/lmm/maxmin.hpp" // Constraint
8 #include "src/surf/surf_interface.hpp"
9 #include "src/surf/trace_mgr.hpp"
15 Resource::Resource(Model* model, const std::string& name, lmm::Constraint* constraint)
16 : name_(name), model_(model), constraint_(constraint)
20 Resource::~Resource() = default;
22 bool Resource::is_on() const
26 bool Resource::is_off() const
31 void Resource::turn_on()
36 void Resource::turn_off()
41 double Resource::get_load()
43 return constraint_->get_usage();
46 Model* Resource::get_model() const
51 const std::string& Resource::get_name() const
56 const char* Resource::get_cname() const
61 bool Resource::operator==(const Resource& other) const
63 return name_ == other.name_;
66 void Resource::set_state_trace(tmgr_trace_t trace)
68 xbt_assert(state_event_ == nullptr, "Cannot set a second state trace to %s", get_cname());
70 state_event_ = future_evt_set.add_trace(trace, this);
73 kernel::lmm::Constraint* Resource::get_constraint() const
78 } // namespace resource
80 } // namespace simgrid