1/****************************************************************************
2**
3** Copyright (C) 2017 Ford Motor Company
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtRemoteObjects module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qtremoteobjectglobal.h"
41
42#include <QtCore/qdatastream.h>
43#include <QtCore/qmetaobject.h>
44
45QT_BEGIN_NAMESPACE
46
47Q_LOGGING_CATEGORY(QT_REMOTEOBJECT, "qt.remoteobjects", QtWarningMsg)
48Q_LOGGING_CATEGORY(QT_REMOTEOBJECT_MODELS, "qt.remoteobjects.models", QtWarningMsg)
49Q_LOGGING_CATEGORY(QT_REMOTEOBJECT_IO, "qt.remoteobjects.io", QtWarningMsg)
50
51/*!
52 \namespace QtRemoteObjects
53 \inmodule QtRemoteObjects
54
55 \brief The QtRemoteObjects namespace contains identifiers used in the
56 Remote Objects module, as well as some functions used from code generated
57 by the \l{Qt Remote Objects Compiler}{Replica Compiler (repc)}.
58*/
59
60/*!
61 \enum QtRemoteObjects::InitialAction
62
63 This enum type specifies the initial action when acquiring a \l Replica derived
64 from QAbstractItemModel.
65
66 \value FetchRootSize Only the size of the model is requested before the
67 \l {QRemoteObjectReplica::}{initialized} signal is emitted,
68 no data will be prefetched before that.
69 \value PrefetchData Some data can be prefetched before the
70 \l {QRemoteObjectReplica::}{initialized} signal is emitted.
71
72 \sa QRemoteObjectNode::acquireModel(), QRemoteObjectReplica::initialized()
73*/
74
75namespace QtRemoteObjects {
76
77void copyStoredProperties(const QMetaObject *mo, const void *src, void *dst)
78{
79#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
80 if (!src) {
81 qCWarning(QT_REMOTEOBJECT) << Q_FUNC_INFO << ": trying to copy from a null source";
82 return;
83 }
84 if (!dst) {
85 qCWarning(QT_REMOTEOBJECT) << Q_FUNC_INFO << ": trying to copy to a null destination";
86 return;
87 }
88
89 for (int i = 0, end = mo->propertyCount(); i != end; ++i) {
90 const QMetaProperty mp = mo->property(index: i);
91 mp.writeOnGadget(gadget: dst, value: mp.readOnGadget(gadget: src));
92 }
93#else
94 Q_UNUSED(mo);
95 Q_UNUSED(src);
96 Q_UNUSED(dst);
97#endif
98}
99
100void copyStoredProperties(const QMetaObject *mo, const void *src, QDataStream &dst)
101{
102#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
103 if (!src) {
104 qCWarning(QT_REMOTEOBJECT) << Q_FUNC_INFO << ": trying to copy from a null source";
105 return;
106 }
107
108 for (int i = 0, end = mo->propertyCount(); i != end; ++i) {
109 const QMetaProperty mp = mo->property(index: i);
110 dst << mp.readOnGadget(gadget: src);
111 }
112#else
113 Q_UNUSED(mo);
114 Q_UNUSED(src);
115 Q_UNUSED(dst);
116#endif
117}
118
119void copyStoredProperties(const QMetaObject *mo, QDataStream &src, void *dst)
120{
121#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
122 if (!dst) {
123 qCWarning(QT_REMOTEOBJECT) << Q_FUNC_INFO << ": trying to copy to a null destination";
124 return;
125 }
126
127 for (int i = 0, end = mo->propertyCount(); i != end; ++i) {
128 const QMetaProperty mp = mo->property(index: i);
129 QVariant v;
130 src >> v;
131 mp.writeOnGadget(gadget: dst, value: v);
132 }
133#else
134 Q_UNUSED(mo);
135 Q_UNUSED(src);
136 Q_UNUSED(dst);
137#endif
138}
139
140} // namespace QtRemoteObjects
141
142QT_END_NAMESPACE
143

source code of qtremoteobjects/src/remoteobjects/qtremoteobjectglobal.cpp