| 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 | |
| 25 | #include "provider.h"cxx . . $ `<file>/src/internal/provider.h`/ |
| 26 | #include "implementation.h"cxx . . $ `<file>/src/internal/implementation.h`/ |
| 27 | #include "internal.h"cxx . . $ `<file>/src/internal/internal.h`/ |
| 28 | |
| 29 | /** |
| 30 | * @file |
| 31 | * @brief Contains classes and functions for representing provider working on ready object. |
| 32 | */ |
| 33 | |
| 34 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 35 | |
| 36 | /** |
| 37 | * @brief Provider that always returns the same object. |
| 38 | * |
| 39 | * This provider implementation will always return the same object. Its provided_type() |
| 40 | * returns type of object passed to it in constructor. Its required_types() returns |
| 41 | * empty set of types. |
| 42 | */ |
| 43 | class INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! provider_readycxx . . $ injeqt/internal/provider_ready# final : public providercxx . . $ injeqt/internal/provider# |
| 44 | { |
| 45 | |
| 46 | public: |
| 47 | /** |
| 48 | * @brief Create provider instance with object to return. |
| 49 | * @param ready_implementation object that this provider will always return |
| 50 | */ |
| 51 | explicit provider_readycxx . . $ injeqt/internal/provider_ready#provider_ready(afe902e6a66e0301).(implementationcxx . . $ injeqt/internal/implementation# ready_implementation); |
| 52 | virtual ~cxx . . $ injeqt/internal/provider_ready#`~provider_ready`(49f6e7a06ebc5aa8).provider_readycxx . . $ injeqt/internal/provider_ready#() {} |
| 53 | |
| 54 | /** |
| 55 | * @return implementation::interface_type() of object passed to construtor |
| 56 | */ |
| 57 | virtual const typecxx . . $ injeqt/v1/type# & provided_typecxx . . $ injeqt/internal/provider_ready#provided_type(7e9f7f4e42b3414e).() const override; |
| 58 | |
| 59 | /** |
| 60 | * @return object passed in constructor |
| 61 | * @post result != nullptr |
| 62 | * @post implements(type{result->metaObject()}, provided_type()) |
| 63 | */ |
| 64 | virtual QObjectcxx . . $ QObject# * providecxx . . $ injeqt/internal/provider_ready#provide(51123600412ca135).(injector_corecxx . . $ injeqt/internal/injector_core# &i) override; |
| 65 | |
| 66 | /** |
| 67 | * @return empty set of object - this provider already has instance of a type |
| 68 | */ |
| 69 | virtual typescxx . . $ injeqt/internal/types# required_typescxx . . $ injeqt/internal/provider_ready#required_types(6f3e1a4b3e1e60c4).() const override { return typescxx . . $ injeqt/internal/types#{}; } |
| 70 | |
| 71 | /** |
| 72 | * @return false |
| 73 | * |
| 74 | * Object should be ready to use and do not require dependency resolving. |
| 75 | */ |
| 76 | virtual bool require_resolvingcxx . . $ injeqt/internal/provider_ready#require_resolving(50ce9a9e25b4a850).() const override; |
| 77 | |
| 78 | /** |
| 79 | * @return implementation object passed in constructor |
| 80 | */ |
| 81 | const implementationcxx . . $ injeqt/internal/implementation# & ready_implementationcxx . . $ injeqt/internal/provider_ready#ready_implementation(60ea5ece359516a8).() const; |
| 82 | |
| 83 | private: |
| 84 | implementationcxx . . $ injeqt/internal/implementation# _ready_implementationcxx . . $ injeqt/internal/provider_ready#_ready_implementation.; |
| 85 | |
| 86 | }; |
| 87 | |
| 88 | }} |