| 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 | #include "provider-configuration.h"cxx . . $ `<file>/src/internal/provider-configuration.h`/ |
| 28 | |
| 29 | /** |
| 30 | * @file |
| 31 | * @brief Contains classes and functions for representing configuration of provider working on factory method. |
| 32 | */ |
| 33 | |
| 34 | namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ { |
| 35 | |
| 36 | /** |
| 37 | * @brief Configuration of provider that returns object created by factory method. |
| 38 | * |
| 39 | * This provider configuration object will return provider implementation that will |
| 40 | * use factory method to create objects. |
| 41 | */ |
| 42 | class INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration# : public provider_configurationcxx . . $ injeqt/internal/provider_configuration# |
| 43 | { |
| 44 | |
| 45 | public: |
| 46 | /** |
| 47 | * @brief Create provider configuration instance. |
| 48 | * @param object_type type of object that this provider will return |
| 49 | * @param factory_type type of object that contains factory method that will return object of type @p object_type |
| 50 | * @pre !object_type.is_empty() |
| 51 | * @pre !factory.is_empty() |
| 52 | * |
| 53 | * This constructor does not throw even when @p object_type or @p factory_type is invalid or if |
| 54 | * @p factory_type does not contain proper factory method. |
| 55 | * Factory method create_provider(const types_by_name &) will throw in that case. |
| 56 | */ |
| 57 | explicit provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#provider_by_factory_configuration(4db51c5aea7c0a3b).(typecxx . . $ injeqt/v1/type# object_type, typecxx . . $ injeqt/v1/type# factory_type); |
| 58 | virtual ~cxx . . $ injeqt/internal/provider_by_factory_configuration#`~provider_by_factory_configuration`(49f6e7a06ebc5aa8).provider_by_factory_configurationcxx . . $ injeqt/internal/provider_by_factory_configuration#(); |
| 59 | |
| 60 | /** |
| 61 | * @return list consisting of object_type and factory_type params passed to constructor |
| 62 | */ |
| 63 | virtual stdcxx . . $ std/::vectorcxx . . $ std/vector#<typecxx . . $ injeqt/v1/type#> typescxx . . $ injeqt/internal/provider_by_factory_configuration#types(cf3a392ed5d6b92b).() const override; |
| 64 | |
| 65 | /** |
| 66 | * @param known_types list of all types known to injector, used to check return types of methods |
| 67 | * @return pointer to new @see provider_by_factory object |
| 68 | * @throw exception::qobject_type if object_type passed to constructor was QObject |
| 69 | * @throw exception::factory_type if object_type passed to constructor was QObject |
| 70 | * @throw exception::unique_factory_method_not_found if factory_type does not have unique factory metohod returning object_type |
| 71 | */ |
| 72 | virtual stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<providercxx . . $ injeqt/internal/provider#> create_providercxx . . $ injeqt/internal/provider_by_factory_configuration#create_provider(2c251cf15db9f22d).(const types_by_namecxx . . $ injeqt/internal/types_by_name# &known_types) const override; |
| 73 | |
| 74 | private: |
| 75 | typecxx . . $ injeqt/v1/type# _object_typecxx . . $ injeqt/internal/provider_by_factory_configuration#_object_type.; |
| 76 | typecxx . . $ injeqt/v1/type# _factory_typecxx . . $ injeqt/internal/provider_by_factory_configuration#_factory_type.; |
| 77 | |
| 78 | }; |
| 79 | |
| 80 | }} |