diff --git a/src/lay/layApplication.cc b/src/lay/layApplication.cc index 09da07490..44ff914ca 100644 --- a/src/lay/layApplication.cc +++ b/src/lay/layApplication.cc @@ -1639,7 +1639,22 @@ void Application::set_config (const std::string &name, const std::string &value) { if (mp_plugin_root) { - mp_plugin_root->config_set (name, value); + + if (name == cfg_technologies) { + + // HACK: cfg_technologies is not a real configuration parameter currently. Hence we emulate that + // behavior. But currently this is the only way to access technology data indirectly from a script. + // Note that this method will set only the technologies accessible through the configuration parameter. + // I.e. the ones not auto-imported. + // TODO: rework this one. This is only half-hearted. + if (! value.empty ()) { + lay::Technologies::instance ()->load_from_xml (value); + } + + } else { + mp_plugin_root->config_set (name, value); + } + } } @@ -1655,7 +1670,16 @@ std::string Application::get_config (const std::string &name) const { if (mp_plugin_root) { - return mp_plugin_root->config_get (name); + if (name == cfg_technologies) { + // HACK: cfg_technologies is not a real configuration parameter currently. Hence we emulate that + // behavior. But currently this is the only way to access technology data indirectly from a script. + // Note that this method will return only the technologies accessible through the configuration parameter. + // I.e. the ones not auto-imported. + // TODO: rework this one. + return lay::Technologies::instance ()->to_xml (); + } else { + return mp_plugin_root->config_get (name); + } } else { return std::string (); } diff --git a/src/laybasic/layTechnology.cc b/src/laybasic/layTechnology.cc index 84bbec0e8..9750e2995 100644 --- a/src/laybasic/layTechnology.cc +++ b/src/laybasic/layTechnology.cc @@ -97,9 +97,19 @@ Technologies::to_xml () const void Technologies::load_from_xml (const std::string &s) { + // create a copy to filter out the ones which are not persisted and remain + lay::Technologies copy; + for (const_iterator t = begin (); t != end (); ++t) { + if (! t->is_persisted ()) { + copy.add (new Technology (*t)); + } + } + tl::XMLStringSource source (s); tl::XMLStruct xml_struct ("technologies", xml_elements ()); - xml_struct.parse (source, *this); + xml_struct.parse (source, copy); + + *this = copy; } void