diff options
author | Kevin Funk <kevin.funk.ford@kdab.com> | 2017-03-20 21:20:41 +0100 |
---|---|---|
committer | Kevin Funk <kevin.funk@kdab.com> | 2017-03-24 19:48:03 +0000 |
commit | 4b65644d0f76773e9e2702d5737cc1c7fe9c64e6 (patch) | |
tree | 00531f92c98f49f705cc0e59308743b212ebde9d /src/remoteobjects/qconnectionfactories.cpp | |
parent | 44b2ca259cf46a468bebad19202d15534e282f69 (diff) |
Load backends properly in Qt static builds
We need a proper way to register the Client/Server backends.
Registration via static initialization will not, thus turn the
Client/Server factories into a global singleton and attempt to
register the Client/Server backends whenever the create-function
is called.
Change-Id: I1c2fb5ad1e742e6480148254fe774ce2a1c6630f
Task-number: QTBUG-59464
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Diffstat (limited to 'src/remoteobjects/qconnectionfactories.cpp')
-rw-r--r-- | src/remoteobjects/qconnectionfactories.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/src/remoteobjects/qconnectionfactories.cpp b/src/remoteobjects/qconnectionfactories.cpp index 0f77809..4f76459 100644 --- a/src/remoteobjects/qconnectionfactories.cpp +++ b/src/remoteobjects/qconnectionfactories.cpp @@ -34,10 +34,27 @@ #include "qconnectionfactories.h" #include "qconnectionfactories_p.h" +// BEGIN: Backends +#if defined(Q_OS_QNX) +#include "qconnection_qnx_backend_p.h" +#endif +#include "qconnection_local_backend_p.h" +#include "qconnection_tcpip_backend_p.h" +// END: Backends + QT_BEGIN_NAMESPACE using namespace QtRemoteObjects; +class FactoryLoader +{ +public: + QtROClientFactory clientFactory; + QtROServerFactory serverFactory; +}; + +Q_GLOBAL_STATIC(FactoryLoader, loader) + inline bool fromDataStream(QDataStream &in, QRemoteObjectPacketTypeEnum &type, QString &name) { quint16 _type; @@ -211,4 +228,96 @@ ServerIoDevice *QConnectionAbstractServer::nextPendingConnection() return iodevice; } +/*! + \class QtROServerFactory + \inmodule QtRemoteObjects + \brief A class holding information about server backends available on the Qt Remote Objects network +*/ +QtROServerFactory::QtROServerFactory() +{ +#if defined(Q_OS_QNX) + registerType<QnxServerImpl>(QStringLiteral("qnx")); +#endif + registerType<LocalServerImpl>(QStringLiteral("local")); + registerType<TcpServerImpl>(QStringLiteral("tcp")); +} + +QtROServerFactory *QtROServerFactory::instance() +{ + return &loader->serverFactory; +} + +/*! + \class QtROClientFactory + \inmodule QtRemoteObjects + \brief A class holding information about client backends available on the Qt Remote Objects network +*/ +QtROClientFactory::QtROClientFactory() +{ +#if defined(Q_OS_QNX) + registerType<QnxClientIo>(QStringLiteral("qnx")); +#endif + registerType<LocalClientIo>(QStringLiteral("local")); + registerType<TcpClientIo>(QStringLiteral("tcp")); +} + +QtROClientFactory *QtROClientFactory::instance() +{ + return &loader->clientFactory; +} + +/*! + \fn void qRegisterRemoteObjectsClient(const QString &id) + \relates QtROClientFactory + + Registers the Remote Objects client \a id for the type \c{T}. + + If you need a custom transport protocol for Qt Remote Objects, you need to + register the client & server implementation here. + + \note This function requires that \c{T} is a fully defined type at the point + where the function is called. + + This example registers the class \c{CustomClientIo} as \c{"myprotocol"}: + + \code + qRegisterRemoteObjectsClient<CustomClientIo>(QStringLiteral("myprotocol")); + \endcode + + With this in place, you can now instantiate nodes using this new custom protocol: + + \code + QRemoteObjectNode client(QUrl(QStringLiteral("myprotocol:registry"))); + \endcode + + \sa {qRegisterRemoteObjectsServer} +*/ + +/*! + \fn void qRegisterRemoteObjectsServer(const QString &id) + \relates QtROServerFactory + + Registers the Remote Objects server \a id for the type \c{T}. + + If you need a custom transport protocol for Qt Remote Objects, you need to + register the client & server implementation here. + + \note This function requires that \c{T} is a fully defined type at the point + where the function is called. + + This example registers the class \c{CustomServerImpl} as \c{"myprotocol"}: + + \code + qRegisterRemoteObjectsServer<CustomServerImpl>(QStringLiteral("myprotocol")); + \endcode + + With this in place, you can now instantiate nodes using this new custom protocol: + + \code + QRemoteObjectNode client(QUrl(QStringLiteral("myprotocol:registry"))); + \endcode + + \sa {qRegisterRemoteObjectsServer} +*/ + QT_END_NAMESPACE |