| 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 "internal.h"cxx . . $ `<file>/src/internal/internal.h`/ |
| 27 | |
| 28 | /** |
| 29 | * @file |
| 30 | * @brief Contains classes and functions for defining implementation of type. |
| 31 | */ |
| 32 | |
| 33 | class QObjectcxx . . $ QObject#; |
| 34 | |
| 35 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 36 | |
| 37 | /** |
| 38 | * @brief Connects type with object that implements it. |
| 39 | * |
| 40 | * This class is used to connect type with object that implements that type. |
| 41 | * |
| 42 | * This class is mostly used in internal code to store objects in cache and to pass |
| 43 | * them as resolved dependencies. The only place where this class is created from outside |
| 44 | * data is module::add_ready_object<T>(QObject *) where a validation is used to ensure |
| 45 | * that user passed valid data. |
| 46 | */ |
| 47 | class INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! implementationcxx . . $ injeqt/internal/implementation# final |
| 48 | { |
| 49 | |
| 50 | public: |
| 51 | /** |
| 52 | * @brief Create new instance. |
| 53 | * @param interface_type type that object implements |
| 54 | * @param object object that should implement interface_type |
| 55 | * @pre !interface_type.is_empty() |
| 56 | * @pre !interface_type.is_qobject() |
| 57 | * @pre object != nullptr |
| 58 | * @pre object->metaObject() != nullptr |
| 59 | * @pre extract_interfaces(type{object->metaObject()}).contains(interface_type) |
| 60 | */ |
| 61 | explicit implementationcxx . . $ injeqt/internal/implementation#implementation(9ea1470f0de69db5).(typecxx . . $ injeqt/v1/type# interface_type, QObjectcxx . . $ QObject# *object); |
| 62 | |
| 63 | const typecxx . . $ injeqt/v1/type# & interface_typecxx . . $ injeqt/internal/implementation#interface_type(7e9f7f4e42b3414e).() const; |
| 64 | QObjectcxx . . $ QObject# * objectcxx . . $ injeqt/internal/implementation#object(2dbb680a34285c44).() const; |
| 65 | |
| 66 | private: |
| 67 | typecxx . . $ injeqt/v1/type# _interface_typecxx . . $ injeqt/internal/implementation#_interface_type.; |
| 68 | QObjectcxx . . $ QObject# *_objectcxx . . $ injeqt/internal/implementation#_object.; |
| 69 | |
| 70 | }; |
| 71 | |
| 72 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! bool operatorcxx . . $ injeqt/internal/`operator==`(a47c5f57c455a7c1). == (const implementationcxx . . $ injeqt/internal/implementation# &x, const implementationcxx . . $ injeqt/internal/implementation# &y); |
| 73 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! bool operatorcxx . . $ injeqt/internal/`operator!=`(a47c5f57c455a7c1). != (const implementationcxx . . $ injeqt/internal/implementation# &x, const implementationcxx . . $ injeqt/internal/implementation# &y); |
| 74 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! bool operatorcxx . . $ injeqt/internal/`operator<`(a47c5f57c455a7c1). < (const implementationcxx . . $ injeqt/internal/implementation# &x, const implementationcxx . . $ injeqt/internal/implementation# &y); |
| 75 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! bool operatorcxx . . $ injeqt/internal/`operator>`(a47c5f57c455a7c1). > (const implementationcxx . . $ injeqt/internal/implementation# &x, const implementationcxx . . $ injeqt/internal/implementation# &y); |
| 76 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! bool operatorcxx . . $ injeqt/internal/`operator<=`(a47c5f57c455a7c1). <= (const implementationcxx . . $ injeqt/internal/implementation# &x, const implementationcxx . . $ injeqt/internal/implementation# &y); |
| 77 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! bool operatorcxx . . $ injeqt/internal/`operator>=`(a47c5f57c455a7c1). >= (const implementationcxx . . $ injeqt/internal/implementation# &x, const implementationcxx . . $ injeqt/internal/implementation# &y); |
| 78 | |
| 79 | /** |
| 80 | * @brief Check if @p interface_type and @p object met implementation preconditions and return new instance if true |
| 81 | * @param interface_type type that object implements |
| 82 | * @param object object that should implement interface_type |
| 83 | * @throw empty_type when passed type @p interface_type is an empty type |
| 84 | * @throw qobject_type when passed type @p interface_type represents QObject |
| 85 | * @throw invalid_qobject when passed @p object is nullptr or does not have valid QMetaObject |
| 86 | * @throw interface_not_implemented when passed @p object does not implements type @p interface_type |
| 87 | */ |
| 88 | INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! implementationcxx . . $ injeqt/internal/implementation# make_implementationcxx . . $ injeqt/internal/make_implementation(2322beed4ceffcb6).(typecxx . . $ injeqt/v1/type# interface_type, QObjectcxx . . $ QObject# *object); |
| 89 | |
| 90 | }} |