blob: c7f69db98861c9a7cd63188c010e3b113b56611c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qifproxyserviceobject.h"
#include "qifproxyserviceobject_p.h"
QT_BEGIN_NAMESPACE
QIfProxyServiceObjectPrivate::QIfProxyServiceObjectPrivate(QIfServiceInterface *interface)
: m_serviceInterface(interface)
{
}
QIfProxyServiceObjectPrivate::QIfProxyServiceObjectPrivate(const QHash<QString, QIfFeatureInterface*> &interfaceMap)
: m_serviceInterface(nullptr)
, m_interfaceMap(interfaceMap)
{
}
/*!
\class QIfProxyServiceObject
\inmodule QtInterfaceFramework
\brief QIfProxyServiceObject is a helper class to connect a Feature to already instantiated
QIfServiceInterface classes.
In constrast to the QIfServiceObject which is created for you by the QIfServiceManager for
every backend plugin, the QIfProxyServiceObject can be instantiated by the user and then
manually set to the feature class.
There are two ways to construct a QIfProxyServiceObject. The first takes a
QIfServiceInterface pointer as input and can be used to load a backend which is derived from
QIfServiceInterface and supposed to be loaded as a plugin, but is part of the same library and
can be loaded directly instead. e.g. within a autotest.
The second constructor takes a QHash<QString, QIfFeatureInterface*> and can be used to directly
connect a feature class to the backend implementing the QIfFeatureInterface.
\sa QIfAbstractFeature
*/
/*!
Creates a new QIfProxyServiceObject for the given \a interface.
The \a parent argument is sent to the QIfServiceObject constructor.
This can be used to load a backend which is derived from QIfServiceInterface and supposed to
be loaded as a plugin, but is part of the same library and can be loaded directly instead. e.g.
within a autotest
*/
QIfProxyServiceObject::QIfProxyServiceObject(QIfServiceInterface *interface, QObject *parent)
: QIfServiceObject(parent)
, d_ptr(new QIfProxyServiceObjectPrivate(interface))
{
}
/*!
Creates a new QIfProxyServiceObject for the given \a interfaceMap.
This can be used to directly connect a feature class to the backend implementing the
QIfFeatureInterface.
*/
QIfProxyServiceObject::QIfProxyServiceObject(const QHash<QString, QIfFeatureInterface*> &interfaceMap, QObject *parent)
: QIfServiceObject(parent)
, d_ptr(new QIfProxyServiceObjectPrivate(interfaceMap))
{
}
QIfProxyServiceObject::~QIfProxyServiceObject()
{
delete d_ptr;
}
/*!
\reimp
*/
QStringList QIfProxyServiceObject::interfaces() const
{
Q_D(const QIfProxyServiceObject);
if (d->m_serviceInterface)
return d->m_serviceInterface->interfaces();
return d->m_interfaceMap.keys();
}
/*!
\reimp
*/
QIfFeatureInterface *QIfProxyServiceObject::interfaceInstance(const QString &interface) const
{
Q_D(const QIfProxyServiceObject);
if (d->m_serviceInterface)
return d->m_serviceInterface->interfaceInstance(interface);
return d->m_interfaceMap.value(interface);
}
QString QIfProxyServiceObject::id() const
{
Q_D(const QIfProxyServiceObject);
QString id;
if (d->m_serviceInterface)
id = d->m_serviceInterface->id();
if (id.isEmpty())
id = QIfServiceObject::id();
return id;
}
QString QIfProxyServiceObject::configurationId() const
{
Q_D(const QIfProxyServiceObject);
if (d->m_serviceInterface)
return d->m_serviceInterface->configurationId();
return QIfServiceObject::configurationId();
}
void QIfProxyServiceObject::updateServiceSettings(const QVariantMap &settings)
{
Q_D(const QIfProxyServiceObject);
if (d->m_serviceInterface)
d->m_serviceInterface->updateServiceSettings(settings);
//Always also call the base class to keep the property in sync
QIfServiceObject::updateServiceSettings(settings);
}
QT_END_NAMESPACE
#include "moc_qifproxyserviceobject.cpp"
|