Debian Codegraph @

src/core/components/controls/controlgroup.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "controlgroup.h"
5
6 #include <utility>
7
8 ControlGroup::ControlGroup(std::string_view id,
9 std::vector<std::unique_ptr<IControl>> &&controls,
10 bool active) noexcept
11 : Control(active)
12 , id_(id)
13 , controls_(std::move(controls))
14 {
15 }
16
17 void ControlGroup::preInit(ICommandQueue &ctlCmds)
18 {
19 for (auto &control : controls_)
20 control->preInit(ctlCmds);
21 }
22
23 void ControlGroup::postInit(ICommandQueue &ctlCmds)
24 {
25 for (auto &control : controls_)
26 control->postInit(ctlCmds);
27 }
28
29 void ControlGroup::init()
30 {
31 if (!controls_.empty()) {
32 for (auto &control : controls_) {
33 control->init();
34
35 // activate inactive controls
36 if (!control->active())
37 control->activate(true);
38 }
39 }
40 }
41
42 std::string const &ControlGroup::ID() const
43 {
44 return id_;
45 }
46
47 void ControlGroup::activate(bool active)
48 {
49 Control::activate(active);
50
51 if (dirty()) {
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_)
56 control->cleanOnce();
57 }
58 }
59
60 void ControlGroup::cleanOnce()
61 {
62 Control::cleanOnce();
63
64 // propagate clean once to aggregated controls
65 for (auto &control : controls_)
66 control->cleanOnce();
67 }
68
69 void ControlGroup::importControl(IControl::Importer &i)
70 {
71 for (auto &control : controls_) {
72 control->importWith(i);
73
74 // ensure that all controls are active
75 control->activate(true);
76 }
77 }
78
79 void ControlGroup::exportControl(IControl::Exporter &e) const
80 {
81 for (auto const &control : controls_)
82 control->exportWith(e);
83 }
84
85 void ControlGroup::cleanControl(ICommandQueue &ctlCmds)
86 {
87 for (auto &control : controls_)
88 control->clean(ctlCmds);
89 }
90
91 void ControlGroup::syncControl(ICommandQueue &ctlCmds)
92 {
93 for (auto &control : controls_)
94 control->sync(ctlCmds);
95 }