+ fix constness and useless checks
+bool HostImpl::isOn() const {
-bool HostImpl::isOff() {
+bool HostImpl::isOff() const {
return p_cpu->isOff();
}
void HostImpl::turnOn(){
return p_cpu->isOff();
}
void HostImpl::turnOn(){
}
void attach(simgrid::s4u::Host* host);
}
void attach(simgrid::s4u::Host* host);
- bool isOn() override;
- bool isOff() override;
+ bool isOn() const override;
+ bool isOff() const override;
void turnOn() override;
void turnOff() override;
void turnOn() override;
void turnOff() override;
namespace surf {
Resource::Resource(Model *model, const char *name)
namespace surf {
Resource::Resource(Model *model, const char *name)
- : Resource(model, name, 1/*ON*/)
-{}
-
-Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
- : Resource(model, name, constraint, 1/*ON*/)
-{}
-
-Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint, int initiallyOn)
: name_(xbt_strdup(name))
, model_(model)
: name_(xbt_strdup(name))
, model_(model)
- , isOn_(initiallyOn)
- , constraint_(constraint)
-Resource::Resource(Model *model, const char *name, int initiallyOn)
+Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
: name_(xbt_strdup(name))
, model_(model)
: name_(xbt_strdup(name))
, model_(model)
+ , constraint_(constraint)
Resource::~Resource() {
xbt_free((void*)name_);
}
Resource::~Resource() {
xbt_free((void*)name_);
}
+bool Resource::isOn() const {
-bool Resource::isOff() {
+bool Resource::isOff() const {
return ! isOn_;
}
void Resource::turnOn()
{
return ! isOn_;
}
void Resource::turnOn()
{
- if (!isOn_) {
- isOn_ = true;
- }
}
void Resource::turnOff()
{
}
void Resource::turnOff()
{
- if (isOn_) {
- isOn_ = false;
- }
}
Model *Resource::getModel() const {
}
Model *Resource::getModel() const {
return strcmp(name_, other.name_);
}
return strcmp(name_, other.name_);
}
-lmm_constraint_t Resource::getConstraint() {
+lmm_constraint_t Resource::getConstraint() const {
/** @ingroup SURF_interface
* @brief SURF resource interface class
/** @ingroup SURF_interface
* @brief SURF resource interface class
- * @details A resource represent an element of a component (e.g.: a link for the network)
+ * @details This is the ancestor class of every resources in SimGrid, such as links, CPU or storage
*/
XBT_PUBLIC_CLASS Resource {
public:
*/
XBT_PUBLIC_CLASS Resource {
public:
*/
Resource(Model *model, const char *name, lmm_constraint_t constraint);
*/
Resource(Model *model, const char *name, lmm_constraint_t constraint);
- Resource(Model *model, const char *name, lmm_constraint_t constraint, int initiallyOn);
-
- /**
- * @brief Resource constructor
- *
- * @param model Model associated to this Resource
- * @param name The name of the Resource
- * @param initiallyOn the initial state of the Resource
- */
- Resource(Model *model, const char *name, int initiallyOn);
-
virtual ~Resource();
/** @brief Get the Model of the current Resource */
virtual ~Resource();
/** @brief Get the Model of the current Resource */
- Model *getModel() const ;
+ Model *getModel() const;
/** @brief Get the name of the current Resource */
/** @brief Get the name of the current Resource */
- const char *getName() const ;
+ const char *getName() const;
bool operator==(const Resource &other) const;
bool operator==(const Resource &other) const;
virtual bool isUsed()=0;
/** @brief Check if the current Resource is active */
virtual bool isUsed()=0;
/** @brief Check if the current Resource is active */
+ virtual bool isOn() const;
/** @brief Check if the current Resource is shut down */
/** @brief Check if the current Resource is shut down */
+ virtual bool isOff() const;
/** @brief Turn on the current Resource */
virtual void turnOn();
/** @brief Turn off the current Resource */
/** @brief Turn on the current Resource */
virtual void turnOn();
/** @brief Turn off the current Resource */
private:
const char *name_;
Model *model_;
private:
const char *name_;
Model *model_;
public: /* LMM */
/** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
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_t getConstraint();
+ lmm_constraint_t getConstraint() const;
protected:
lmm_constraint_t constraint_ = nullptr;
};
protected:
lmm_constraint_t constraint_ = nullptr;
};