Large refactoring of the Config classes

This commit is contained in:
Alessandro Ranellucci 2015-12-07 19:39:49 +01:00
parent 32a333f16a
commit 3fac8cd77e
8 changed files with 467 additions and 336 deletions

View File

@ -19,6 +19,21 @@ operator!= (const ConfigOption &a, const ConfigOption &b)
return !(a == b); return !(a == b);
} }
ConfigDef::~ConfigDef()
{
for (t_optiondef_map::iterator it = this->options.begin(); it != this->options.end(); ++it) {
if (it->second.default_value != NULL)
delete it->second.default_value;
}
}
const ConfigOptionDef*
ConfigDef::get(const t_config_option_key &opt_key) const
{
if (this->options.count(opt_key) == 0) return NULL;
return &const_cast<ConfigDef*>(this)->options[opt_key];
}
bool bool
ConfigBase::has(const t_config_option_key &opt_key) { ConfigBase::has(const t_config_option_key &opt_key) {
return (this->option(opt_key, false) != NULL); return (this->option(opt_key, false) != NULL);
@ -72,10 +87,10 @@ ConfigBase::serialize(const t_config_option_key &opt_key) const {
bool bool
ConfigBase::set_deserialize(const t_config_option_key &opt_key, std::string str) { ConfigBase::set_deserialize(const t_config_option_key &opt_key, std::string str) {
if (this->def->count(opt_key) == 0) throw "Calling set_deserialize() on unknown option"; const ConfigOptionDef* optdef = this->def->get(opt_key);
ConfigOptionDef* optdef = &(*this->def)[opt_key]; if (optdef == NULL) throw "Calling set_deserialize() on unknown option";
if (!optdef->shortcut.empty()) { if (!optdef->shortcut.empty()) {
for (std::vector<t_config_option_key>::iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it) { for (std::vector<t_config_option_key>::const_iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it) {
if (!this->set_deserialize(*it, str)) return false; if (!this->set_deserialize(*it, str)) return false;
} }
return true; return true;
@ -91,8 +106,8 @@ ConfigBase::get_abs_value(const t_config_option_key &opt_key) {
ConfigOption* opt = this->option(opt_key, false); ConfigOption* opt = this->option(opt_key, false);
if (ConfigOptionFloatOrPercent* optv = dynamic_cast<ConfigOptionFloatOrPercent*>(opt)) { if (ConfigOptionFloatOrPercent* optv = dynamic_cast<ConfigOptionFloatOrPercent*>(opt)) {
// get option definition // get option definition
assert(this->def->count(opt_key) != 0); const ConfigOptionDef* def = this->def->get(opt_key);
ConfigOptionDef* def = &(*this->def)[opt_key]; assert(def != NULL);
// compute absolute value over the absolute value of the base option // compute absolute value over the absolute value of the base option
return optv->get_abs_value(this->get_abs_value(def->ratio_over)); return optv->get_abs_value(this->get_abs_value(def->ratio_over));
@ -150,44 +165,57 @@ SV*
ConfigBase::get(t_config_option_key opt_key) { ConfigBase::get(t_config_option_key opt_key) {
ConfigOption* opt = this->option(opt_key); ConfigOption* opt = this->option(opt_key);
if (opt == NULL) return &PL_sv_undef; if (opt == NULL) return &PL_sv_undef;
if (ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt)) {
const ConfigOptionDef* def = this->def->get(opt_key);
if (def->type == coFloat) {
ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt);
return newSVnv(optv->value); return newSVnv(optv->value);
} else if (ConfigOptionPercent* optv = dynamic_cast<ConfigOptionPercent*>(opt)) { } else if (def->type == coFloats) {
return newSVnv(optv->value); ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt);
} else if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) {
AV* av = newAV(); AV* av = newAV();
av_fill(av, optv->values.size()-1); av_fill(av, optv->values.size()-1);
for (std::vector<double>::iterator it = optv->values.begin(); it != optv->values.end(); ++it) for (std::vector<double>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), newSVnv(*it)); av_store(av, it - optv->values.begin(), newSVnv(*it));
return newRV_noinc((SV*)av); return newRV_noinc((SV*)av);
} else if (ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt)) { } else if (def->type == coPercent) {
ConfigOptionPercent* optv = dynamic_cast<ConfigOptionPercent*>(opt);
return newSVnv(optv->value);
} else if (def->type == coInt) {
ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt);
return newSViv(optv->value); return newSViv(optv->value);
} else if (ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt)) { } else if (def->type == coInts) {
ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt);
AV* av = newAV(); AV* av = newAV();
av_fill(av, optv->values.size()-1); av_fill(av, optv->values.size()-1);
for (std::vector<int>::iterator it = optv->values.begin(); it != optv->values.end(); ++it) for (std::vector<int>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), newSViv(*it)); av_store(av, it - optv->values.begin(), newSViv(*it));
return newRV_noinc((SV*)av); return newRV_noinc((SV*)av);
} else if (ConfigOptionString* optv = dynamic_cast<ConfigOptionString*>(opt)) { } else if (def->type == coString) {
ConfigOptionString* optv = dynamic_cast<ConfigOptionString*>(opt);
// we don't serialize() because that would escape newlines // we don't serialize() because that would escape newlines
return newSVpvn_utf8(optv->value.c_str(), optv->value.length(), true); return newSVpvn_utf8(optv->value.c_str(), optv->value.length(), true);
} else if (ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt)) { } else if (def->type == coStrings) {
ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt);
AV* av = newAV(); AV* av = newAV();
av_fill(av, optv->values.size()-1); av_fill(av, optv->values.size()-1);
for (std::vector<std::string>::iterator it = optv->values.begin(); it != optv->values.end(); ++it) for (std::vector<std::string>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), newSVpvn_utf8(it->c_str(), it->length(), true)); av_store(av, it - optv->values.begin(), newSVpvn_utf8(it->c_str(), it->length(), true));
return newRV_noinc((SV*)av); return newRV_noinc((SV*)av);
} else if (ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt)) { } else if (def->type == coPoint) {
return perl_to_SV_clone_ref(optv->point); ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt);
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) { return perl_to_SV_clone_ref(optv->value);
} else if (def->type == coPoints) {
ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt);
AV* av = newAV(); AV* av = newAV();
av_fill(av, optv->values.size()-1); av_fill(av, optv->values.size()-1);
for (Pointfs::iterator it = optv->values.begin(); it != optv->values.end(); ++it) for (Pointfs::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
av_store(av, it - optv->values.begin(), perl_to_SV_clone_ref(*it)); av_store(av, it - optv->values.begin(), perl_to_SV_clone_ref(*it));
return newRV_noinc((SV*)av); return newRV_noinc((SV*)av);
} else if (ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt)) { } else if (def->type == coBool) {
ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt);
return newSViv(optv->value ? 1 : 0); return newSViv(optv->value ? 1 : 0);
} else if (ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt)) { } else if (def->type == coBools) {
ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt);
AV* av = newAV(); AV* av = newAV();
av_fill(av, optv->values.size()-1); av_fill(av, optv->values.size()-1);
for (std::vector<bool>::iterator it = optv->values.begin(); it != optv->values.end(); ++it) for (std::vector<bool>::iterator it = optv->values.begin(); it != optv->values.end(); ++it)
@ -204,17 +232,23 @@ ConfigBase::get_at(t_config_option_key opt_key, size_t i) {
ConfigOption* opt = this->option(opt_key); ConfigOption* opt = this->option(opt_key);
if (opt == NULL) return &PL_sv_undef; if (opt == NULL) return &PL_sv_undef;
if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) { const ConfigOptionDef* def = this->def->get(opt_key);
if (def->type == coFloats) {
ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt);
return newSVnv(optv->get_at(i)); return newSVnv(optv->get_at(i));
} else if (ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt)) { } else if (def->type == coInts) {
ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt);
return newSViv(optv->get_at(i)); return newSViv(optv->get_at(i));
} else if (ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt)) { } else if (def->type == coStrings) {
ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt);
// we don't serialize() because that would escape newlines // we don't serialize() because that would escape newlines
std::string val = optv->get_at(i); std::string val = optv->get_at(i);
return newSVpvn_utf8(val.c_str(), val.length(), true); return newSVpvn_utf8(val.c_str(), val.length(), true);
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) { } else if (def->type == coPoints) {
ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt);
return perl_to_SV_clone_ref(optv->get_at(i)); return perl_to_SV_clone_ref(optv->get_at(i));
} else if (ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt)) { } else if (def->type == coBools) {
ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt);
return newSViv(optv->get_at(i) ? 1 : 0); return newSViv(optv->get_at(i) ? 1 : 0);
} else { } else {
return &PL_sv_undef; return &PL_sv_undef;
@ -226,10 +260,13 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) {
ConfigOption* opt = this->option(opt_key, true); ConfigOption* opt = this->option(opt_key, true);
if (opt == NULL) CONFESS("Trying to set non-existing option"); if (opt == NULL) CONFESS("Trying to set non-existing option");
if (ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt)) { const ConfigOptionDef* def = this->def->get(opt_key);
if (def->type == coFloat) {
if (!looks_like_number(value)) return false; if (!looks_like_number(value)) return false;
ConfigOptionFloat* optv = dynamic_cast<ConfigOptionFloat*>(opt);
optv->value = SvNV(value); optv->value = SvNV(value);
} else if (ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt)) { } else if (def->type == coFloats) {
ConfigOptionFloats* optv = dynamic_cast<ConfigOptionFloats*>(opt);
std::vector<double> values; std::vector<double> values;
AV* av = (AV*)SvRV(value); AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1; const size_t len = av_len(av)+1;
@ -239,10 +276,12 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) {
values.push_back(SvNV(*elem)); values.push_back(SvNV(*elem));
} }
optv->values = values; optv->values = values;
} else if (ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt)) { } else if (def->type == coInt) {
if (!looks_like_number(value)) return false; if (!looks_like_number(value)) return false;
ConfigOptionInt* optv = dynamic_cast<ConfigOptionInt*>(opt);
optv->value = SvIV(value); optv->value = SvIV(value);
} else if (ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt)) { } else if (def->type == coInts) {
ConfigOptionInts* optv = dynamic_cast<ConfigOptionInts*>(opt);
std::vector<int> values; std::vector<int> values;
AV* av = (AV*)SvRV(value); AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1; const size_t len = av_len(av)+1;
@ -252,9 +291,11 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) {
values.push_back(SvIV(*elem)); values.push_back(SvIV(*elem));
} }
optv->values = values; optv->values = values;
} else if (ConfigOptionString* optv = dynamic_cast<ConfigOptionString*>(opt)) { } else if (def->type == coString) {
ConfigOptionString* optv = dynamic_cast<ConfigOptionString*>(opt);
optv->value = std::string(SvPV_nolen(value), SvCUR(value)); optv->value = std::string(SvPV_nolen(value), SvCUR(value));
} else if (ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt)) { } else if (def->type == coStrings) {
ConfigOptionStrings* optv = dynamic_cast<ConfigOptionStrings*>(opt);
optv->values.clear(); optv->values.clear();
AV* av = (AV*)SvRV(value); AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1; const size_t len = av_len(av)+1;
@ -263,9 +304,11 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) {
if (elem == NULL) return false; if (elem == NULL) return false;
optv->values.push_back(std::string(SvPV_nolen(*elem), SvCUR(*elem))); optv->values.push_back(std::string(SvPV_nolen(*elem), SvCUR(*elem)));
} }
} else if (ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt)) { } else if (def->type == coPoint) {
return optv->point.from_SV_check(value); ConfigOptionPoint* optv = dynamic_cast<ConfigOptionPoint*>(opt);
} else if (ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt)) { return optv->value.from_SV_check(value);
} else if (def->type == coPoints) {
ConfigOptionPoints* optv = dynamic_cast<ConfigOptionPoints*>(opt);
std::vector<Pointf> values; std::vector<Pointf> values;
AV* av = (AV*)SvRV(value); AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1; const size_t len = av_len(av)+1;
@ -276,9 +319,11 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) {
values.push_back(point); values.push_back(point);
} }
optv->values = values; optv->values = values;
} else if (ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt)) { } else if (def->type == coBool) {
ConfigOptionBool* optv = dynamic_cast<ConfigOptionBool*>(opt);
optv->value = SvTRUE(value); optv->value = SvTRUE(value);
} else if (ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt)) { } else if (def->type == coBools) {
ConfigOptionBools* optv = dynamic_cast<ConfigOptionBools*>(opt);
optv->values.clear(); optv->values.clear();
AV* av = (AV*)SvRV(value); AV* av = (AV*)SvRV(value);
const size_t len = av_len(av)+1; const size_t len = av_len(av)+1;
@ -345,7 +390,8 @@ ConfigOption*
DynamicConfig::option(const t_config_option_key &opt_key, bool create) { DynamicConfig::option(const t_config_option_key &opt_key, bool create) {
if (this->options.count(opt_key) == 0) { if (this->options.count(opt_key) == 0) {
if (create) { if (create) {
ConfigOptionDef* optdef = &(*this->def)[opt_key]; const ConfigOptionDef* optdef = this->def->get(opt_key);
assert(optdef != NULL);
ConfigOption* opt; ConfigOption* opt;
if (optdef->type == coFloat) { if (optdef->type == coFloat) {
opt = new ConfigOptionFloat (); opt = new ConfigOptionFloat ();
@ -415,10 +461,24 @@ DynamicConfig::erase(const t_config_option_key &opt_key) {
this->options.erase(opt_key); this->options.erase(opt_key);
} }
void
StaticConfig::set_defaults()
{
// use defaults from definition
if (this->def == NULL) return;
t_config_option_keys keys = this->keys();
for (t_config_option_keys::const_iterator it = keys.begin(); it != keys.end(); ++it) {
const ConfigOptionDef* def = this->def->get(*it);
if (def->default_value != NULL)
this->option(*it)->set(*def->default_value);
}
}
t_config_option_keys t_config_option_keys
StaticConfig::keys() const { StaticConfig::keys() const {
t_config_option_keys keys; t_config_option_keys keys;
for (t_optiondef_map::const_iterator it = this->def->begin(); it != this->def->end(); ++it) { for (t_optiondef_map::const_iterator it = this->def->options.begin(); it != this->def->options.end(); ++it) {
const ConfigOption* opt = this->option(it->first); const ConfigOption* opt = this->option(it->first);
if (opt != NULL) keys.push_back(it->first); if (opt != NULL) keys.push_back(it->first);
} }
@ -434,9 +494,9 @@ StaticConfig::option(const t_config_option_key &opt_key) const
#ifdef SLIC3RXS #ifdef SLIC3RXS
bool bool
StaticConfig::set(t_config_option_key opt_key, SV* value) { StaticConfig::set(t_config_option_key opt_key, SV* value) {
ConfigOptionDef* optdef = &(*this->def)[opt_key]; const ConfigOptionDef* optdef = this->def->get(opt_key);
if (!optdef->shortcut.empty()) { if (!optdef->shortcut.empty()) {
for (std::vector<t_config_option_key>::iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it) { for (std::vector<t_config_option_key>::const_iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it) {
if (!this->set(*it, value)) return false; if (!this->set(*it, value)) return false;
} }
return true; return true;

View File

@ -22,12 +22,28 @@ class ConfigOption {
virtual ~ConfigOption() {}; virtual ~ConfigOption() {};
virtual std::string serialize() const = 0; virtual std::string serialize() const = 0;
virtual bool deserialize(std::string str) = 0; virtual bool deserialize(std::string str) = 0;
virtual void set(const ConfigOption &option) = 0;
virtual int getInt() const { return 0; }; virtual int getInt() const { return 0; };
virtual double getFloat() const { return 0; };
virtual bool getBool() const { return false; };
virtual void setInt(int val) {}; virtual void setInt(int val) {};
friend bool operator== (const ConfigOption &a, const ConfigOption &b); friend bool operator== (const ConfigOption &a, const ConfigOption &b);
friend bool operator!= (const ConfigOption &a, const ConfigOption &b); friend bool operator!= (const ConfigOption &a, const ConfigOption &b);
}; };
template <class T>
class ConfigOptionSingle : public ConfigOption {
public:
T value;
ConfigOptionSingle(T _value) : value(_value) {};
operator T() const { return this->value; };
void set(const ConfigOption &option) {
const ConfigOptionSingle<T>* other = dynamic_cast< const ConfigOptionSingle<T>* >(&option);
if (other != NULL) this->value = other->value;
};
};
class ConfigOptionVectorBase : public ConfigOption { class ConfigOptionVectorBase : public ConfigOption {
public: public:
virtual ~ConfigOptionVectorBase() {}; virtual ~ConfigOptionVectorBase() {};
@ -41,6 +57,11 @@ class ConfigOptionVector : public ConfigOptionVectorBase
virtual ~ConfigOptionVector() {}; virtual ~ConfigOptionVector() {};
std::vector<T> values; std::vector<T> values;
void set(const ConfigOption &option) {
const const ConfigOptionVector<T>* other = dynamic_cast< const ConfigOptionVector<T>* >(&option);
if (other != NULL) this->values = other->values;
};
T get_at(size_t i) const { T get_at(size_t i) const {
try { try {
return this->values.at(i); return this->values.at(i);
@ -50,14 +71,13 @@ class ConfigOptionVector : public ConfigOptionVectorBase
}; };
}; };
class ConfigOptionFloat : public ConfigOption class ConfigOptionFloat : public ConfigOptionSingle<double>
{ {
public: public:
double value; // use double instead of float for preserving compatibility with values coming from Perl ConfigOptionFloat() : ConfigOptionSingle(0) {};
ConfigOptionFloat() : value(0) {}; ConfigOptionFloat(double _value) : ConfigOptionSingle(_value) {};
operator float() const { return this->value; }; double getFloat() const { return this->value; };
operator double() const { return this->value; };
std::string serialize() const { std::string serialize() const {
std::ostringstream ss; std::ostringstream ss;
@ -108,13 +128,12 @@ class ConfigOptionFloats : public ConfigOptionVector<double>
}; };
}; };
class ConfigOptionInt : public ConfigOption class ConfigOptionInt : public ConfigOptionSingle<int>
{ {
public: public:
int value; ConfigOptionInt() : ConfigOptionSingle(0) {};
ConfigOptionInt() : value(0) {}; ConfigOptionInt(double _value) : ConfigOptionSingle(_value) {};
operator int() const { return this->value; };
int getInt() const { return this->value; }; int getInt() const { return this->value; };
void setInt(int val) { this->value = val; }; void setInt(int val) { this->value = val; };
@ -167,13 +186,11 @@ class ConfigOptionInts : public ConfigOptionVector<int>
}; };
}; };
class ConfigOptionString : public ConfigOption class ConfigOptionString : public ConfigOptionSingle<std::string>
{ {
public: public:
std::string value; ConfigOptionString() : ConfigOptionSingle("") {};
ConfigOptionString() : value("") {}; ConfigOptionString(std::string _value) : ConfigOptionSingle(_value) {};
operator std::string() const { return this->value; };
std::string serialize() const { std::string serialize() const {
std::string str = this->value; std::string str = this->value;
@ -230,11 +247,11 @@ class ConfigOptionStrings : public ConfigOptionVector<std::string>
}; };
}; };
class ConfigOptionPercent : public ConfigOption class ConfigOptionPercent : public ConfigOptionFloat
{ {
public: public:
double value; ConfigOptionPercent() : ConfigOptionFloat(0) {};
ConfigOptionPercent() : value(0) {}; ConfigOptionPercent(double _value) : ConfigOptionFloat(_value) {};
double get_abs_value(double ratio_over) const { double get_abs_value(double ratio_over) const {
return ratio_over * this->value / 100; return ratio_over * this->value / 100;
@ -255,12 +272,21 @@ class ConfigOptionPercent : public ConfigOption
}; };
}; };
class ConfigOptionFloatOrPercent : public ConfigOption class ConfigOptionFloatOrPercent : public ConfigOptionPercent
{ {
public: public:
double value;
bool percent; bool percent;
ConfigOptionFloatOrPercent() : value(0), percent(false) {}; ConfigOptionFloatOrPercent() : ConfigOptionPercent(0), percent(false) {};
ConfigOptionFloatOrPercent(double _value, bool _percent)
: ConfigOptionPercent(_value), percent(_percent) {};
void set(const ConfigOption &option) {
const ConfigOptionFloatOrPercent* other = dynamic_cast< const ConfigOptionFloatOrPercent* >(&option);
if (other != NULL) {
this->value = other->value;
this->percent = other->percent;
}
};
double get_abs_value(double ratio_over) const { double get_abs_value(double ratio_over) const {
if (this->percent) { if (this->percent) {
@ -285,28 +311,26 @@ class ConfigOptionFloatOrPercent : public ConfigOption
}; };
}; };
class ConfigOptionPoint : public ConfigOption class ConfigOptionPoint : public ConfigOptionSingle<Pointf>
{ {
public: public:
Pointf point; ConfigOptionPoint() : ConfigOptionSingle(Pointf(0,0)) {};
ConfigOptionPoint() : point(Pointf(0,0)) {}; ConfigOptionPoint(Pointf _value) : ConfigOptionSingle(_value) {};
operator Pointf() const { return this->point; };
std::string serialize() const { std::string serialize() const {
std::ostringstream ss; std::ostringstream ss;
ss << this->point.x; ss << this->value.x;
ss << ","; ss << ",";
ss << this->point.y; ss << this->value.y;
return ss.str(); return ss.str();
}; };
bool deserialize(std::string str) { bool deserialize(std::string str) {
std::istringstream iss(str); std::istringstream iss(str);
iss >> this->point.x; iss >> this->value.x;
iss.ignore(std::numeric_limits<std::streamsize>::max(), ','); iss.ignore(std::numeric_limits<std::streamsize>::max(), ',');
iss.ignore(std::numeric_limits<std::streamsize>::max(), 'x'); iss.ignore(std::numeric_limits<std::streamsize>::max(), 'x');
iss >> this->point.y; iss >> this->value.y;
return true; return true;
}; };
}; };
@ -356,13 +380,13 @@ class ConfigOptionPoints : public ConfigOptionVector<Pointf>
}; };
}; };
class ConfigOptionBool : public ConfigOption class ConfigOptionBool : public ConfigOptionSingle<bool>
{ {
public: public:
bool value; ConfigOptionBool() : ConfigOptionSingle(false) {};
ConfigOptionBool() : value(false) {}; ConfigOptionBool(bool _value) : ConfigOptionSingle(_value) {};
operator bool() const { return this->value; }; bool getBool() const { return this->value; };
std::string serialize() const { std::string serialize() const {
return std::string(this->value ? "1" : "0"); return std::string(this->value ? "1" : "0");
@ -411,12 +435,12 @@ class ConfigOptionBools : public ConfigOptionVector<bool>
typedef std::map<std::string,int> t_config_enum_values; typedef std::map<std::string,int> t_config_enum_values;
template <class T> template <class T>
class ConfigOptionEnum : public ConfigOption class ConfigOptionEnum : public ConfigOptionSingle<T>
{ {
public: public:
T value; // by default, use the first value (0) of the T enum type
ConfigOptionEnum() : ConfigOptionSingle<T>(static_cast<T>(0)) {};
operator T() const { return this->value; }; ConfigOptionEnum(T _value) : ConfigOptionSingle<T>(_value) {};
std::string serialize() const { std::string serialize() const {
t_config_enum_values enum_keys_map = ConfigOptionEnum<T>::get_enum_values(); t_config_enum_values enum_keys_map = ConfigOptionEnum<T>::get_enum_values();
@ -438,16 +462,13 @@ class ConfigOptionEnum : public ConfigOption
/* We use this one in DynamicConfig objects, otherwise it's better to use /* We use this one in DynamicConfig objects, otherwise it's better to use
the specialized ConfigOptionEnum<T> containers. */ the specialized ConfigOptionEnum<T> containers. */
class ConfigOptionEnumGeneric : public ConfigOption class ConfigOptionEnumGeneric : public ConfigOptionInt
{ {
public: public:
int value; const t_config_enum_values* keys_map;
t_config_enum_values* keys_map;
operator int() const { return this->value; };
std::string serialize() const { std::string serialize() const {
for (t_config_enum_values::iterator it = this->keys_map->begin(); it != this->keys_map->end(); ++it) { for (t_config_enum_values::const_iterator it = this->keys_map->begin(); it != this->keys_map->end(); ++it) {
if (it->second == this->value) return it->first; if (it->second == this->value) return it->first;
} }
return ""; return "";
@ -455,7 +476,7 @@ class ConfigOptionEnumGeneric : public ConfigOption
bool deserialize(std::string str) { bool deserialize(std::string str) {
if (this->keys_map->count(str) == 0) return false; if (this->keys_map->count(str) == 0) return false;
this->value = (*this->keys_map)[str]; this->value = (*const_cast<t_config_enum_values*>(this->keys_map))[str];
return true; return true;
}; };
}; };
@ -481,6 +502,7 @@ class ConfigOptionDef
{ {
public: public:
ConfigOptionType type; ConfigOptionType type;
ConfigOption* default_value;
std::string gui_type; std::string gui_type;
std::string gui_flags; std::string gui_flags;
std::string label; std::string label;
@ -503,17 +525,25 @@ class ConfigOptionDef
std::vector<std::string> enum_labels; std::vector<std::string> enum_labels;
t_config_enum_values enum_keys_map; t_config_enum_values enum_keys_map;
ConfigOptionDef() : type(coNone), ConfigOptionDef() : type(coNone), default_value(NULL),
multiline(false), full_width(false), readonly(false), multiline(false), full_width(false), readonly(false),
height(-1), width(-1), min(INT_MIN), max(INT_MAX) {}; height(-1), width(-1), min(INT_MIN), max(INT_MAX) {};
}; };
typedef std::map<t_config_option_key,ConfigOptionDef> t_optiondef_map; typedef std::map<t_config_option_key,ConfigOptionDef> t_optiondef_map;
class ConfigDef
{
public:
t_optiondef_map options;
~ConfigDef();
const ConfigOptionDef* get(const t_config_option_key &opt_key) const;
};
class ConfigBase class ConfigBase
{ {
public: public:
t_optiondef_map* def; const ConfigDef* def;
ConfigBase() : def(NULL) {}; ConfigBase() : def(NULL) {};
bool has(const t_config_option_key &opt_key); bool has(const t_config_option_key &opt_key);
@ -539,7 +569,7 @@ class ConfigBase
#endif #endif
}; };
class DynamicConfig : public ConfigBase class DynamicConfig : public virtual ConfigBase
{ {
public: public:
DynamicConfig() {}; DynamicConfig() {};
@ -558,12 +588,14 @@ class DynamicConfig : public ConfigBase
t_options_map options; t_options_map options;
}; };
class StaticConfig : public ConfigBase class StaticConfig : public virtual ConfigBase
{ {
public: public:
StaticConfig() : ConfigBase() {};
t_config_option_keys keys() const; t_config_option_keys keys() const;
virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0; virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0;
const ConfigOption* option(const t_config_option_key &opt_key) const; const ConfigOption* option(const t_config_option_key &opt_key) const;
void set_defaults();
#ifdef SLIC3RXS #ifdef SLIC3RXS
bool set(t_config_option_key opt_key, SV* value); bool set(t_config_option_key opt_key, SV* value);

View File

@ -41,40 +41,28 @@ PlaceholderParser::update_timestamp()
this->set("second", timeinfo->tm_sec); this->set("second", timeinfo->tm_sec);
} }
void PlaceholderParser::apply_config(DynamicPrintConfig &config) void PlaceholderParser::apply_config(const DynamicPrintConfig &config)
{ {
// options that are set and aren't text-boxes t_config_option_keys opt_keys = config.keys();
t_config_option_keys opt_keys; for (t_config_option_keys::const_iterator i = opt_keys.begin(); i != opt_keys.end(); ++i) {
for (t_optiondef_map::iterator i = config.def->begin(); const t_config_option_key &opt_key = *i;
i != config.def->end(); ++i) const ConfigOptionDef* def = config.def->get(opt_key);
{ if (def->multiline) continue;
const t_config_option_key &key = i->first;
const ConfigOptionDef &def = i->second;
if (config.has(key) && !def.multiline) {
opt_keys.push_back(key);
}
}
for (t_config_option_keys::iterator i = opt_keys.begin();
i != opt_keys.end(); ++i)
{
const t_config_option_key &key = *i;
const ConfigOption* opt = config.option(key);
const ConfigOption* opt = config.option(opt_key);
if (const ConfigOptionVectorBase* optv = dynamic_cast<const ConfigOptionVectorBase*>(opt)) { if (const ConfigOptionVectorBase* optv = dynamic_cast<const ConfigOptionVectorBase*>(opt)) {
// set placeholders for options with multiple values // set placeholders for options with multiple values
// TODO: treat [bed_shape] as single, not multiple // TODO: treat [bed_shape] as single, not multiple
this->set(key, optv->vserialize()); this->set(opt_key, optv->vserialize());
} else if (const ConfigOptionPoint* optp = dynamic_cast<const ConfigOptionPoint*>(opt)) { } else if (const ConfigOptionPoint* optp = dynamic_cast<const ConfigOptionPoint*>(opt)) {
this->set(key, optp->serialize()); this->set(opt_key, optp->serialize());
Pointf val = *optp; Pointf val = *optp;
this->set(key + "_X", val.x); this->set(opt_key + "_X", val.x);
this->set(key + "_Y", val.y); this->set(opt_key + "_Y", val.y);
} else { } else {
// set single-value placeholders // set single-value placeholders
this->set(key, opt->serialize()); this->set(opt_key, opt->serialize());
} }
} }
} }

View File

@ -22,7 +22,7 @@ class PlaceholderParser
PlaceholderParser(); PlaceholderParser();
void update_timestamp(); void update_timestamp();
void apply_config(DynamicPrintConfig &config); void apply_config(const DynamicPrintConfig &config);
void apply_env_variables(); void apply_env_variables();
void set(const std::string &key, const std::string &value); void set(const std::string &key, const std::string &value);
void set(const std::string &key, int value); void set(const std::string &key, int value);

File diff suppressed because it is too large Load Diff

View File

@ -67,33 +67,38 @@ template<> inline t_config_enum_values ConfigOptionEnum<SeamPosition>::get_enum_
return keys_map; return keys_map;
} }
class PrintConfigDef class PrintConfigDef : public ConfigDef
{ {
public: public:
static t_optiondef_map def; PrintConfigDef();
static t_optiondef_map build_def();
}; };
class DynamicPrintConfig : public DynamicConfig extern PrintConfigDef print_config_def;
class PrintConfigBase : public virtual ConfigBase
{ {
public: public:
DynamicPrintConfig() { PrintConfigBase() {
this->def = &PrintConfigDef::def; this->def = &print_config_def;
}; };
double min_object_distance() const;
};
class DynamicPrintConfig : public PrintConfigBase, public DynamicConfig
{
public:
DynamicPrintConfig() : PrintConfigBase(), DynamicConfig() {};
void normalize(); void normalize();
}; };
class StaticPrintConfig : public virtual StaticConfig class StaticPrintConfigBase : public PrintConfigBase, public StaticConfig
{ {
public: public:
StaticPrintConfig() { StaticPrintConfigBase() : PrintConfigBase(), StaticConfig() {};
this->def = &PrintConfigDef::def;
};
}; };
class PrintObjectConfig : public virtual StaticPrintConfig class PrintObjectConfig : public virtual StaticPrintConfigBase
{ {
public: public:
ConfigOptionBool dont_support_bridges; ConfigOptionBool dont_support_bridges;
@ -120,34 +125,8 @@ class PrintObjectConfig : public virtual StaticPrintConfig
ConfigOptionInt support_material_threshold; ConfigOptionInt support_material_threshold;
ConfigOptionFloat xy_size_compensation; ConfigOptionFloat xy_size_compensation;
PrintObjectConfig() : StaticPrintConfig() { PrintObjectConfig() : StaticPrintConfigBase() {
this->dont_support_bridges.value = true; this->set_defaults();
this->extrusion_width.value = 0;
this->extrusion_width.percent = false;
this->first_layer_height.value = 0.35;
this->first_layer_height.percent = false;
this->infill_only_where_needed.value = false;
this->interface_shells.value = false;
this->layer_height.value = 0.3;
this->raft_layers.value = 0;
this->seam_position.value = spAligned;
this->support_material.value = false;
this->support_material_angle.value = 0;
this->support_material_contact_distance.value = 0.2;
this->support_material_enforce_layers.value = 0;
this->support_material_extruder.value = 1;
this->support_material_extrusion_width.value = 0;
this->support_material_extrusion_width.percent = false;
this->support_material_interface_extruder.value = 1;
this->support_material_interface_layers.value = 3;
this->support_material_interface_spacing.value = 0;
this->support_material_interface_speed.value = 100;
this->support_material_interface_speed.percent = true;
this->support_material_pattern.value = smpPillars;
this->support_material_spacing.value = 2.5;
this->support_material_speed.value = 60;
this->support_material_threshold.value = 0;
this->xy_size_compensation.value = 0;
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
@ -179,7 +158,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig
}; };
}; };
class PrintRegionConfig : public virtual StaticPrintConfig class PrintRegionConfig : public virtual StaticPrintConfigBase
{ {
public: public:
ConfigOptionInt bottom_solid_layers; ConfigOptionInt bottom_solid_layers;
@ -215,49 +194,8 @@ class PrintRegionConfig : public virtual StaticPrintConfig
ConfigOptionInt top_solid_layers; ConfigOptionInt top_solid_layers;
ConfigOptionFloatOrPercent top_solid_infill_speed; ConfigOptionFloatOrPercent top_solid_infill_speed;
PrintRegionConfig() : StaticPrintConfig() { PrintRegionConfig() : StaticPrintConfigBase() {
this->bottom_solid_layers.value = 3; this->set_defaults();
this->bridge_flow_ratio.value = 1;
this->bridge_speed.value = 60;
this->external_fill_pattern.value = ipRectilinear;
this->external_perimeter_extrusion_width.value = 0;
this->external_perimeter_extrusion_width.percent = false;
this->external_perimeter_speed.value = 50;
this->external_perimeter_speed.percent = true;
this->external_perimeters_first.value = false;
this->extra_perimeters.value = true;
this->fill_angle.value = 45;
this->fill_density.value = 20;
this->fill_pattern.value = ipHoneycomb;
this->gap_fill_speed.value = 20;
this->infill_extruder.value = 1;
this->infill_extrusion_width.value = 0;
this->infill_extrusion_width.percent = false;
this->infill_every_layers.value = 1;
this->infill_overlap.value = 15;
this->infill_overlap.percent = true;
this->infill_speed.value = 80;
this->overhangs.value = true;
this->perimeter_extruder.value = 1;
this->perimeter_extrusion_width.value = 0;
this->perimeter_extrusion_width.percent = false;
this->perimeter_speed.value = 60;
this->perimeters.value = 3;
this->solid_infill_extruder.value = 1;
this->small_perimeter_speed.value = 15;
this->small_perimeter_speed.percent = false;
this->solid_infill_below_area.value = 70;
this->solid_infill_extrusion_width.value = 0;
this->solid_infill_extrusion_width.percent = false;
this->solid_infill_every_layers.value = 0;
this->solid_infill_speed.value = 20;
this->solid_infill_speed.percent = false;
this->thin_walls.value = true;
this->top_infill_extrusion_width.value = 0;
this->top_infill_extrusion_width.percent = false;
this->top_solid_infill_speed.value = 15;
this->top_solid_infill_speed.percent = false;
this->top_solid_layers.value = 3;
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
@ -298,7 +236,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig
}; };
}; };
class GCodeConfig : public virtual StaticPrintConfig class GCodeConfig : public virtual StaticPrintConfigBase
{ {
public: public:
ConfigOptionString before_layer_gcode; ConfigOptionString before_layer_gcode;
@ -317,7 +255,7 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOptionFloats retract_lift; ConfigOptionFloats retract_lift;
ConfigOptionFloats retract_restart_extra; ConfigOptionFloats retract_restart_extra;
ConfigOptionFloats retract_restart_extra_toolchange; ConfigOptionFloats retract_restart_extra_toolchange;
ConfigOptionInts retract_speed; ConfigOptionFloats retract_speed;
ConfigOptionString start_gcode; ConfigOptionString start_gcode;
ConfigOptionString toolchange_gcode; ConfigOptionString toolchange_gcode;
ConfigOptionFloat travel_speed; ConfigOptionFloat travel_speed;
@ -325,38 +263,8 @@ class GCodeConfig : public virtual StaticPrintConfig
ConfigOptionBool use_relative_e_distances; ConfigOptionBool use_relative_e_distances;
ConfigOptionBool use_volumetric_e; ConfigOptionBool use_volumetric_e;
GCodeConfig() : StaticPrintConfig() { GCodeConfig() : StaticPrintConfigBase() {
this->before_layer_gcode.value = ""; this->set_defaults();
this->end_gcode.value = "M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n";
this->extrusion_axis.value = "E";
this->extrusion_multiplier.values.resize(1);
this->extrusion_multiplier.values[0] = 1;
this->filament_diameter.values.resize(1);
this->filament_diameter.values[0] = 3;
this->gcode_comments.value = false;
this->gcode_flavor.value = gcfRepRap;
this->layer_gcode.value = "";
this->max_print_speed.value = 80;
this->max_volumetric_speed.value = 0;
this->pressure_advance.value = 0;
this->retract_length.values.resize(1);
this->retract_length.values[0] = 2;
this->retract_length_toolchange.values.resize(1);
this->retract_length_toolchange.values[0] = 10;
this->retract_lift.values.resize(1);
this->retract_lift.values[0] = 0;
this->retract_restart_extra.values.resize(1);
this->retract_restart_extra.values[0] = 0;
this->retract_restart_extra_toolchange.values.resize(1);
this->retract_restart_extra_toolchange.values[0] = 0;
this->retract_speed.values.resize(1);
this->retract_speed.values[0] = 40;
this->start_gcode.value = "G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n";
this->toolchange_gcode.value = "";
this->travel_speed.value = 130;
this->use_firmware_retraction.value = false;
this->use_relative_e_distances.value = false;
this->use_volumetric_e.value = false;
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
@ -429,7 +337,7 @@ class PrintConfig : public GCodeConfig
ConfigOptionBool infill_first; ConfigOptionBool infill_first;
ConfigOptionInt max_fan_speed; ConfigOptionInt max_fan_speed;
ConfigOptionInt min_fan_speed; ConfigOptionInt min_fan_speed;
ConfigOptionInt min_print_speed; ConfigOptionFloat min_print_speed;
ConfigOptionFloat min_skirt_length; ConfigOptionFloat min_skirt_length;
ConfigOptionString notes; ConfigOptionString notes;
ConfigOptionFloats nozzle_diameter; ConfigOptionFloats nozzle_diameter;
@ -454,68 +362,7 @@ class PrintConfig : public GCodeConfig
ConfigOptionFloat z_offset; ConfigOptionFloat z_offset;
PrintConfig() : GCodeConfig() { PrintConfig() : GCodeConfig() {
this->avoid_crossing_perimeters.value = false; this->set_defaults();
this->bed_shape.values.push_back(Pointf(0,0));
this->bed_shape.values.push_back(Pointf(200,0));
this->bed_shape.values.push_back(Pointf(200,200));
this->bed_shape.values.push_back(Pointf(0,200));
this->bed_temperature.value = 0;
this->bridge_acceleration.value = 0;
this->bridge_fan_speed.value = 100;
this->brim_width.value = 0;
this->complete_objects.value = false;
this->cooling.value = true;
this->default_acceleration.value = 0;
this->disable_fan_first_layers.value = 3;
this->duplicate_distance.value = 6;
this->extruder_clearance_height.value = 20;
this->extruder_clearance_radius.value = 20;
this->extruder_offset.values.resize(1);
this->extruder_offset.values[0] = Pointf(0,0);
this->fan_always_on.value = false;
this->fan_below_layer_time.value = 60;
this->filament_colour.values.resize(1);
this->filament_colour.values[0] = "#FFFFFF";
this->first_layer_acceleration.value = 0;
this->first_layer_bed_temperature.value = 0;
this->first_layer_extrusion_width.value = 200;
this->first_layer_extrusion_width.percent = true;
this->first_layer_speed.value = 30;
this->first_layer_speed.percent = false;
this->first_layer_temperature.values.resize(1);
this->first_layer_temperature.values[0] = 200;
this->gcode_arcs.value = false;
this->infill_acceleration.value = 0;
this->infill_first.value = false;
this->max_fan_speed.value = 100;
this->min_fan_speed.value = 35;
this->min_print_speed.value = 10;
this->min_skirt_length.value = 0;
this->notes.value = "";
this->nozzle_diameter.values.resize(1);
this->nozzle_diameter.values[0] = 0.5;
this->only_retract_when_crossing_perimeters.value = true;
this->ooze_prevention.value = false;
this->output_filename_format.value = "[input_filename_base].gcode";
this->perimeter_acceleration.value = 0;
this->resolution.value = 0;
this->retract_before_travel.values.resize(1);
this->retract_before_travel.values[0] = 2;
this->retract_layer_change.values.resize(1);
this->retract_layer_change.values[0] = false;
this->skirt_distance.value = 6;
this->skirt_height.value = 1;
this->skirts.value = 1;
this->slowdown_below_layer_time.value = 5;
this->spiral_vase.value = false;
this->standby_temperature_delta.value = -5;
this->temperature.values.resize(1);
this->temperature.values[0] = 200;
this->threads.value = 2;
this->vibration_limit.value = 0;
this->wipe.values.resize(1);
this->wipe.values[0] = false;
this->z_offset.value = 0;
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
@ -576,11 +423,9 @@ class PrintConfig : public GCodeConfig
return NULL; return NULL;
}; };
double min_object_distance() const;
}; };
class HostConfig : public virtual StaticPrintConfig class HostConfig : public virtual StaticPrintConfigBase
{ {
public: public:
ConfigOptionString octoprint_host; ConfigOptionString octoprint_host;
@ -588,11 +433,8 @@ class HostConfig : public virtual StaticPrintConfig
ConfigOptionString serial_port; ConfigOptionString serial_port;
ConfigOptionInt serial_speed; ConfigOptionInt serial_speed;
HostConfig() : StaticPrintConfig() { HostConfig() : StaticPrintConfigBase() {
this->octoprint_host.value = ""; this->set_defaults();
this->octoprint_apikey.value = "";
this->serial_port.value = "";
this->serial_speed.value = 250000;
}; };
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) { ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {

View File

@ -30,6 +30,7 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) {
is $config->serialize('first_layer_height'), '0.3', 'serialize absolute floatOrPercent'; is $config->serialize('first_layer_height'), '0.3', 'serialize absolute floatOrPercent';
$config->set('first_layer_height', '50%'); $config->set('first_layer_height', '50%');
$config->get_abs_value('first_layer_height');
ok abs($config->get_abs_value('first_layer_height') - 0.15) < 1e-4, 'set/get relative floatOrPercent'; ok abs($config->get_abs_value('first_layer_height') - 0.15) < 1e-4, 'set/get relative floatOrPercent';
is $config->serialize('first_layer_height'), '50%', 'serialize relative floatOrPercent'; is $config->serialize('first_layer_height'), '50%', 'serialize relative floatOrPercent';

View File

@ -31,6 +31,7 @@
void erase(t_config_option_key opt_key); void erase(t_config_option_key opt_key);
void normalize(); void normalize();
%name{setenv} void setenv_(); %name{setenv} void setenv_();
double min_object_distance();
}; };
%name{Slic3r::Config::GCode} class GCodeConfig { %name{Slic3r::Config::GCode} class GCodeConfig {
@ -158,11 +159,11 @@ PROTOTYPES: DISABLE
SV* SV*
print_config_def() print_config_def()
CODE: CODE:
t_optiondef_map &def = Slic3r::print_config_def.options;
FullPrintConfig config; FullPrintConfig config;
t_optiondef_map* def = config.def;
HV* options_hv = newHV(); HV* options_hv = newHV();
for (t_optiondef_map::iterator oit = def->begin(); oit != def->end(); ++oit) { for (t_optiondef_map::iterator oit = def.begin(); oit != def.end(); ++oit) {
HV* hv = newHV(); HV* hv = newHV();
t_config_option_key opt_key = oit->first; t_config_option_key opt_key = oit->first;