| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/components/controls/controlgroup.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "controlgroup.h"cxx . . $ `<file>/src/core/components/controls/controlgroup.h`/ |
| 5 | |
| 6 | #include <utility> |
| 7 | |
| 8 | ControlGroupcxx . . $ ControlGroup#::ControlGroupcxx . . $ ControlGroup#ControlGroup(f82d4ed52a84f8e1).(stdcxx . . $ std/::string_viewcxx . . $ std/string_view# id, |
| 9 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IControlcxx . . $ IControl#>> &&controls, |
| 10 | bool active) noexcept |
| 11 | : Controlcxx . . $ Control#(active) |
| 12 | , id_cxx . . $ ControlGroup#id_.(id) |
| 13 | , controls_cxx . . $ ControlGroup#controls_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(controls)) |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | void ControlGroupcxx . . $ ControlGroup#::preInitcxx . . $ ControlGroup#preInit(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds) |
| 18 | { |
| 19 | for (auto &control : controls_cxx . . $ ControlGroup#controls_.) |
| 20 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).preInitcxx . . $ IControl#preInit(151e9138769f295e).(ctlCmds); |
| 21 | } |
| 22 | |
| 23 | void ControlGroupcxx . . $ ControlGroup#::postInitcxx . . $ ControlGroup#postInit(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds) |
| 24 | { |
| 25 | for (auto &control : controls_cxx . . $ ControlGroup#controls_.) |
| 26 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).postInitcxx . . $ IControl#postInit(151e9138769f295e).(ctlCmds); |
| 27 | } |
| 28 | |
| 29 | void ControlGroupcxx . . $ ControlGroup#::initcxx . . $ ControlGroup#init(49f6e7a06ebc5aa8).() |
| 30 | { |
| 31 | if (!controls_cxx . . $ ControlGroup#controls_..emptycxx . . $ std/vector#empty(3482b152b9333168).()) { |
| 32 | for (auto &control : controls_cxx . . $ ControlGroup#controls_.) { |
| 33 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initcxx . . $ IControl#init(49f6e7a06ebc5aa8).(); |
| 34 | |
| 35 | // activate inactive controls |
| 36 | if (!control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activecxx . . $ IControl#active(50ce9a9e25b4a850).()) |
| 37 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activatecxx . . $ IControl#activate(b45ddcbc8423892c).(true); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | stdcxx . . $ std/::stringcxx . . $ std/string# const &ControlGroupcxx . . $ ControlGroup#::IDcxx . . $ ControlGroup#ID(f4fff0029955a25f).() const |
| 43 | { |
| 44 | return id_cxx . . $ ControlGroup#id_.; |
| 45 | } |
| 46 | |
| 47 | void ControlGroupcxx . . $ ControlGroup#::activatecxx . . $ ControlGroup#activate(b45ddcbc8423892c).(bool active) |
| 48 | { |
| 49 | Controlcxx . . $ Control#::activatecxx . . $ Control#activate(b45ddcbc8423892c).(active); |
| 50 | |
| 51 | if (dirtycxx . . $ Control#dirty(50ce9a9e25b4a850).()) { |
| 52 | // All aggregated controls are always active. Therefore, we must |
| 53 | // clean them manually as they will never enter in dirty state on |
| 54 | // their own. |
| 55 | for (auto &control : controls_cxx . . $ ControlGroup#controls_.) |
| 56 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).cleanOncecxx . . $ IControl#cleanOnce(49f6e7a06ebc5aa8).(); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | void ControlGroupcxx . . $ ControlGroup#::cleanOncecxx . . $ ControlGroup#cleanOnce(49f6e7a06ebc5aa8).() |
| 61 | { |
| 62 | Controlcxx . . $ Control#::cleanOncecxx . . $ Control#cleanOnce(49f6e7a06ebc5aa8).(); |
| 63 | |
| 64 | // propagate clean once to aggregated controls |
| 65 | for (auto &control : controls_cxx . . $ ControlGroup#controls_.) |
| 66 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).cleanOncecxx . . $ IControl#cleanOnce(49f6e7a06ebc5aa8).(); |
| 67 | } |
| 68 | |
| 69 | void ControlGroupcxx . . $ ControlGroup#::importControlcxx . . $ ControlGroup#importControl(4f796e3ecd5dcd94).(IControlcxx . . $ IControl#::Importercxx . . $ IControl#Importer# &i) |
| 70 | { |
| 71 | for (auto &control : controls_cxx . . $ ControlGroup#controls_.) { |
| 72 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).importWithcxx . . $ Importable#importWith(94eddebf9440278).(i); |
| 73 | |
| 74 | // ensure that all controls are active |
| 75 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activatecxx . . $ IControl#activate(b45ddcbc8423892c).(true); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | void ControlGroupcxx . . $ ControlGroup#::exportControlcxx . . $ ControlGroup#exportControl(40299682ab9c8676).(IControlcxx . . $ IControl#::Exportercxx . . $ IControl#Exporter# &e) const |
| 80 | { |
| 81 | for (auto const &control : controls_cxx . . $ ControlGroup#controls_.) |
| 82 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).exportWithcxx . . $ Exportable#exportWith(5b5c94ff60635419).(e); |
| 83 | } |
| 84 | |
| 85 | void ControlGroupcxx . . $ ControlGroup#::cleanControlcxx . . $ ControlGroup#cleanControl(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds) |
| 86 | { |
| 87 | for (auto &control : controls_cxx . . $ ControlGroup#controls_.) |
| 88 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).cleancxx . . $ IControl#clean(151e9138769f295e).(ctlCmds); |
| 89 | } |
| 90 | |
| 91 | void ControlGroupcxx . . $ ControlGroup#::syncControlcxx . . $ ControlGroup#syncControl(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds) |
| 92 | { |
| 93 | for (auto &control : controls_cxx . . $ ControlGroup#controls_.) |
| 94 | control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).synccxx . . $ IControl#sync(151e9138769f295e).(ctlCmds); |
| 95 | } |