Debian Codegraph @

src/core/components/controls/controlmode.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/components/controls/controlmode.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "controlmode.h"cxx . . $ `<file>/src/core/components/controls/controlmode.h`/
5
6 #include <algorithm>
7 #include <utility>
8
9 ControlModecxx . . $ ControlMode#::ControlModecxx . . $ ControlMode#ControlMode(f82d4ed52a84f8e1).(stdcxx . . $ std/::string_viewcxx . . $ std/string_view# id,
10 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IControlcxx . . $ IControl#>> &&controls,
11 bool active) noexcept
12 : Controlcxx . . $ Control#(active, true)
13 , id_cxx . . $ ControlMode#id_.(id)
14 , controls_cxx . . $ ControlMode#controls_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(controls))
15 {
16 }
17
18 void ControlModecxx . . $ ControlMode#::preInitcxx . . $ ControlMode#preInit(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds)
19 {
20 for (auto &control : controls_cxx . . $ ControlMode#controls_.)
21 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).preInitcxx . . $ IControl#preInit(151e9138769f295e).(ctlCmds);
22 }
23
24 void ControlModecxx . . $ ControlMode#::postInitcxx . . $ ControlMode#postInit(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds)
25 {
26 for (auto &control : controls_cxx . . $ ControlMode#controls_.)
27 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).postInitcxx . . $ IControl#postInit(151e9138769f295e).(ctlCmds);
28 }
29
30 void ControlModecxx . . $ ControlMode#::initcxx . . $ ControlMode#init(49f6e7a06ebc5aa8).()
31 {
32 // Set the first active control as the active mode
33 // or the first one when no active controls are found.
34
35 bool activeFound{false};
36 for (auto &control : controls_cxx . . $ ControlMode#controls_.) {
37 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initcxx . . $ IControl#init(49f6e7a06ebc5aa8).();
38
39 if (!activeFound && control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activecxx . . $ IControl#active(50ce9a9e25b4a850).()) {
40 mode_cxx . . $ ControlMode#mode_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IDcxx . . $ Item#ID(f4fff0029955a25f).();
41 activeFound = true;
42 }
43 else if (activeFound && control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activecxx . . $ IControl#active(50ce9a9e25b4a850).())
44 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activatecxx . . $ IControl#activate(b45ddcbc8423892c).(false);
45 }
46
47 if (!activeFound && !controls_cxx . . $ ControlMode#controls_..emptycxx . . $ std/vector#empty(3482b152b9333168).()) {
48 auto &control = controls_cxx . . $ ControlMode#controls_..frontcxx . . $ std/vector#front(af0004c3ce7cab93).();
49 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activatecxx . . $ IControl#activate(b45ddcbc8423892c).(true);
50 mode_cxx . . $ ControlMode#mode_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IDcxx . . $ Item#ID(f4fff0029955a25f).();
51 }
52 }
53
54 stdcxx . . $ std/::stringcxx . . $ std/string# const &ControlModecxx . . $ ControlMode#::IDcxx . . $ ControlMode#ID(f4fff0029955a25f).() const
55 {
56 return id_cxx . . $ ControlMode#id_.;
57 }
58
59 void ControlModecxx . . $ ControlMode#::importControlcxx . . $ ControlMode#importControl(4f796e3ecd5dcd94).(IControlcxx . . $ IControl#::Importercxx . . $ IControl#Importer# &i)
60 {
61 auto &pModeImporter = dynamic_cast<ControlModecxx . . $ ControlMode#::Importercxx . . $ ControlMode#Importer# &>(i);
62 modecxx . . $ ControlMode#mode(9c546c94e5fcce4e).(pModeImporter.provideModecxx . . $ ControlMode#Importer#provideMode(f4fff0029955a25f).());
63
64 for (auto &control : controls_cxx . . $ ControlMode#controls_.) {
65 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).importWithcxx . . $ Importable#importWith(94eddebf9440278).(i);
66
67 // ensure that only the selected mode is active
68 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activatecxx . . $ IControl#activate(b45ddcbc8423892c).(control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IDcxx . . $ Item#ID(f4fff0029955a25f).() ==cxx . . $ std/`operator==`(5ea818b58063a774). modecxx . . $ ControlMode#mode(f4fff0029955a25f).());
69 }
70 }
71
72 void ControlModecxx . . $ ControlMode#::exportControlcxx . . $ ControlMode#exportControl(40299682ab9c8676).(IControlcxx . . $ IControl#::Exportercxx . . $ IControl#Exporter# &e) const
73 {
74 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> modescxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
75 for (auto const &control : controls_cxx . . $ ControlMode#controls_.) {
76 modes.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IDcxx . . $ Item#ID(f4fff0029955a25f).());
77 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).exportWithcxx . . $ Exportable#exportWith(5b5c94ff60635419).(e);
78 }
79
80 auto &pModeExporter = dynamic_cast<ControlModecxx . . $ ControlMode#::Exportercxx . . $ ControlMode#Exporter# &>(e);
81 pModeExporter.takeModescxx . . $ ControlMode#Exporter#takeModes(eb4a68411a16b7e7).(modes);
82 pModeExporter.takeModecxx . . $ ControlMode#Exporter#takeMode(9c546c94e5fcce4e).(modecxx . . $ ControlMode#mode(f4fff0029955a25f).());
83 }
84
85 void ControlModecxx . . $ ControlMode#::cleanControlcxx . . $ ControlMode#cleanControl(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds)
86 {
87 for (auto &control : controls_cxx . . $ ControlMode#controls_.)
88 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).cleancxx . . $ IControl#clean(151e9138769f295e).(ctlCmds);
89 }
90
91 void ControlModecxx . . $ ControlMode#::syncControlcxx . . $ ControlMode#syncControl(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds)
92 {
93 for (auto &control : controls_cxx . . $ ControlMode#controls_.)
94 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).synccxx . . $ IControl#sync(151e9138769f295e).(ctlCmds);
95 }
96
97 stdcxx . . $ std/::stringcxx . . $ std/string# const &ControlModecxx . . $ ControlMode#::modecxx . . $ ControlMode#mode(f4fff0029955a25f).() const
98 {
99 return mode_cxx . . $ ControlMode#mode_.;
100 }
101
102 void ControlModecxx . . $ ControlMode#::modecxx . . $ ControlMode#mode(9c546c94e5fcce4e).(stdcxx . . $ std/::stringcxx . . $ std/string# const &mode)
103 {
104 auto iter = stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).(
105 controls_cxx . . $ ControlMode#controls_..cbegincxx . . $ std/vector#cbegin(d1e1699016b9d7e6).(), controls_cxx . . $ ControlMode#controls_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).(),
106 [&](auto const &control) { return mode == control->ID(); });
107 if (iter != controls_cxx . . $ ControlMode#controls_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).())
108 mode_cxx . . $ ControlMode#mode_. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). mode;
109 }