1// Copyright (C) 2017 Ford Motor Company
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qtremoteobjectglobal.h"
5#include "qremoteobjectpacket_p.h"
6
7#include <QtCore/qdatastream.h>
8#include <QtCore/qmetaobject.h>
9
10QT_BEGIN_NAMESPACE
11
12Q_LOGGING_CATEGORY(QT_REMOTEOBJECT, "qt.remoteobjects", QtWarningMsg)
13Q_LOGGING_CATEGORY(QT_REMOTEOBJECT_MODELS, "qt.remoteobjects.models", QtWarningMsg)
14Q_LOGGING_CATEGORY(QT_REMOTEOBJECT_IO, "qt.remoteobjects.io", QtWarningMsg)
15
16QT_IMPL_METATYPE_EXTERN(QRemoteObjectSourceLocation)
17QT_IMPL_METATYPE_EXTERN(QRemoteObjectSourceLocations)
18QT_IMPL_METATYPE_EXTERN(QIntHash)
19
20/*!
21 \namespace QtRemoteObjects
22 \inmodule QtRemoteObjects
23
24 \brief The QtRemoteObjects namespace contains identifiers used in the
25 Remote Objects module, as well as some functions used from code generated
26 by the \l{Qt Remote Objects Compiler}{Replica Compiler (repc)}.
27*/
28
29/*!
30 \enum QtRemoteObjects::InitialAction
31
32 This enum type specifies the initial action when acquiring a \l Replica derived
33 from QAbstractItemModel.
34
35 \value FetchRootSize Only the size of the model is requested before the
36 \l {QRemoteObjectReplica::}{initialized} signal is emitted,
37 no data will be prefetched before that.
38 \value PrefetchData Some data can be prefetched before the
39 \l {QRemoteObjectReplica::}{initialized} signal is emitted.
40
41 \sa QRemoteObjectNode::acquireModel(), QRemoteObjectReplica::initialized()
42*/
43
44namespace QtRemoteObjects {
45
46void copyStoredProperties(const QMetaObject *mo, const void *src, void *dst)
47{
48 if (!src) {
49 qCWarning(QT_REMOTEOBJECT) << Q_FUNC_INFO << ": trying to copy from a null source";
50 return;
51 }
52 if (!dst) {
53 qCWarning(QT_REMOTEOBJECT) << Q_FUNC_INFO << ": trying to copy to a null destination";
54 return;
55 }
56
57 for (int i = 0, end = mo->propertyCount(); i != end; ++i) {
58 const QMetaProperty mp = mo->property(index: i);
59 mp.writeOnGadget(gadget: dst, value: mp.readOnGadget(gadget: src));
60 }
61}
62
63void copyStoredProperties(const QMetaObject *mo, const void *src, QDataStream &dst)
64{
65 if (!src) {
66 qCWarning(QT_REMOTEOBJECT) << Q_FUNC_INFO << ": trying to copy from a null source";
67 return;
68 }
69
70 for (int i = 0, end = mo->propertyCount(); i != end; ++i) {
71 const QMetaProperty mp = mo->property(index: i);
72 dst << QRemoteObjectPackets::encodeVariant(value: mp.readOnGadget(gadget: src));
73 }
74}
75
76void copyStoredProperties(const QMetaObject *mo, QDataStream &src, void *dst)
77{
78 if (!dst) {
79 qCWarning(QT_REMOTEOBJECT) << Q_FUNC_INFO << ": trying to copy to a null destination";
80 return;
81 }
82
83 for (int i = 0, end = mo->propertyCount(); i != end; ++i) {
84 const QMetaProperty mp = mo->property(index: i);
85 QVariant v;
86 src >> v;
87 mp.writeOnGadget(gadget: dst, value: QRemoteObjectPackets::decodeVariant(value: std::move(v), metaType: mp.metaType()));
88 }
89}
90
91} // namespace QtRemoteObjects
92
93QT_END_NAMESPACE
94

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