Debian Codegraph @

src/internal/provider-by-factory.h

raw symbols SCIP
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 "factory-method.h"cxx . . $ `<file>/src/internal/factory-method.h`/
26 #include "internal.h"cxx . . $ `<file>/src/internal/internal.h`/
27 #include "provider.h"cxx . . $ `<file>/src/internal/provider.h`/
28
29 /**
30 * @file
31 * @brief Contains classes and functions for representing provider working on factory method.
32 */
33
34 namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ {
35
36 /**
37 * @brief Provider that returns object created by factory.
38 *
39 * This provider implementation will return object using factory method. Its provided_type() returns
40 * type of factory method return type and its required_types() returns type of object of factory method.
41 * On first call of provide(injector_core &) it will ask injector_core for object of type
42 * factory_method::object_method() to be able to invoke this method on that object.
43 *
44 * Once created, object will be stored inside and return on subsequents calls to provide(injector_core &).
45 * This provider has ownershipd over created object and will destroy it at own destruction.
46 */
47 class INJEQT_INTERNAL_APIcxx . . $ `src/internal/internal.h:24:9`! provider_by_factorycxx . . $ injeqt/internal/provider_by_factory# final : public providercxx . . $ injeqt/internal/provider#
48 {
49
50 public:
51 /**
52 * @brief Create provider instance with factory method to call.
53 * @param factory factory method used to create object
54 */
55 explicit provider_by_factorycxx . . $ injeqt/internal/provider_by_factory#provider_by_factory(1fa9f39a5bd862df).(factory_methodcxx . . $ injeqt/internal/factory_method# factory);
56 virtual ~cxx . . $ injeqt/internal/provider_by_factory#`~provider_by_factory`(49f6e7a06ebc5aa8).provider_by_factorycxx . . $ injeqt/internal/provider_by_factory#();
57
58 provider_by_factorycxx . . $ injeqt/internal/provider_by_factory#provider_by_factory(ecb7f1c8fcd33b7c).(provider_by_factorycxx . . $ injeqt/internal/provider_by_factory# &&x) = delete;
59 provider_by_factorycxx . . $ injeqt/internal/provider_by_factory# & operatorcxx . . $ injeqt/internal/provider_by_factory#`operator=`(f9d8dd8960824e60). = (provider_by_factorycxx . . $ injeqt/internal/provider_by_factory# &&x) = delete;
60
61 /**
62 * @return factory_method::retrun_type() of object passed to construtor
63 */
64 virtual const typecxx . . $ injeqt/v1/type# & provided_typecxx . . $ injeqt/internal/provider_by_factory#provided_type(7e9f7f4e42b3414e).() const override;
65
66 /**
67 * @return object created by factory method
68 * @post result != nullptr
69 * @post implements(type{result->metaObject()}, provided_type())
70 * @throw instantiation_failed if instantiation of provided type failed
71 *
72 * If object was not yet created the object of type factory_method::object_type() is requested
73 * from @p i and the factory method is called on it to get object and stoe it in internal cache,
74 * Then object from cache is returned.
75 */
76 virtual QObjectcxx . . $ QObject# * providecxx . . $ injeqt/internal/provider_by_factory#provide(51123600412ca135).(injector_corecxx . . $ injeqt/internal/injector_core# &i) override;
77
78 /**
79 * @return factory_method::object_type() from object passed to constructor
80 *
81 * Factory object must be present before factory method can be invoked.
82 */
83 virtual typescxx . . $ injeqt/internal/types# required_typescxx . . $ injeqt/internal/provider_by_factory#required_types(6f3e1a4b3e1e60c4).() const override;
84
85 /**
86 * @return false
87 *
88 * Objects creaded by factory should be ready to use and do not require dependency resolving.
89 */
90 virtual bool require_resolvingcxx . . $ injeqt/internal/provider_by_factory#require_resolving(50ce9a9e25b4a850).() const override;
91
92 /**
93 * @return factory method object passed in constructor
94 */
95 const factory_methodcxx . . $ injeqt/internal/factory_method# & factorycxx . . $ injeqt/internal/provider_by_factory#factory(95f19e0517a98a5d).() const;
96
97 private:
98 factory_methodcxx . . $ injeqt/internal/factory_method# _factorycxx . . $ injeqt/internal/provider_by_factory#_factory.;
99 stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<QObjectcxx . . $ QObject#> _objectcxx . . $ injeqt/internal/provider_by_factory#_object.;
100
101 };
102
103 }}