| 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 | #pragma once |
| 22 | |
| 23 | #include <injeqt/injeqt.h>cxx . . $ `<file>/include/injeqt/injeqt.h`/ |
| 24 | #include <injeqt/type.h>cxx . . $ `<file>/include/injeqt/type.h`/ |
| 25 | |
| 26 | #include "dependencies.h"cxx . . $ `<file>/src/internal/dependencies.h`/ |
| 27 | #include "internal.h"cxx . . $ `<file>/src/internal/internal.h`/ |
| 28 | |
| 29 | #include <cassert> |
| 30 | |
| 31 | /** |
| 32 | * @file |
| 33 | * @brief Contains classes and functions for representing type and its dependencies. |
| 34 | */ |
| 35 | |
| 36 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 37 | |
| 38 | /** |
| 39 | * @brief Type and its dependencies. |
| 40 | * |
| 41 | * This class is used to represent type with connection of all its dependencies. Instances created |
| 42 | * with make_type_dependencies(type) function are guaranteed to be valid. |
| 43 | * |
| 44 | * Used in model class to store all dependnecies and in injector_core to resolve them. |
| 45 | */ |
| 46 | class INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:26:9`! type_dependenciescxx . . $ injeqt/internal/type_dependencies# final |
| 47 | { |
| 48 | |
| 49 | public: |
| 50 | /** |
| 51 | * @brief Create new instance of type_dependencies. |
| 52 | * @param dependent_type type that contains dependencies described with dependency_list |
| 53 | * @param dependency_list list of dependencies of dependent_type |
| 54 | */ |
| 55 | explicit type_dependenciescxx . . $ injeqt/internal/type_dependencies#type_dependencies(50791c604c871475).(typecxx . . $ injeqt/v1/type# dependent_type, dependenciescxx . . $ injeqt/internal/dependencies# dependency_list); |
| 56 | |
| 57 | /** |
| 58 | * @return type that contains dependencies described with dependency_list |
| 59 | */ |
| 60 | const typecxx . . $ injeqt/v1/type# & dependent_typecxx . . $ injeqt/internal/type_dependencies#dependent_type(7e9f7f4e42b3414e).() const; |
| 61 | |
| 62 | /** |
| 63 | * @return list of dependencies of dependent_type() |
| 64 | */ |
| 65 | const dependenciescxx . . $ injeqt/internal/dependencies# & dependency_listcxx . . $ injeqt/internal/type_dependencies#dependency_list(2a77aa8e1f54b3e2).() const; |
| 66 | |
| 67 | private: |
| 68 | typecxx . . $ injeqt/v1/type# _dependent_typecxx . . $ injeqt/internal/type_dependencies#_dependent_type.; |
| 69 | dependenciescxx . . $ injeqt/internal/dependencies# _dependency_listcxx . . $ injeqt/internal/type_dependencies#_dependency_list.; |
| 70 | |
| 71 | }; |
| 72 | |
| 73 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! bool operatorcxx . . $ injeqt/internal/`operator==`(9916366bbc6ddca2). == (const type_dependenciescxx . . $ injeqt/internal/type_dependencies# &x, const type_dependenciescxx . . $ injeqt/internal/type_dependencies# &y); |
| 74 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! bool operatorcxx . . $ injeqt/internal/`operator!=`(9916366bbc6ddca2). != (const type_dependenciescxx . . $ injeqt/internal/type_dependencies# &x, const type_dependenciescxx . . $ injeqt/internal/type_dependencies# &y); |
| 75 | |
| 76 | /** |
| 77 | * @brief Create valid type_dependencies from given type. |
| 78 | * @param dependent_type type to get dependecies from. |
| 79 | * @pre !dependent_type.is_empty() |
| 80 | * @throw dependency_on_self when type depends on self |
| 81 | * @throw dependency_on_subtype when type depends on own supertype |
| 82 | * @throw dependency_on_subtype when type depends on own subtype |
| 83 | * @throw invalid_setter if any tagged setter has parameter that is not a QObject-derived pointer |
| 84 | * @throw invalid_setter if any tagged setter has parameter that is a QObject pointer |
| 85 | * @throw invalid_setter if any tagged setter has other number of parameters than one |
| 86 | */ |
| 87 | inline type_dependenciescxx . . $ injeqt/internal/type_dependencies# make_type_dependenciescxx . . $ injeqt/internal/make_type_dependencies(7a895c663be5b638).(const types_by_namecxx . . $ injeqt/internal/types_by_name# &known_types, typecxx . . $ injeqt/v1/type# dependent_type) |
| 88 | { |
| 89 | assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!dependent_type.is_empty()); |
| 90 | |
| 91 | return type_dependenciescxx . . $ injeqt/internal/type_dependencies#{dependent_type, extract_dependenciescxx . . $ injeqt/internal/extract_dependencies(c8c0e98cc48858ad).(known_types, dependent_type)}; |
| 92 | } |
| 93 | |
| 94 | }} |