| 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 "required-to-satisfy.h"cxx . . $ `<file>/src/internal/required-to-satisfy.h`/ |
| 22 | |
| 23 | #include "dependencies.h"cxx . . $ `<file>/src/internal/dependencies.h`/ |
| 24 | #include "implemented-by.h"cxx . . $ `<file>/src/internal/implemented-by.h`/ |
| 25 | #include "interfaces-utils.h"cxx . . $ `<file>/src/internal/interfaces-utils.h`/ |
| 26 | |
| 27 | #include <cassert> |
| 28 | #include <set> |
| 29 | |
| 30 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 31 | |
| 32 | typescxx . . $ injeqt/internal/types# required_to_satisfycxx . . $ injeqt/internal/required_to_satisfy(4c5f2d4bccbaabd5).(const dependenciescxx . . $ injeqt/internal/dependencies# &dependencies_to_satisfy, const types_modelcxx . . $ injeqt/internal/types_model# &model, const implementationscxx . . $ injeqt/internal/implementations# &objects) |
| 33 | { |
| 34 | assertcxx . . $ `/usr/include/assert.h:102:11`!(model.get_unresolvable_dependencies().empty()); |
| 35 | |
| 36 | auto result = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}; |
| 37 | auto ready = stdcxx . . $ std/set#set(f3bfeaebad815056).::setcxx . . $ std/set#<typecxx . . $ injeqt/v1/type#>{}; |
| 38 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(stdcxx . . $ std/::begincxx . . $ std/begin(a139f8bc8514c5ac).(objects), stdcxx . . $ std/::endcxx . . $ std/end(c459d8867450f8b2).(objects), stdcxx . . $ std/::insertercxx . . $ std/inserter(cc902069f641a146).(ready, stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(ready)), |
| 39 | [](const implementationcxx . . $ injeqt/internal/implementation# &i){ return i.interface_typecxx . . $ injeqt/internal/implementation#interface_type(7e9f7f4e42b3414e).(); }); |
| 40 | |
| 41 | auto interfaces_to_check = stdcxx . . $ std/vector#vector(b1ea180184b47f03).::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#>{}; |
| 42 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(stdcxx . . $ std/::begincxx . . $ std/begin(a139f8bc8514c5ac).(dependencies_to_satisfy), stdcxx . . $ std/::endcxx . . $ std/end(c459d8867450f8b2).(dependencies_to_satisfy), stdcxx . . $ std/::back_insertercxx . . $ std/back_inserter(7b559d6bdd90ff74).(interfaces_to_check), |
| 43 | [](const dependencycxx . . $ injeqt/internal/dependency# &d){ return d.required_typecxx . . $ injeqt/internal/dependency#required_type(7e9f7f4e42b3414e).(); }); |
| 44 | |
| 45 | while (!interfaces_to_check.emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).()) |
| 46 | { |
| 47 | auto current_interface_type = interfaces_to_check.backcxx . . $ std/vector#back(feee51535944b307).(); |
| 48 | interfaces_to_check.pop_backcxx . . $ std/vector#pop_back(49f6e7a06ebc5aa8).(); |
| 49 | |
| 50 | auto current_implementation_type_it = model.available_typescxx . . $ injeqt/internal/types_model#available_types(f204e9055a5335f3).().getcxx . . $ injeqt/internal/sorted_unique_vector#get(f1b725e3c61eba).(current_interface_type); |
| 51 | if (current_implementation_type_it ==cxx . . $ __gnu_cxx/`operator==`(d99b0194e00bfb5f). stdcxx . . $ std/::endcxx . . $ std/end(c459d8867450f8b2).(model.available_typescxx . . $ injeqt/internal/types_model#available_types(f204e9055a5335f3).())) |
| 52 | continue; |
| 53 | |
| 54 | auto current_implementation_type = current_implementation_type_it->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).implementation_typecxx . . $ injeqt/internal/implemented_by#implementation_type(358fec32f253752a).(); |
| 55 | if (ready.findcxx . . $ std/set#find(f8922f46a681e6cc).(current_implementation_type) !=cxx . . $ std/`operator!=`(7e1308a0738ea758). stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(ready)) |
| 56 | continue; |
| 57 | ready.insertcxx . . $ std/set#insert(411a10a755068dfe).(current_implementation_type); |
| 58 | result.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(current_implementation_type); |
| 59 | |
| 60 | if (model.mapped_dependenciescxx . . $ injeqt/internal/types_model#mapped_dependencies(6995930a3bd7d232).().contains_keycxx . . $ injeqt/internal/sorted_unique_vector#contains_key(8877ebe272b9620d).(current_implementation_type)) |
| 61 | { |
| 62 | auto dependencies = model.mapped_dependenciescxx . . $ injeqt/internal/types_model#mapped_dependencies(6995930a3bd7d232).().getcxx . . $ injeqt/internal/sorted_unique_vector#get(f1b725e3c61eba).(current_implementation_type)->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(a68f0626e749d9f6).dependency_listcxx . . $ injeqt/internal/type_dependencies#dependency_list(2a77aa8e1f54b3e2).(); |
| 63 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(stdcxx . . $ std/::begincxx . . $ std/begin(8c94f1ffb8cd32fc).(dependencies), stdcxx . . $ std/::endcxx . . $ std/end(898c3e9f99adb426).(dependencies), stdcxx . . $ std/::back_insertercxx . . $ std/back_inserter(7b559d6bdd90ff74).(interfaces_to_check), |
| 64 | [](const dependencycxx . . $ injeqt/internal/dependency# &d){ return d.required_typecxx . . $ injeqt/internal/dependency#required_type(7e9f7f4e42b3414e).(); }); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | return typescxx . . $ injeqt/internal/sorted_unique_vector#sorted_unique_vector(26e8deb829554aa).{resultcxx . . $ std/vector#vector(a1201200cf0efa42).}; |
| 69 | } |
| 70 | |
| 71 | }} |