sculpt_manager: Deploy::use_as_deploy_template

This patch simplifies the 'Deploy::update_managed_deploy_config'
interface by keeping an internal copy of the currently used deploy
template inside the 'Deploy' class. The template is updated whenever
the config/deploy file is modified.

This change weakens the coupling between the '_manual_deploy_rom' and
the '_deploy' subsystem, easing the upcoming implementation of the
switching between presets.
This commit is contained in:
Norman Feske 2023-01-10 15:53:00 +01:00 committed by Christian Helmuth
parent bf231f7fca
commit 79d8d1d557
2 changed files with 27 additions and 6 deletions

View File

@ -78,7 +78,27 @@ struct Sculpt::Deploy
/* config obtained from '/config/managed/deploy' */
Attached_rom_dataspace _managed_deploy_rom { _env, "config -> managed/deploy" };
void update_managed_deploy_config(Xml_node deploy)
Constructible<Buffered_xml> _template { };
void use_as_deploy_template(Xml_node const &deploy)
{
_template.construct(_alloc, deploy);
}
void update_managed_deploy_config()
{
if (!_template.constructed())
return;
Xml_node const deploy = _template->xml();
if (deploy.type() == "empty")
return;
_update_managed_deploy_config(deploy);
}
void _update_managed_deploy_config(Xml_node deploy)
{
/*
* Ignore intermediate states that may occur when manually updating

View File

@ -397,7 +397,8 @@ struct Sculpt::Main : Input_event_handler,
{
_runtime_state.reset_abandoned_and_launched_children();
_manual_deploy_rom.update();
_deploy.update_managed_deploy_config(_manual_deploy_rom.xml());
_deploy.use_as_deploy_template(_manual_deploy_rom.xml());
_deploy.update_managed_deploy_config();
}
Signal_handler<Main> _manual_deploy_handler {
@ -794,7 +795,7 @@ struct Sculpt::Main : Input_event_handler,
_runtime_state.abandon(name);
/* update config/managed/deploy with the component 'name' removed */
_deploy.update_managed_deploy_config(_manual_deploy_rom.xml());
_deploy.update_managed_deploy_config();
}
/*
@ -822,7 +823,7 @@ struct Sculpt::Main : Input_event_handler,
_runtime_state.restart(name);
/* update config/managed/deploy with the component 'name' removed */
_deploy.update_managed_deploy_config(_manual_deploy_rom.xml());
_deploy.update_managed_deploy_config();
}
}
@ -1078,7 +1079,7 @@ struct Sculpt::Main : Input_event_handler,
_close_popup_dialog();
/* trigger change of the deployment */
_deploy.update_managed_deploy_config(_manual_deploy_rom.xml());
_deploy.update_managed_deploy_config();
}
Start_name new_construction(Component::Path const &pkg,
@ -1101,7 +1102,7 @@ struct Sculpt::Main : Input_event_handler,
_close_popup_dialog();
/* trigger change of the deployment */
_deploy.update_managed_deploy_config(_manual_deploy_rom.xml());
_deploy.update_managed_deploy_config();
}
void trigger_download(Path const &path) override