Debian Codegraph @

src/internal/provider-configuration.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>
24 #include <injeqt/type.h>
25
26 #include "internal.h"
27 #include "types-by-name.h"
28
29 #include <memory>
30
31 /**
32 * @file
33 * @brief Contains classes and functions for representing configuration of object's provider.
34 */
35
36 namespace injeqt { namespace internal {
37
38 class provider;
39
40 /**
41 * @brief Abstract configuration of object's provider
42 * @see provider
43 *
44 * This object is used to create @see provider objects. Configurations are stored in @see module
45 * and @see module_impl, providers are stored in @see injector_core objects.
46 *
47 * Provider configuration contains only two methods: types() and create_provider(const types_by_name &).
48 * First one is represents list of types that are known to provider (like factory type and created
49 * object type), second one creates provider based on list of all known types.
50 *
51 * This class is reqruied due to Qt limitations of interactions between plugins and QMetaType system.
52 * If QMetaType have worked properly inside plugins it could be used to extract parameter and return
53 * types of invokable methods (using QMetaMethod::returnType() and QMetaMethod::paremeterType() with
54 * QMetaType::metaObjectForType(int). As it does not work, Injeqt stores all known QMetaObject in
55 * common @see types_by_name structure (that can only by computed in @see injector when all modules are known)
56 * and uses QMetaMethod::typeName() and QMetaMethod::returnType()::paramterTypes() to get names of
57 * types, that are mapped using this @see types_by_name.
58 */
59 class INJEQT_INTERNAL_API provider_configuration
60 {
61
62 public:
63 explicit provider_configuration() {}
64 virtual ~provider_configuration() {}
65
66 /**
67 * @return list of all types that this configuration knows (like factory type and created object type)
68 */
69 virtual std::vector<type> types() const = 0;
70
71 /**
72 * @param known_types list of all types known to injector
73 * @return new provider object
74 */
75 virtual std::unique_ptr<provider> create_provider(const types_by_name &known_types) const = 0;
76
77 };
78
79 }}