Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
start snake_case()ing some private fields
[simgrid.git] / src / kernel / resource / Resource.cpp
1 /* Copyright (c) 2004-2018. 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 #include "simgrid/kernel/resource/Resource.hpp"
7 #include "src/kernel/lmm/maxmin.hpp" // Constraint
8 #include "src/surf/surf_interface.hpp"
9
10 namespace simgrid {
11 namespace kernel {
12 namespace resource {
13
14 Resource::Resource(Model* model, const std::string& name, lmm::Constraint* constraint)
15     : name_(name), model_(model), constraint_(constraint)
16 {
17 }
18
19 Resource::~Resource() = default;
20
21 bool Resource::isOn() const
22 {
23   return is_on_;
24 }
25 bool Resource::isOff() const
26 {
27   return not is_on_;
28 }
29
30 void Resource::turnOn()
31 {
32   is_on_ = true;
33 }
34
35 void Resource::turnOff()
36 {
37   is_on_ = false;
38 }
39
40 double Resource::getLoad()
41 {
42   return constraint_->get_usage();
43 }
44
45 Model* Resource::model() const
46 {
47   return model_;
48 }
49
50 const std::string& Resource::getName() const
51 {
52   return name_;
53 }
54
55 const char* Resource::getCname() const
56 {
57   return name_.c_str();
58 }
59
60 bool Resource::operator==(const Resource& other) const
61 {
62   return name_ == other.name_;
63 }
64
65 kernel::lmm::Constraint* Resource::constraint() const
66 {
67   return constraint_;
68 }
69
70 } // namespace resource
71 } // namespace kernel
72 } // namespace simgrid