| 1 | /* |
| 2 | * %injeqt copyright begin% |
| 3 | * Copyright 2014 Rafał Malinowski ([email protected]) |
| 4 | * %injeqt copyright end% |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include "injector-core.h"cxx . . $ `<file>/src/internal/injector-core.h`/ |
| 22 | |
| 23 | #include <injeqt/exception/ambiguous-types.h>cxx . . $ `<file>/include/injeqt/exception/ambiguous-types.h`/ |
| 24 | #include <injeqt/exception/unavailable-required-types.h>cxx . . $ `<file>/include/injeqt/exception/unavailable-required-types.h`/ |
| 25 | #include <injeqt/exception/unknown-type.h>cxx . . $ `<file>/include/injeqt/exception/unknown-type.h`/ |
| 26 | #include <injeqt/module.h>cxx . . $ `<file>/include/injeqt/module.h`/ |
| 27 | |
| 28 | #include "action-method.h"cxx . . $ `<file>/src/internal/action-method.h`/ |
| 29 | #include "containers.h"cxx . . $ `<file>/src/internal/containers.h`/ |
| 30 | #include "interfaces-utils.h"cxx . . $ `<file>/src/internal/interfaces-utils.h`/ |
| 31 | #include "provided-object.h"cxx . . $ `<file>/src/internal/provided-object.h`/ |
| 32 | #include "provider-by-default-constructor.h"cxx . . $ `<file>/src/internal/provider-by-default-constructor.h`/ |
| 33 | #include "provider-ready.h"cxx . . $ `<file>/src/internal/provider-ready.h`/ |
| 34 | #include "provider.h"cxx . . $ `<file>/src/internal/provider.h`/ |
| 35 | #include "module-impl.h"cxx . . $ `<file>/src/internal/module-impl.h`/ |
| 36 | #include "required-to-satisfy.h"cxx . . $ `<file>/src/internal/required-to-satisfy.h`/ |
| 37 | #include "resolve-dependencies.h"cxx . . $ `<file>/src/internal/resolve-dependencies.h`/ |
| 38 | #include "resolved-dependency.h"cxx . . $ `<file>/src/internal/resolved-dependency.h`/ |
| 39 | #include "type-role.h"cxx . . $ `<file>/src/internal/type-role.h`/ |
| 40 | |
| 41 | #include <cassert> |
| 42 | |
| 43 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 44 | |
| 45 | injector_corecxx . . $ injeqt/internal/injector_core#::injector_corecxx . . $ injeqt/internal/injector_core#injector_core(49f6e7a06ebc5aa8).() |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | injector_corecxx . . $ injeqt/internal/injector_core#::injector_corecxx . . $ injeqt/internal/injector_core#injector_core(a8e0597472603795).(types_by_namecxx . . $ injeqt/internal/types_by_name# known_types, stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<providercxx . . $ injeqt/internal/provider#>> &&all_providers) : |
| 50 | _known_typescxx . . $ injeqt/internal/injector_core#_known_types.{stdcxx . . $ std/::movecxx . . $ std/move(e7c6c0c8363dcc46).(known_types)} |
| 51 | { |
| 52 | auto all_providers_size = all_providers.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); |
| 53 | _available_providerscxx . . $ injeqt/internal/injector_core#_available_providers. =cxx . . $ injeqt/internal/sorted_unique_vector#`operator=`(a105b8b5b74f4351). providerscxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{stdcxx . . $ std/vector#vector(b1ea180184b47f03).::movecxx . . $ std/move(e7c6c0c8363dcc46).(all_providers)}; |
| 54 | |
| 55 | // some types were removed, because of duplication |
| 56 | if (_available_providerscxx . . $ injeqt/internal/injector_core#_available_providers..sizecxx . . $ injeqt/internal/sorted_unique_vector#size(89f858102beaadab).() != all_providers_size) |
| 57 | throw exceptioncxx . . $ injeqt/v1/exception/ambiguous_types#ambiguous_types(8d4ab0a187bf9331).::ambiguous_typescxx . . $ injeqt/v1/exception/ambiguous_types#{}; // TODO: find a way to extract type names |
| 58 | |
| 59 | _types_modelcxx . . $ injeqt/internal/injector_core#_types_model. =cxx . . $ injeqt/internal/types_model#`operator=`(7aba9e11eb0d6d12). create_types_modelcxx . . $ injeqt/internal/injector_core#create_types_model(5250c6e58d6688a7).(); |
| 60 | |
| 61 | auto required_types = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}; |
| 62 | for (auto &&p : _available_providerscxx . . $ injeqt/internal/injector_core#_available_providers.) |
| 63 | for (auto &&r : p->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).required_typescxx . . $ injeqt/internal/provider#required_types(6f3e1a4b3e1e60c4).()) |
| 64 | required_types.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(r); |
| 65 | |
| 66 | auto unavailable_required_types = matchcxx . . $ injeqt/internal/match(f64fa725a7b4ed06).(typescxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{required_typescxx . . $ std/vector#vector(a1201200cf0efa42).}, _types_modelcxx . . $ injeqt/internal/injector_core#_types_model..available_typescxx . . $ injeqt/internal/types_model#available_types(f204e9055a5335f3).()).unmatched_1cxx . . $ injeqt/internal/match_result#unmatched_1.; |
| 67 | if (!unavailable_required_types.emptycxx . . $ injeqt/internal/sorted_unique_vector#empty(50ce9a9e25b4a850).()) |
| 68 | { |
| 69 | auto message = stdcxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).::stringcxx . . $ std/string#{}; |
| 70 | for (auto &&t : unavailable_required_types) |
| 71 | { |
| 72 | message.appendcxx . . $ std/__cxx11/basic_string#append(c0b47be1fddc0e75).(t.namecxx . . $ injeqt/v1/type#name(219584694fe2b248).()); |
| 73 | message.appendcxx . . $ std/__cxx11/basic_string#append(978ca1133b5f6e74).("\n"); |
| 74 | } |
| 75 | throw exceptioncxx . . $ injeqt/v1/exception/unavailable_required_types#unavailable_required_types(8d4ab0a187bf9331).::unavailable_required_typescxx . . $ injeqt/v1/exception/unavailable_required_types#{messagecxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).}; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | injector_corecxx . . $ injeqt/internal/injector_core#::~cxx . . $ injeqt/internal/injector_core#`~injector_core`(49f6e7a06ebc5aa8).injector_corecxx . . $ injeqt/internal/injector_core#() |
| 80 | { |
| 81 | for (auto &&resolved_object : _resolved_objectscxx . . $ injeqt/internal/injector_core#_resolved_objects.) |
| 82 | call_done_methodscxx . . $ injeqt/internal/injector_core#call_done_methods(5facab8496d0a3e3).(resolved_object.objectcxx . . $ injeqt/internal/implementation#object(2dbb680a34285c44).()); |
| 83 | } |
| 84 | |
| 85 | types_modelcxx . . $ injeqt/internal/types_model# injector_corecxx . . $ injeqt/internal/injector_core#::create_types_modelcxx . . $ injeqt/internal/injector_core#create_types_model(5250c6e58d6688a7).() const |
| 86 | { |
| 87 | auto all_types = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}; |
| 88 | auto need_dependencies = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}; |
| 89 | for (auto &&p : _available_providerscxx . . $ injeqt/internal/injector_core#_available_providers.) |
| 90 | { |
| 91 | all_types.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(p->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).provided_typecxx . . $ injeqt/internal/provider#provided_type(7e9f7f4e42b3414e).()); |
| 92 | if (p->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).require_resolvingcxx . . $ injeqt/internal/provider#require_resolving(50ce9a9e25b4a850).()) |
| 93 | { |
| 94 | auto interfaces = extract_interfacescxx . . $ injeqt/internal/extract_interfaces(859a62e7a8dc5225).(p->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).provided_typecxx . . $ injeqt/internal/provider#provided_type(7e9f7f4e42b3414e).()); |
| 95 | stdcxx . . $ std/::copycxx . . $ std/copy(88304b602929f6f4).(stdcxx . . $ std/::begincxx . . $ std/begin(8c94f1ffb8cd32fc).(interfaces), stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(interfaces), stdcxx . . $ std/::back_insertercxx . . $ std/back_inserter(7b559d6bdd90ff74).(need_dependencies)); |
| 96 | } |
| 97 | } |
| 98 | return make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(_known_typescxx . . $ injeqt/internal/injector_core#_known_types., all_types, need_dependencies); |
| 99 | } |
| 100 | |
| 101 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#> injector_corecxx . . $ injeqt/internal/injector_core#::provided_typescxx . . $ injeqt/internal/injector_core#provided_types(cf3a392ed5d6b92b).() const |
| 102 | { |
| 103 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}; |
| 104 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(stdcxx . . $ std/::begincxx . . $ std/begin(a139f8bc8514c5ac).(_available_providerscxx . . $ injeqt/internal/injector_core#_available_providers.), stdcxx . . $ std/::endcxx . . $ std/end(c459d8867450f8b2).(_available_providerscxx . . $ injeqt/internal/injector_core#_available_providers.), stdcxx . . $ std/::back_insertercxx . . $ std/back_inserter(7b559d6bdd90ff74).(result), type_from_providercxx . . $ injeqt/internal/type_from_provider(ac0d57febace0029).); |
| 105 | return resultcxx . . $ std/vector#vector(b1ea180184b47f03).; |
| 106 | } |
| 107 | |
| 108 | void injector_corecxx . . $ injeqt/internal/injector_core#::instantiatecxx . . $ injeqt/internal/injector_core#instantiate(ebaf86d70144d0a8).(const typecxx . . $ injeqt/v1/type# &interface_type) |
| 109 | { |
| 110 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface_type.is_empty()); |
| 111 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface_type.is_qobject()); |
| 112 | |
| 113 | auto object_it = _objectscxx . . $ injeqt/internal/injector_core#_objects..getcxx . . $ injeqt/internal/sorted_unique_vector#get(f1b725e3c61eba).(interface_type); |
| 114 | if (object_it ==cxx . . $ __gnu_cxx/`operator==`(d99b0194e00bfb5f). endcxx . . $ injeqt/internal/end(9638168a7e9b19c2).(_objectscxx . . $ injeqt/internal/injector_core#_objects.)) |
| 115 | instantiate_interfacecxx . . $ injeqt/internal/injector_core#instantiate_interface(ebaf86d70144d0a8).(interface_type); |
| 116 | } |
| 117 | |
| 118 | void injector_corecxx . . $ injeqt/internal/injector_core#::instantiate_all_with_type_rolecxx . . $ injeqt/internal/injector_core#instantiate_all_with_type_role(9c546c94e5fcce4e).(const stdcxx . . $ std/::stringcxx . . $ std/string# &type_role) |
| 119 | { |
| 120 | for (auto &&provider : _available_providerscxx . . $ injeqt/internal/injector_core#_available_providers.) |
| 121 | { |
| 122 | auto type = provider->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).provided_typecxx . . $ injeqt/internal/provider#provided_type(7e9f7f4e42b3414e).(); |
| 123 | if (has_type_rolecxx . . $ injeqt/internal/has_type_role(d3daa6f621ef2328).(type, type_role)) |
| 124 | instantiate_interfacecxx . . $ injeqt/internal/injector_core#instantiate_interface(ebaf86d70144d0a8).(type); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | QObjectcxx . . $ QObject# * injector_corecxx . . $ injeqt/internal/injector_core#::getcxx . . $ injeqt/internal/injector_core#get(e1ed43d1af855660).(const typecxx . . $ injeqt/v1/type# &interface_type) |
| 129 | { |
| 130 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface_type.is_empty()); |
| 131 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface_type.is_qobject()); |
| 132 | |
| 133 | instantiatecxx . . $ injeqt/internal/injector_core#instantiate(ebaf86d70144d0a8).(interface_type); |
| 134 | return _objectscxx . . $ injeqt/internal/injector_core#_objects..getcxx . . $ injeqt/internal/sorted_unique_vector#get(f1b725e3c61eba).(interface_type)->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).objectcxx . . $ injeqt/internal/implementation#object(2dbb680a34285c44).(); |
| 135 | } |
| 136 | |
| 137 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<QObjectcxx . . $ QObject# *> injector_corecxx . . $ injeqt/internal/injector_core#::get_all_with_type_rolecxx . . $ injeqt/internal/injector_core#get_all_with_type_role(60702980c580d8f6).(const stdcxx . . $ std/::stringcxx . . $ std/string# &type_role) |
| 138 | { |
| 139 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<QObjectcxx . . $ QObject# *>{}; |
| 140 | for (auto &&provider : _available_providerscxx . . $ injeqt/internal/injector_core#_available_providers.) |
| 141 | { |
| 142 | auto type = provider->cxx . . $ std/unique_ptr#`operator->`(ca399b2b6292c808).provided_typecxx . . $ injeqt/internal/provider#provided_type(7e9f7f4e42b3414e).(); |
| 143 | if (has_type_rolecxx . . $ injeqt/internal/has_type_role(d3daa6f621ef2328).(type, type_role)) |
| 144 | result.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(getcxx . . $ injeqt/internal/injector_core#get(e1ed43d1af855660).(type)); |
| 145 | } |
| 146 | |
| 147 | return resultcxx . . $ std/vector#vector(b1ea180184b47f03).; |
| 148 | } |
| 149 | |
| 150 | void injector_corecxx . . $ injeqt/internal/injector_core#::instantiate_interfacecxx . . $ injeqt/internal/injector_core#instantiate_interface(ebaf86d70144d0a8).(const typecxx . . $ injeqt/v1/type# &interface_type) |
| 151 | { |
| 152 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface_type.is_empty()); |
| 153 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface_type.is_qobject()); |
| 154 | |
| 155 | instantiate_implementationcxx . . $ injeqt/internal/injector_core#instantiate_implementation(ebaf86d70144d0a8).(implementation_forcxx . . $ injeqt/internal/injector_core#implementation_for(6d6526d4c0efaff3).(interface_type)); |
| 156 | } |
| 157 | |
| 158 | typecxx . . $ injeqt/v1/type# injector_corecxx . . $ injeqt/internal/injector_core#::implementation_forcxx . . $ injeqt/internal/injector_core#implementation_for(6d6526d4c0efaff3).(const typecxx . . $ injeqt/v1/type# &interface_type) const |
| 159 | { |
| 160 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface_type.is_empty()); |
| 161 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!interface_type.is_qobject()); |
| 162 | |
| 163 | auto implementation_type_it = _types_modelcxx . . $ injeqt/internal/injector_core#_types_model..available_typescxx . . $ injeqt/internal/types_model#available_types(f204e9055a5335f3).().getcxx . . $ injeqt/internal/sorted_unique_vector#get(f1b725e3c61eba).(interface_type); |
| 164 | if (implementation_type_it ==cxx . . $ __gnu_cxx/`operator==`(d99b0194e00bfb5f). endcxx . . $ injeqt/internal/end(9638168a7e9b19c2).(_types_modelcxx . . $ injeqt/internal/injector_core#_types_model..available_typescxx . . $ injeqt/internal/types_model#available_types(f204e9055a5335f3).())) |
| 165 | throw exceptioncxx . . $ injeqt/v1/exception/unknown_type#unknown_type(8d4ab0a187bf9331).::unknown_typecxx . . $ injeqt/v1/exception/unknown_type#{interface_typecxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f)..namecxx . . $ injeqt/v1/type#name(219584694fe2b248).()}; |
| 166 | return implementation_type_it->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).implementation_typecxx . . $ injeqt/internal/implemented_by#implementation_type(358fec32f253752a).(); |
| 167 | } |
| 168 | |
| 169 | void injector_corecxx . . $ injeqt/internal/injector_core#::instantiate_implementationcxx . . $ injeqt/internal/injector_core#instantiate_implementation(ebaf86d70144d0a8).(const typecxx . . $ injeqt/v1/type# &implementation_type) |
| 170 | { |
| 171 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!implementation_type.is_empty()); |
| 172 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!implementation_type.is_qobject()); |
| 173 | |
| 174 | auto types_to_instantiate = required_to_satisfycxx . . $ injeqt/internal/required_to_satisfy(4c5f2d4bccbaabd5).(implementation_type_dependenciescxx . . $ injeqt/internal/injector_core#implementation_type_dependencies(7e15a51b9934704e).(implementation_type), _types_modelcxx . . $ injeqt/internal/injector_core#_types_model., _objectscxx . . $ injeqt/internal/injector_core#_objects.); |
| 175 | types_to_instantiate.addcxx . . $ injeqt/internal/sorted_unique_vector#add(69eed69a60cddb2f).(implementation_type); |
| 176 | instantiate_allcxx . . $ injeqt/internal/injector_core#instantiate_all(3e77e1d0e0e5e776).(types_to_instantiate); |
| 177 | } |
| 178 | |
| 179 | dependenciescxx . . $ injeqt/internal/dependencies# injector_corecxx . . $ injeqt/internal/injector_core#::implementation_type_dependenciescxx . . $ injeqt/internal/injector_core#implementation_type_dependencies(7e15a51b9934704e).(const typecxx . . $ injeqt/v1/type# &implementation_type) const |
| 180 | { |
| 181 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!implementation_type.is_empty()); |
| 182 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!implementation_type.is_qobject()); |
| 183 | |
| 184 | return _types_modelcxx . . $ injeqt/internal/injector_core#_types_model..mapped_dependenciescxx . . $ injeqt/internal/types_model#mapped_dependencies(6995930a3bd7d232).().contains_keycxx . . $ injeqt/internal/sorted_unique_vector#contains_key(8877ebe272b9620d).(implementation_type) |
| 185 | ? _types_modelcxx . . $ injeqt/internal/injector_core#_types_model..mapped_dependenciescxx . . $ injeqt/internal/types_model#mapped_dependencies(6995930a3bd7d232).().getcxx . . $ injeqt/internal/sorted_unique_vector#get(f1b725e3c61eba).(implementation_type)->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).dependency_listcxx . . $ injeqt/internal/type_dependencies#dependency_list(2a77aa8e1f54b3e2).() |
| 186 | : dependenciescxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(49f6e7a06ebc5aa8).{}; |
| 187 | } |
| 188 | |
| 189 | void injector_corecxx . . $ injeqt/internal/injector_core#::instantiate_allcxx . . $ injeqt/internal/injector_core#instantiate_all(3e77e1d0e0e5e776).(const typescxx . . $ injeqt/internal/types# &interface_types) |
| 190 | { |
| 191 | instantiate_required_types_forcxx . . $ injeqt/internal/injector_core#instantiate_required_types_for(3e77e1d0e0e5e776).(interface_types); |
| 192 | |
| 193 | auto provided_objects = provide_objectscxx . . $ std/vector#vector(b1ea180184b47f03).(providers_forcxx . . $ injeqt/internal/injector_core#providers_for(61414923878c0a89).(non_instantiatedcxx . . $ injeqt/internal/injector_core#non_instantiated(d141fac86e8abaf0).(interface_types))); |
| 194 | _objectscxx . . $ injeqt/internal/injector_core#_objects..mergecxx . . $ injeqt/internal/sorted_unique_vector#merge(9e71efcb105452bc).(implementationscxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{objects_to_storecxx . . $ std/vector#vector(b1ea180184b47f03).(extract_implementationscxx . . $ injeqt/internal/injector_core#extract_implementations(77b7dc284b45368d).(provided_objects))}); |
| 195 | resolve_objectscxx . . $ injeqt/internal/injector_core#resolve_objects(f00003a32284dffb).(objects_to_resolvecxx . . $ injeqt/internal/injector_core#objects_to_resolve(77b7dc284b45368d).(provided_objects)); |
| 196 | } |
| 197 | |
| 198 | void injector_corecxx . . $ injeqt/internal/injector_core#::instantiate_required_types_forcxx . . $ injeqt/internal/injector_core#instantiate_required_types_for(3e77e1d0e0e5e776).(const typescxx . . $ injeqt/internal/types# &types_to_instantiate) |
| 199 | { |
| 200 | for (auto &&provider : providers_forcxx . . $ injeqt/internal/injector_core#providers_for(61414923878c0a89).(types_to_instantiate)) |
| 201 | for (auto &&required_type : provider->required_typescxx . . $ injeqt/internal/provider#required_types(6f3e1a4b3e1e60c4).()) |
| 202 | instantiate_interfacecxx . . $ injeqt/internal/injector_core#instantiate_interface(ebaf86d70144d0a8).(required_type); |
| 203 | } |
| 204 | |
| 205 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#> injector_corecxx . . $ injeqt/internal/injector_core#::non_instantiatedcxx . . $ injeqt/internal/injector_core#non_instantiated(d141fac86e8abaf0).(const typescxx . . $ injeqt/internal/types# &to_filter) const |
| 206 | { |
| 207 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}; |
| 208 | result.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(to_filter.sizecxx . . $ injeqt/internal/sorted_unique_vector#size(89f858102beaadab).()); |
| 209 | for (auto &&type : to_filter) |
| 210 | if (_objectscxx . . $ injeqt/internal/injector_core#_objects..getcxx . . $ injeqt/internal/sorted_unique_vector#get(f1b725e3c61eba).(type) ==cxx . . $ __gnu_cxx/`operator==`(d99b0194e00bfb5f). endcxx . . $ injeqt/internal/end(9638168a7e9b19c2).(_objectscxx . . $ injeqt/internal/injector_core#_objects.)) |
| 211 | result.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(type); |
| 212 | return resultcxx . . $ std/vector#vector(b1ea180184b47f03).; |
| 213 | } |
| 214 | |
| 215 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<provided_objectcxx . . $ injeqt/internal/provided_object#> injector_corecxx . . $ injeqt/internal/injector_core#::provide_objectscxx . . $ injeqt/internal/injector_core#provide_objects(393f2e4f0f16d2ec).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<providercxx . . $ injeqt/internal/provider# *> &providers) |
| 216 | { |
| 217 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<provided_objectcxx . . $ injeqt/internal/provided_object#>{}; |
| 218 | result.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(providers.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()); |
| 219 | for (auto &&provider : providers) |
| 220 | { |
| 221 | auto instance = provider->providecxx . . $ injeqt/internal/provider#provide(51123600412ca135).(*this); |
| 222 | auto i = make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(provider->provided_typecxx . . $ injeqt/internal/provider#provided_type(7e9f7f4e42b3414e).(), instance); |
| 223 | result.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(provided_objectcxx . . $ injeqt/internal/provided_object#provided_object(afb3d9edfad8322).{provider, i}); |
| 224 | } |
| 225 | return resultcxx . . $ std/vector#vector(b1ea180184b47f03).; |
| 226 | } |
| 227 | |
| 228 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<implementationcxx . . $ injeqt/internal/implementation#> injector_corecxx . . $ injeqt/internal/injector_core#::objects_to_resolvecxx . . $ injeqt/internal/injector_core#objects_to_resolve(77b7dc284b45368d).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<provided_objectcxx . . $ injeqt/internal/provided_object#> &provided_objects) const |
| 229 | { |
| 230 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<implementationcxx . . $ injeqt/internal/implementation#>{}; |
| 231 | result.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(provided_objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()); |
| 232 | for (auto &&provided_object : provided_objects) |
| 233 | if (provided_object.provided_bycxx . . $ injeqt/internal/provided_object#provided_by(17276d1c2193c8fe).()->require_resolvingcxx . . $ injeqt/internal/provider#require_resolving(50ce9a9e25b4a850).()) |
| 234 | result.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(provided_object.objectcxx . . $ injeqt/internal/provided_object#object(1cbef4e702e8ff4b).()); |
| 235 | return resultcxx . . $ std/vector#vector(b1ea180184b47f03).; |
| 236 | } |
| 237 | |
| 238 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<implementationcxx . . $ injeqt/internal/implementation#> injector_corecxx . . $ injeqt/internal/injector_core#::extract_implementationscxx . . $ injeqt/internal/injector_core#extract_implementations(77b7dc284b45368d).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<provided_objectcxx . . $ injeqt/internal/provided_object#> &provided_objects) const |
| 239 | { |
| 240 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<implementationcxx . . $ injeqt/internal/implementation#>{}; |
| 241 | result.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(provided_objects.sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()); |
| 242 | for (auto &&provided_object : provided_objects) |
| 243 | result.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(provided_object.objectcxx . . $ injeqt/internal/provided_object#object(1cbef4e702e8ff4b).()); |
| 244 | return resultcxx . . $ std/vector#vector(b1ea180184b47f03).; |
| 245 | } |
| 246 | |
| 247 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<implementationcxx . . $ injeqt/internal/implementation#> injector_corecxx . . $ injeqt/internal/injector_core#::objects_to_storecxx . . $ injeqt/internal/injector_core#objects_to_store(3f4d54e2b105ac4d).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<implementationcxx . . $ injeqt/internal/implementation#> &objects) const |
| 248 | { |
| 249 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<implementationcxx . . $ injeqt/internal/implementation#>{}; |
| 250 | for (auto &&object : objects) |
| 251 | { |
| 252 | auto interfaces = extract_interfacescxx . . $ injeqt/internal/extract_interfaces(859a62e7a8dc5225).(object.interface_typecxx . . $ injeqt/internal/implementation#interface_type(7e9f7f4e42b3414e).()); |
| 253 | auto matched = matchcxx . . $ std/vector#vector(b1ea180184b47f03).(interfaces, _types_modelcxx . . $ injeqt/internal/injector_core#_types_model..available_typescxx . . $ injeqt/internal/types_model#available_types(f204e9055a5335f3).()).matchedcxx . . $ injeqt/internal/match_result#matched.; |
| 254 | for (auto &&m : matched) |
| 255 | { |
| 256 | auto i = implementationcxx . . $ injeqt/internal/implementation#implementation(9ea1470f0de69db5).{m.firstcxx . . $ std/pair#first., object.objectcxx . . $ injeqt/internal/implementation#object(2dbb680a34285c44).()}; // no need to check preconditions again with make_implementation |
| 257 | result.emplace_backcxx . . $ std/vector#emplace_back(b3d147e3bb711c35).(i); |
| 258 | } |
| 259 | } |
| 260 | return resultcxx . . $ std/vector#vector(b1ea180184b47f03).; |
| 261 | } |
| 262 | |
| 263 | void injector_corecxx . . $ injeqt/internal/injector_core#::resolve_objectscxx . . $ injeqt/internal/injector_core#resolve_objects(f00003a32284dffb).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<implementationcxx . . $ injeqt/internal/implementation#> &objects) |
| 264 | { |
| 265 | for (auto &&object : objects) |
| 266 | resolve_objectcxx . . $ injeqt/internal/injector_core#resolve_object(2f2bf958926a1747).(object); |
| 267 | for (auto &&object : objects) |
| 268 | call_init_methodscxx . . $ injeqt/internal/injector_core#call_init_methods(5facab8496d0a3e3).(object.objectcxx . . $ injeqt/internal/implementation#object(2dbb680a34285c44).()); |
| 269 | _resolved_objectscxx . . $ injeqt/internal/injector_core#_resolved_objects..mergecxx . . $ injeqt/internal/sorted_unique_vector#merge(9e71efcb105452bc).(implementationscxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{objectscxx . . $ std/vector#vector(a1201200cf0efa42).}); |
| 270 | } |
| 271 | |
| 272 | void injector_corecxx . . $ injeqt/internal/injector_core#::resolve_objectcxx . . $ injeqt/internal/injector_core#resolve_object(2f2bf958926a1747).(const implementationcxx . . $ injeqt/internal/implementation# &object) const |
| 273 | { |
| 274 | auto object_dependencies = implementation_type_dependenciescxx . . $ injeqt/internal/injector_core#implementation_type_dependencies(7e15a51b9934704e).(object.interface_typecxx . . $ injeqt/internal/implementation#interface_type(7e9f7f4e42b3414e).()); |
| 275 | resolve_objectcxx . . $ injeqt/internal/injector_core#resolve_object(5db74c9facaddd12).(object_dependencies, object); |
| 276 | } |
| 277 | |
| 278 | void injector_corecxx . . $ injeqt/internal/injector_core#::resolve_objectcxx . . $ injeqt/internal/injector_core#resolve_object(5db74c9facaddd12).(const dependenciescxx . . $ injeqt/internal/dependencies# &object_dependencies, const implementationcxx . . $ injeqt/internal/implementation# &object) const |
| 279 | { |
| 280 | auto resolved_dependencies = resolve_dependenciescxx . . $ injeqt/internal/resolve_dependencies(2fc3aec96b5b3950).(object_dependencies, _objectscxx . . $ injeqt/internal/injector_core#_objects.); |
| 281 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(resolved_dependencies.unresolved.empty()); |
| 282 | |
| 283 | for (auto &&resolved : resolved_dependencies.resolvedcxx . . $ injeqt/internal/resolve_dependencies_result#resolved.) |
| 284 | { |
| 285 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(implements(object.interface_type(), resolved.setter().object_type())); |
| 286 | resolved.apply_oncxx . . $ injeqt/internal/resolved_dependency#apply_on(967f3292d4f23d29).(object.objectcxx . . $ injeqt/internal/implementation#object(2dbb680a34285c44).()); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | void injector_corecxx . . $ injeqt/internal/injector_core#::inject_intocxx . . $ injeqt/internal/injector_core#inject_into(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *object) |
| 291 | { |
| 292 | auto object_implementation = implementationcxx . . $ injeqt/internal/implementation#implementation(9ea1470f0de69db5).{typecxx . . $ injeqt/v1/type#type(f870fe3066718694).{object->metaObjectcxx . . $ QObject#metaObject(216d4151dd9c9333).()}, object}; |
| 293 | auto dependencies = extract_dependenciescxx . . $ injeqt/internal/extract_dependencies(c8c0e98cc48858ad).(_known_typescxx . . $ injeqt/internal/injector_core#_known_types., object_implementation.interface_typecxx . . $ injeqt/internal/implementation#interface_type(7e9f7f4e42b3414e).()); |
| 294 | auto types_to_instantiate = required_to_satisfycxx . . $ injeqt/internal/required_to_satisfy(4c5f2d4bccbaabd5).(dependencies, _types_modelcxx . . $ injeqt/internal/injector_core#_types_model., _objectscxx . . $ injeqt/internal/injector_core#_objects.); |
| 295 | instantiate_allcxx . . $ injeqt/internal/injector_core#instantiate_all(3e77e1d0e0e5e776).(types_to_instantiate); |
| 296 | resolve_objectcxx . . $ injeqt/internal/injector_core#resolve_object(5db74c9facaddd12).(dependencies, object_implementation); |
| 297 | call_init_methodscxx . . $ injeqt/internal/injector_core#call_init_methods(5facab8496d0a3e3).(object); |
| 298 | } |
| 299 | |
| 300 | void injector_corecxx . . $ injeqt/internal/injector_core#::call_init_methodscxx . . $ injeqt/internal/injector_core#call_init_methods(5facab8496d0a3e3).(QObjectcxx . . $ QObject# *object) const |
| 301 | { |
| 302 | for (auto action : extract_actionscxx . . $ injeqt/internal/extract_actions(e128403a847e2c67).("INJEQT_INIT"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., typecxx . . $ injeqt/v1/type#type(f870fe3066718694).{object->metaObjectcxx . . $ QObject#metaObject(216d4151dd9c9333).()})) |
| 303 | action.invokecxx . . $ injeqt/internal/action_method#invoke(a7755beb02b388f3).(object); |
| 304 | } |
| 305 | |
| 306 | void injector_corecxx . . $ injeqt/internal/injector_core#::call_done_methodscxx . . $ injeqt/internal/injector_core#call_done_methods(5facab8496d0a3e3).(QObjectcxx . . $ QObject# *object) const |
| 307 | { |
| 308 | auto done_actions = extract_actionscxx . . $ std/vector#vector(b1ea180184b47f03).("INJEQT_DONE"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., typecxx . . $ injeqt/v1/type#type(f870fe3066718694).{object->metaObjectcxx . . $ QObject#metaObject(216d4151dd9c9333).()}); |
| 309 | for (auto i = done_actionscxx . . $ std/reverse_iterator#reverse_iterator(e2d883c4bd185f58)..rbegincxx . . $ std/vector#rbegin(9dcc1de6a3b68785).(), e = done_actionscxx . . $ std/reverse_iterator#reverse_iterator(e2d883c4bd185f58)..rendcxx . . $ std/vector#rend(9dcc1de6a3b68785).(); i !=cxx . . $ std/`operator!=`(c2ad8cf295ccec45). e; ++cxx . . $ std/reverse_iterator#operator++(b4fad7494eaaab68).i) |
| 310 | i->cxx . . $ std/reverse_iterator#`operator->`(a68f0626e749d9f6).invokecxx . . $ injeqt/internal/action_method#invoke(a7755beb02b388f3).(object); |
| 311 | } |
| 312 | |
| 313 | }} |