// **** ConfigurationElement ****
class ConfigurationElement {
-protected:
+private:
std::string key;
std::string desc;
bool isdefault = true;
{
dynamic_cast<TypedConfigurationElement<T>&>(*this).setDefaultValue(std::move(value));
}
+ void unsetDefault() { isdefault = false; }
bool isDefault() const { return isdefault; }
std::string const& getDescription() const { return desc; }
void update()
{
if (old_callback)
- this->old_callback(key.c_str());
+ this->old_callback(getKey().c_str());
if (this->callback)
this->callback(this->content);
}
void setDefaultValue(T value)
{
- if (this->isdefault) {
+ if (this->isDefault()) {
this->content = std::move(value);
this->update();
} else {
- XBT_DEBUG("Do not override configuration variable '%s' with value '%s' because it was already set.", key.c_str(),
- to_string(value).c_str());
+ XBT_DEBUG("Do not override configuration variable '%s' with value '%s' because it was already set.",
+ getKey().c_str(), to_string(value).c_str());
}
}
};
void TypedConfigurationElement<T>::setStringValue(const char* value) // override
{
this->content = ConfigType<T>::parse(value);
- this->isdefault = false;
+ this->unsetDefault();
this->update();
}