+ return dynamic_cast<const TypedConfigurationElement<T>&>(*this).getValue();
+ }
+ template<class T>
+ void setValue(T value)
+ {
+ dynamic_cast<TypedConfigurationElement<T>&>(*this).setValue(std::move(value));
+ }
+ template<class T>
+ void setDefaultValue(T value)
+ {
+ dynamic_cast<TypedConfigurationElement<T>&>(*this).setDefaultValue(std::move(value));
+ }
+ bool isDefault() const { return isdefault; }
+
+ std::string const& getDescription() const { return desc; }
+};
+
+ConfigurationElement::~ConfigurationElement() {}
+
+// **** TypedConfigurationElement<T> ****
+
+// TODO, could we use boost::any with some Type* reference?
+template<class T>
+class TypedConfigurationElement : public ConfigurationElement {
+private:
+ T content;
+ std::function<void(T&)> callback;
+
+public:
+ TypedConfigurationElement(const char* key, const char* desc, T value = T())
+ : ConfigurationElement(key, desc), content(std::move(value))
+ {}
+ TypedConfigurationElement(const char* key, const char* desc, T value,
+ xbt_cfg_cb_t cb)
+ : ConfigurationElement(key, desc, cb), content(std::move(value))
+ {}
+ TypedConfigurationElement(const char* key, const char* desc, T value,
+ std::function<void(T&)> callback)
+ : ConfigurationElement(key, desc), content(std::move(value)),
+ callback(std::move(callback))
+ {}
+ ~TypedConfigurationElement() override;
+
+ std::string getStringValue() override;
+ const char* getTypeName() override;
+ void setStringValue(const char* value) override;
+
+ void update()
+ {
+ if (old_callback)
+ this->old_callback(key.c_str());
+ if (this->callback)
+ this->callback(this->content);
+ }
+
+ T const& getValue() const { return content; }
+
+ void setValue(T value)
+ {
+ this->content = std::move(value);
+ this->update();