| 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 "implemented-by-mapping.h"cxx . . $ `<file>/src/internal/implemented-by-mapping.h`/ |
| 27 | #include "internal.h"cxx . . $ `<file>/src/internal/internal.h`/ |
| 28 | #include "types-by-name.h"cxx . . $ `<file>/src/internal/types-by-name.h`/ |
| 29 | #include "types-dependencies.h"cxx . . $ `<file>/src/internal/types-dependencies.h`/ |
| 30 | |
| 31 | /** |
| 32 | * @file |
| 33 | * @brief Contains classes and functions for representing model of Injeqt types. |
| 34 | */ |
| 35 | |
| 36 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 37 | |
| 38 | /** |
| 39 | * @brief Model of all types, their dependencies and relations. |
| 40 | * |
| 41 | * This class is used to represent model of all types, their dependencies and relations. |
| 42 | * Basically it consists of implemented_by_mapping and types_dependencies build from |
| 43 | * the same set of types. |
| 44 | * |
| 45 | * Use make_types_model(const std::vector<type> &) to create valid instance of this type |
| 46 | * and be informed of any errors in form of exceptions. |
| 47 | */ |
| 48 | class INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:26:9`! types_modelcxx . . $ injeqt/internal/types_model# |
| 49 | { |
| 50 | |
| 51 | public: |
| 52 | /** |
| 53 | * @brief Create empty instance of types_model. |
| 54 | */ |
| 55 | types_modelcxx . . $ injeqt/internal/types_model#types_model(49f6e7a06ebc5aa8).(); |
| 56 | |
| 57 | /** |
| 58 | * @brief Create new instance of types_model. |
| 59 | * @param available_types set of all interfaces in model mapped to implementation types |
| 60 | * @param mapped_dependencies set of all dependencies of implementation types |
| 61 | * |
| 62 | * Both @p available_types and @p mapped_dependencies should be created from the same set of |
| 63 | * types for types_model to be usefull. |
| 64 | */ |
| 65 | explicit types_modelcxx . . $ injeqt/internal/types_model#types_model(dd375443b17c432f).(implemented_by_mappingcxx . . $ injeqt/internal/implemented_by_mapping# available_types, types_dependenciescxx . . $ injeqt/internal/types_dependencies# mapped_dependencies); |
| 66 | |
| 67 | /** |
| 68 | * @return set of all interfaces in model mapped to implementation types. |
| 69 | */ |
| 70 | const implemented_by_mappingcxx . . $ injeqt/internal/implemented_by_mapping# & available_typescxx . . $ injeqt/internal/types_model#available_types(f204e9055a5335f3).() const; |
| 71 | |
| 72 | /** |
| 73 | * @return set of all dependencies of implementation types |
| 74 | */ |
| 75 | const types_dependenciescxx . . $ injeqt/internal/types_dependencies# & mapped_dependenciescxx . . $ injeqt/internal/types_model#mapped_dependencies(6995930a3bd7d232).() const; |
| 76 | |
| 77 | /** |
| 78 | * @return true if model contains @p interface_type |
| 79 | */ |
| 80 | bool containscxx . . $ injeqt/internal/types_model#contains(50bf6aa70d8632fb).(const typecxx . . $ injeqt/v1/type# &interface_type) const; |
| 81 | |
| 82 | /** |
| 83 | * @brief Return all unresolvable dependencies |
| 84 | */ |
| 85 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<dependencycxx . . $ injeqt/internal/dependency#> get_unresolvable_dependenciescxx . . $ injeqt/internal/types_model#get_unresolvable_dependencies(5e9b420138d82390).() const; |
| 86 | |
| 87 | private: |
| 88 | implemented_by_mappingcxx . . $ injeqt/internal/implemented_by_mapping# _available_typescxx . . $ injeqt/internal/types_model#_available_types.; |
| 89 | types_dependenciescxx . . $ injeqt/internal/types_dependencies# _mapped_dependenciescxx . . $ injeqt/internal/types_model#_mapped_dependencies.; |
| 90 | |
| 91 | }; |
| 92 | |
| 93 | /** |
| 94 | * @brief Create types_model from given set of types. |
| 95 | * @param known_types list of all known types |
| 96 | * @param all_types set of types to make model from, all types must be valid. |
| 97 | * @param need_dependencies list of types that will have dependencies extracted |
| 98 | * @post result.get_unresolvable_dependencies().empty() |
| 99 | * @throw ambiguous_types if one or more types is ambiguous (@see make_type_relations) |
| 100 | * @throw unresolvable_dependencies if a type has a dependency type not in @p all_types set |
| 101 | * @throw dependency_on_self when type depends on self |
| 102 | * @throw dependency_on_subtype when type depends on own supertype |
| 103 | * @throw dependency_on_subtype when type depends on own subtype |
| 104 | * @throw invalid_setter if any tagged setter has parameter that is not a QObject-derived pointer |
| 105 | * @throw invalid_setter if any tagged setter has parameter that is a QObject pointer |
| 106 | * @throw invalid_setter if any tagged setter has other number of parameters than one |
| 107 | */ |
| 108 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! types_modelcxx . . $ injeqt/internal/types_model# make_types_modelcxx . . $ injeqt/internal/make_types_model(b2f682f82691dfc9).(const types_by_namecxx . . $ injeqt/internal/types_by_name# &known_types, const stdcxx . . $ std/::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#> &all_types, const stdcxx . . $ std/::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#> &need_dependencies); |
| 109 | |
| 110 | /** |
| 111 | * @brief Check if types model do not have unresolvable types. |
| 112 | * @param model model to check |
| 113 | * @throw unresolvable_dependencies if @p model contains unresolvable types |
| 114 | */ |
| 115 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! void validate_non_unresolvablecxx . . $ injeqt/internal/validate_non_unresolvable(4d683f01ab1d0083).(const types_modelcxx . . $ injeqt/internal/types_model# &model); |
| 116 | |
| 117 | }} |