Debian Codegraph @

src/internal/provider.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 "types.h"cxx . . $ `<file>/src/internal/types.h`/
26
27 /**
28 * @file
29 * @brief Contains classes and functions for representing providers of object.
30 */
31
32 class QObjectcxx . . $ QObject#;
33
34 namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ {
35
36 class injector_corecxx . . $ injeqt/internal/injector_core#;
37
38 /**
39 * @brief Abstract provider of objects.
40 *
41 * Providers are used in injector to create objects of configured types. Objects
42 * can be created in different ways so this is an abstract class with a few
43 * mplementations.
44 *
45 * Provider can require objects of other types to be already available in injector
46 * using required_types() and then provide an object with its provide() object.
47 * Provider may or may no take ownership of a provided object - look for concrete
48 * types for more information.
49 *
50 * Provider return objects that may or may not require dependency resolving.
51 * It can be checked with require_resolving() method.
52 */
53 class providercxx . . $ injeqt/internal/provider#
54 {
55
56 public:
57 explicit providercxx . . $ injeqt/internal/provider#provider(49f6e7a06ebc5aa8).() {}
58 virtual ~cxx . . $ injeqt/internal/provider#`~provider`(49f6e7a06ebc5aa8).providercxx . . $ injeqt/internal/provider#() {}
59
60 /**
61 * @return type of object that this provider provides.
62 */
63 virtual const typecxx . . $ injeqt/v1/type# & provided_typecxx . . $ injeqt/internal/provider#provided_type(7e9f7f4e42b3414e).() const = 0;
64
65 /**
66 * @return provided object
67 * @param i injector_core that requests object
68 * @post result != nullptr
69 * @post implements(type{result->metaObject()}, provided_type())
70 * @throw instantiation_failed if instantiation of provided type failed
71 *
72 * Provider can require some types with required_types() to be already available
73 * in injector_core. Provider may or may no take ownership of a provided object -
74 * look for concrete types for more information.
75 */
76 virtual QObjectcxx . . $ QObject# * providecxx . . $ injeqt/internal/provider#provide(51123600412ca135).(injector_corecxx . . $ injeqt/internal/injector_core# &i) = 0;
77
78 /**
79 * @return list of types that must be instantiated in injector_core before calling provide(injector_core) method
80 *
81 * Return value of this method must be the same for whole lifetime of this object.
82 */
83 virtual typescxx . . $ injeqt/internal/types# required_typescxx . . $ injeqt/internal/provider#required_types(6f3e1a4b3e1e60c4).() const = 0;
84
85 /**
86 * @return true, if provided object require resolving of dependencies
87 */
88 virtual bool require_resolvingcxx . . $ injeqt/internal/provider#require_resolving(50ce9a9e25b4a850).() const = 0;
89
90 };
91
92 }}