Added template function to make getting references to ConfigOptions easier to write.

This commit is contained in:
Joseph Lenox 2018-05-05 16:13:34 -05:00 committed by Joseph Lenox
parent e4aa624ccb
commit 65a1d57d05

View File

@ -16,6 +16,13 @@ public:
void write_ini(const std::string& file) { save(file); }
void read_ini(const std::string& file) { load(file); }
/// Template function to retrieve and cast in hopefully a slightly nicer
/// format than longwinded dynamic_cast<>
template <class T>
T& get(const t_config_option_key& opt_key, bool create=false) {
return *(dynamic_cast<T*>(this->optptr(opt_key, create)));
}
};
} // namespace Slic3r