Fix of a set method to make ConfigOptionEnum compatible with
ConfigOptionEnumGeneric.
This commit is contained in:
parent
60a192ef34
commit
9f2cd347e3
@ -810,6 +810,14 @@ public:
|
|||||||
ConfigOption* clone() const override { return new ConfigOptionEnum<T>(*this); }
|
ConfigOption* clone() const override { return new ConfigOptionEnum<T>(*this); }
|
||||||
ConfigOptionEnum<T>& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
ConfigOptionEnum<T>& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||||
bool operator==(const ConfigOptionEnum<T> &rhs) const { return this->value == rhs.value; }
|
bool operator==(const ConfigOptionEnum<T> &rhs) const { return this->value == rhs.value; }
|
||||||
|
int getInt() const override { return (int)this->value; }
|
||||||
|
|
||||||
|
void set(const ConfigOption *rhs) override {
|
||||||
|
if (rhs->type() != this->type())
|
||||||
|
throw std::runtime_error("ConfigOptionEnum<T>: Assigning an incompatible type");
|
||||||
|
// rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum<T>
|
||||||
|
this->value = (T)rhs->getInt();
|
||||||
|
}
|
||||||
|
|
||||||
std::string serialize() const override
|
std::string serialize() const override
|
||||||
{
|
{
|
||||||
@ -879,6 +887,13 @@ public:
|
|||||||
ConfigOptionEnumGeneric& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
ConfigOptionEnumGeneric& operator=(const ConfigOption *opt) { this->set(opt); return *this; }
|
||||||
bool operator==(const ConfigOptionEnumGeneric &rhs) const { return this->value == rhs.value; }
|
bool operator==(const ConfigOptionEnumGeneric &rhs) const { return this->value == rhs.value; }
|
||||||
|
|
||||||
|
void set(const ConfigOption *rhs) override {
|
||||||
|
if (rhs->type() != this->type())
|
||||||
|
throw std::runtime_error("ConfigOptionEnumGeneric: Assigning an incompatible type");
|
||||||
|
// rhs could be of the following type: ConfigOptionEnumGeneric or ConfigOptionEnum<T>
|
||||||
|
this->value = rhs->getInt();
|
||||||
|
}
|
||||||
|
|
||||||
std::string serialize() const override
|
std::string serialize() const override
|
||||||
{
|
{
|
||||||
for (const auto &kvp : *this->keys_map)
|
for (const auto &kvp : *this->keys_map)
|
||||||
|
Loading…
Reference in New Issue
Block a user