| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/components/controls/controlgroupprofilepart.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "controlgroupprofilepart.h"cxx . . $ `<file>/src/core/components/controls/controlgroupprofilepart.h`/ |
| 5 | |
| 6 | #include <algorithm> |
| 7 | #include <iterator> |
| 8 | #include <unordered_map> |
| 9 | #include <utility> |
| 10 | |
| 11 | class ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Factorycxx . . $ ControlGroupProfilePart#Factory# final |
| 12 | : public ProfilePartcxx . . $ ProfilePart#::Factorycxx . . $ ProfilePart#Factory# |
| 13 | , public ControlGroupcxx . . $ ControlGroup#::Exportercxx . . $ IControl#Exporter# |
| 14 | { |
| 15 | public: |
| 16 | Factorycxx . . $ ControlGroupProfilePart#Factory#Factory(2978d0f4ae175682).(IProfilePartProvidercxx . . $ IProfilePartProvider# const &profilePartProvider, |
| 17 | ControlGroupProfilePartcxx . . $ ControlGroupProfilePart# &profilePart) noexcept |
| 18 | : ProfilePartcxx . . $ ProfilePart#::Factorycxx . . $ ProfilePart#Factory#(profilePartProvider) |
| 19 | , outer_cxx . . $ ControlGroupProfilePart#Factory#outer_.(profilePart) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | void takeProfilePartcxx . . $ ControlGroupProfilePart#Factory#takeProfilePart(8c7717026cb6ec4).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IProfilePartcxx . . $ IProfilePart#> &&part) override; |
| 24 | |
| 25 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 26 | provideExportercxx . . $ ControlGroupProfilePart#Factory#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) override; |
| 27 | |
| 28 | void takeActivecxx . . $ ControlGroupProfilePart#Factory#takeActive(b45ddcbc8423892c).(bool) override |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | private: |
| 33 | ControlGroupProfilePartcxx . . $ ControlGroupProfilePart# &outer_cxx . . $ ControlGroupProfilePart#Factory#outer_.; |
| 34 | }; |
| 35 | |
| 36 | void ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Factorycxx . . $ ControlGroupProfilePart#Factory#::takeProfilePartcxx . . $ ControlGroupProfilePart#Factory#takeProfilePart(8c7717026cb6ec4).( |
| 37 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IProfilePartcxx . . $ IProfilePart#> &&part) |
| 38 | { |
| 39 | outer_cxx . . $ ControlGroupProfilePart#Factory#outer_..parts_cxx . . $ ControlGroupProfilePart#parts_..emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(part)); |
| 40 | } |
| 41 | |
| 42 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 43 | ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Factorycxx . . $ ControlGroupProfilePart#Factory#::provideExportercxx . . $ ControlGroupProfilePart#Factory#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) |
| 44 | { |
| 45 | return factorycxx . . $ ProfilePart#Factory#factory(f4c9227945a043b8).(i.IDcxx . . $ Item#ID(f4fff0029955a25f).()); |
| 46 | } |
| 47 | |
| 48 | class ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Initializercxx . . $ ControlGroupProfilePart#Initializer# final : public ControlGroupcxx . . $ ControlGroup#::Exportercxx . . $ IControl#Exporter# |
| 49 | { |
| 50 | public: |
| 51 | Initializercxx . . $ ControlGroupProfilePart#Initializer#Initializer(a40d7dd6899a27b8).(ControlGroupProfilePartcxx . . $ ControlGroupProfilePart# &profilePart) noexcept |
| 52 | : outer_cxx . . $ ControlGroupProfilePart#Initializer#outer_.(profilePart) |
| 53 | { |
| 54 | } |
| 55 | |
| 56 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 57 | provideExportercxx . . $ ControlGroupProfilePart#Initializer#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) override; |
| 58 | |
| 59 | void takeActivecxx . . $ ControlGroupProfilePart#Initializer#takeActive(b45ddcbc8423892c).(bool active) override; |
| 60 | |
| 61 | private: |
| 62 | ControlGroupProfilePartcxx . . $ ControlGroupProfilePart# &outer_cxx . . $ ControlGroupProfilePart#Initializer#outer_.; |
| 63 | stdcxx . . $ std/::unordered_mapcxx . . $ std/unordered_map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> initializers_cxx . . $ ControlGroupProfilePart#Initializer#initializers_.; |
| 64 | }; |
| 65 | |
| 66 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#>> |
| 67 | ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Initializercxx . . $ ControlGroupProfilePart#Initializer#::provideExportercxx . . $ ControlGroupProfilePart#Initializer#provideExporter(3acccbde2694e33a).(Itemcxx . . $ Item# const &i) |
| 68 | { |
| 69 | for (auto &part : outer_cxx . . $ ControlGroupProfilePart#Initializer#outer_..parts_cxx . . $ ControlGroupProfilePart#parts_.) { |
| 70 | |
| 71 | if (part->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IDcxx . . $ Item#ID(f4fff0029955a25f).() ==cxx . . $ std/`operator==`(5ea818b58063a774). i.IDcxx . . $ Item#ID(f4fff0029955a25f).() && |
| 72 | (part->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).() ==cxx . . $ std/`operator==`(5ea818b58063a774). i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).() || part->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).().emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).())) { |
| 73 | |
| 74 | // Each item instance must have its own initializer |
| 75 | auto const id = i.IDcxx . . $ Item#ID(f4fff0029955a25f).() != i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).() ? i.IDcxx . . $ Item#ID(f4fff0029955a25f).() +cxx . . $ std/operator+(2764d1739bf7913d). i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).() |
| 76 | : icxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)..IDcxx . . $ Item#ID(f4fff0029955a25f).(); |
| 77 | if (initializers_cxx . . $ ControlGroupProfilePart#Initializer#initializers_..countcxx . . $ std/unordered_map#count(b71ff106d381144b).(id) > 0) |
| 78 | return *cxx . . $ std/optional#optional(e3f0d6382bd52f24).initializers_cxx . . $ ControlGroupProfilePart#Initializer#initializers_..atcxx . . $ std/unordered_map#at(4f10b6009f0ee734).(id); |
| 79 | else { |
| 80 | auto initializer = part->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initializercxx . . $ IProfilePart#initializer(6b4e1016740e578).(); |
| 81 | if (initializer != nullptr) { |
| 82 | initializers_cxx . . $ ControlGroupProfilePart#Initializer#initializers_..emplacecxx . . $ std/unordered_map#emplace(8e800962ae7274b6).(id, stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(initializer)); |
| 83 | return *cxx . . $ std/optional#optional(e3f0d6382bd52f24).initializers_cxx . . $ ControlGroupProfilePart#Initializer#initializers_..atcxx . . $ std/unordered_map#at(4f10b6009f0ee734).(id); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | break; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | return {cxx . . $ std/optional#optional(ced63f7c635d850d).}; |
| 92 | } |
| 93 | |
| 94 | void ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Initializercxx . . $ ControlGroupProfilePart#Initializer#::takeActivecxx . . $ ControlGroupProfilePart#Initializer#takeActive(b45ddcbc8423892c).(bool active) |
| 95 | { |
| 96 | outer_cxx . . $ ControlGroupProfilePart#Initializer#outer_..activatecxx . . $ ProfilePart#activate(b45ddcbc8423892c).(active); |
| 97 | } |
| 98 | |
| 99 | ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#ControlGroupProfilePart(c6e332c41c54746f).(stdcxx . . $ std/::string_viewcxx . . $ std/string_view# id) noexcept |
| 100 | : id_cxx . . $ ControlGroupProfilePart#id_.(id) |
| 101 | { |
| 102 | } |
| 103 | |
| 104 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#> |
| 105 | ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::factorycxx . . $ ControlGroupProfilePart#factory(af48dc8d4887b70c).(IProfilePartProvidercxx . . $ IProfilePartProvider# const &profilePartProvider) |
| 106 | { |
| 107 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Factorycxx . . $ ControlGroupProfilePart#Factory#>(profilePartProvider, |
| 108 | *this); |
| 109 | } |
| 110 | |
| 111 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter#> ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::initializercxx . . $ ControlGroupProfilePart#initializer(6b4e1016740e578).() |
| 112 | { |
| 113 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::Initializercxx . . $ ControlGroupProfilePart#Initializer#>(*this); |
| 114 | } |
| 115 | |
| 116 | stdcxx . . $ std/::stringcxx . . $ std/string# const &ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::IDcxx . . $ ControlGroupProfilePart#ID(f4fff0029955a25f).() const |
| 117 | { |
| 118 | return id_cxx . . $ ControlGroupProfilePart#id_.; |
| 119 | } |
| 120 | |
| 121 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::reference_wrappercxx . . $ std/reference_wrapper#<Importablecxx . . $ Importable#::Importercxx . . $ Importable#Importer#>> |
| 122 | ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::provideImportercxx . . $ ControlGroupProfilePart#provideImporter(c13a3bcac0db4745).(Itemcxx . . $ Item# const &i) |
| 123 | { |
| 124 | auto partIter = stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).( |
| 125 | parts_cxx . . $ ControlGroupProfilePart#parts_..cbegincxx . . $ std/vector#cbegin(d1e1699016b9d7e6).(), parts_cxx . . $ ControlGroupProfilePart#parts_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).(), [&](auto const &part) { |
| 126 | return part->ID() == i.IDcxx . . $ Item#ID(f4fff0029955a25f).() && part->instanceID() == i.instanceIDcxx . . $ Item#instanceID(f4fff0029955a25f).(); |
| 127 | }); |
| 128 | |
| 129 | if (partIter != parts_cxx . . $ ControlGroupProfilePart#parts_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).()) { |
| 130 | auto importer = dynamic_cast<Importablecxx . . $ Importable#::Importercxx . . $ Importable#Importer# *>(partIter->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()); |
| 131 | if (importer != nullptr) |
| 132 | return *cxx . . $ std/optional#optional(e3f0d6382bd52f24).importer; |
| 133 | } |
| 134 | |
| 135 | return {cxx . . $ std/optional#optional(ced63f7c635d850d).}; |
| 136 | } |
| 137 | |
| 138 | bool ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::provideActivecxx . . $ ControlGroupProfilePart#provideActive(50ce9a9e25b4a850).() const |
| 139 | { |
| 140 | return activecxx . . $ ProfilePart#active(50ce9a9e25b4a850).(); |
| 141 | } |
| 142 | |
| 143 | void ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::importProfilePartcxx . . $ ControlGroupProfilePart#importProfilePart(d62b6a6dfe9fe695).(IProfilePartcxx . . $ IProfilePart#::Importercxx . . $ IProfilePart#Importer# &i) |
| 144 | { |
| 145 | for (auto &part : parts_cxx . . $ ControlGroupProfilePart#parts_.) { |
| 146 | part->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).importWithcxx . . $ Importable#importWith(94eddebf9440278).(i); |
| 147 | |
| 148 | // ensure that all parts are active |
| 149 | part->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).activatecxx . . $ IProfilePart#activate(b45ddcbc8423892c).(true); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | void ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::exportProfilePartcxx . . $ ControlGroupProfilePart#exportProfilePart(702e13e8794d0da4).(IProfilePartcxx . . $ IProfilePart#::Exportercxx . . $ IProfilePart#Exporter# &e) const |
| 154 | { |
| 155 | for (auto const &part : parts_cxx . . $ ControlGroupProfilePart#parts_.) |
| 156 | part->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).exportWithcxx . . $ Exportable#exportWith(5b5c94ff60635419).(e); |
| 157 | } |
| 158 | |
| 159 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IProfilePartcxx . . $ IProfilePart#> ControlGroupProfilePartcxx . . $ ControlGroupProfilePart#::cloneProfilePartcxx . . $ ControlGroupProfilePart#cloneProfilePart(1378fcc1caef3e7b).() const |
| 160 | { |
| 161 | auto clone = instancecxx . . $ ControlGroupProfilePart#instance(f98cf899a05f254d).(); |
| 162 | clone->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).parts_cxx . . $ ControlGroupProfilePart#parts_..reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(parts_cxx . . $ ControlGroupProfilePart#parts_..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()); |
| 163 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).( |
| 164 | parts_cxx . . $ ControlGroupProfilePart#parts_..cbegincxx . . $ std/vector#cbegin(d1e1699016b9d7e6).(), parts_cxx . . $ ControlGroupProfilePart#parts_..cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).(), stdcxx . . $ std/::back_insertercxx . . $ std/back_inserter(7b559d6bdd90ff74).(clone->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).parts_cxx . . $ ControlGroupProfilePart#parts_.), |
| 165 | [](stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IProfilePartcxx . . $ IProfilePart#> const &part) { return part->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).clonecxx . . $ IProfilePart#clone(1378fcc1caef3e7b).(); }); |
| 166 | |
| 167 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::movecxx . . $ std/move(e35c19a1ba7baa26).(clone); |
| 168 | } |