Preset::config() returns a weak reference to the shared configuration.

This commit is contained in:
Joseph Lenox 2018-11-17 20:57:03 -06:00 committed by Joseph Lenox
parent ef37a748ff
commit 76be75431b
3 changed files with 9 additions and 0 deletions

View File

@ -44,6 +44,11 @@ Slic3r::Config Preset::dirty_config() {
return result;
}
config_ref Preset::config() {
std::weak_ptr<Slic3r::Config> result { this->_dirty_config };
return result;
}
config_ptr Preset::load_config() {
if (this->loaded()) return this->_dirty_config;

View File

@ -78,6 +78,9 @@ public:
/// Retrieve a copy of the loaded version of the configuration with any options applied.
Slic3r::Config dirty_config();
/// Retrieve a shared (cast through a weak) pointer.
config_ref config();
/// Pass-through to Slic3r::Config, returns whether or not a config was loaded.
bool loaded() { return !this->_config->empty(); }

View File

@ -33,6 +33,7 @@ public:
class Config;
using config_ptr = std::shared_ptr<Config>;
using config_ref = std::weak_ptr<Config>;
class Config {
public: