Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > c61c536f80c3d067f7ca643389c560f9 > files > 47

qtremoteobjects5-doc-5.12.2-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- remoteobjects-source.qdoc -->
  <title>Qt Remote Objects Source | Qt Remote Objects 5.12.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtremoteobjects-index.html">Qt Remote Objects</a></td><td >Qt Remote Objects Source</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtremoteobjects-index.html">Qt 5.12.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#source-objects">Source Objects</a></li>
<li class="level1"><a href="#identifying-sources">Identifying Sources</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Remote Objects Source</h1>
<span class="subtitle"></span>
<!-- $$$qtremoteobjects-source.html-description -->
<div class="descr"> <a name="details"></a>
<a name="source-objects"></a>
<h2 id="source-objects">Source Objects</h2>
<p>A Remote Object Source is the QObject that is responsible for the implementation of the exposed API.</p>
<p>At a high level, you have a choice of using a QObject type directly as a source or defining the desired API in a .rep template for use with the <a href="qtremoteobjects-repc.html">repc</a> compiler.</p>
<p>If you already have a fully defined QObject, it can become a Source simply by passing it to <a href="qremoteobjecthostbase.html#enableRemoting">QRemoteObjectHostBase::enableRemoting</a>(). This lets other processes/devices create a <a href="qtremoteobjects-replica.html#replica">Replica</a> of the object to interact with (see <a href="qtremoteobjects-interaction.html#remote-object-interaction">Remote Object Interaction</a>). You can then instantiate <a href="qremoteobjectdynamicreplica.html">QRemoteObjectDynamicReplica</a>s of your object.</p>
<p>Letting <a href="qtremoteobjects-repc.html">repc</a> generate a <a href="qtremoteobjects-source.html#source">Source</a> header file for your project (using the <a href="qtremoteobjects-repc.html#repc-source">REPC_SOURCE</a> variable) provides three options for implementing the desired API. If your class name was Foo, the options would be the following (see <a href="qtremoteobjects-repc.html#the-rep-file-format">The rep file format</a> for help in creating a rep file)</p>
<ul>
<li><a href="qtremoteobjects-source.html#typesimplesource">FooSimpleSource</a> inheritance</li>
<li><a href="qtremoteobjects-source.html#typesource">FooSource</a> inheritance</li>
<li><a href="qtremoteobjects-source.html#typeapi">FooSourceAPI</a> usage with your own QObject</li>
</ul>
<a name="typesimplesource"></a><p>There is a &lt;Type&gt;SimpleSource class defined in the header, which provides basic getter/setter methods for each property and implements data members of the correct property type in the header. Here &quot;&lt;Type&gt;&quot; represents the class name from the .rep file, so if your class is of type &quot;MyType&quot; in the .rep file, there will be a MyTypeSimpleSource class declared in the generated header file. This is a fast way to get started using the API. To use this class, you need to inherit from this class and implement any defined slots (which are pure virtual in the generated header file). Whatever logic is needed to manage the exposed properties and emit signals would be added to the inheriting class as well.</p>
<a name="typesource"></a><p>If you need to hide the implementation details, you can use the &lt;Type&gt;Source class instead, which is the 2nd class declared in the header file. This class definition does not provide data members, and makes the getter/setter functions pure virtual as well. You have more flexibility in how you implement the class, although you need to write more code.</p>
<a name="typeapi"></a><p>Finally, there is the &lt;Type&gt;SourceAPI class generated in the header. This is a templated class, for use specifically by the templated version of <a href="qremoteobjecthostbase.html#enableRemoting">QRemoteObjectHostBase::enableRemoting</a>(), which allows you to use any QObject that supports the desired API as the source. You will get compile-time warnings if the class does not provide the correct API, and using this class allows you to hide or convert properties or signal/slot parameters.</p>
<p><b>Note: </b>The QObject API is <b>never</b> exposed. For instance, while a <a href="qtremoteobjects-replica.html#replica">Replica</a> will have a destroyed signal, the destroyed signal of the source is not propagated. The <a href="qtremoteobjects-source.html#source">Source</a> and each <a href="qtremoteobjects-replica.html#replica">Replica</a> are unique QObjects with their own connections. The API that is exposed is defined by the .rep template used by <a href="qtremoteobjects-repc.html">repc</a>, or in the case of raw QObjects, all API elements defined in the inheritance chain from a specific ancestor. Unless you define Q_CLASSINFO(&quot;RemoteObject Type&quot;) in an ancestor, the QObject's parent is used. If Q_CLASSINFO(&quot;RemoteObject Type&quot;) is used, that class's API is the lowest level of API used.</p><a name="identifying-sources"></a>
<h2 id="identifying-sources">Identifying Sources</h2>
<p>Since more than one <a href="qtremoteobjects-source.html#source">Source</a> can be shared by a host node, each <a href="qtremoteobjects-source.html#source">Source</a> requires a name. All <a href="qtremoteobjects-repc.html">repc</a> generated headers include a way for the node to determine the class name (Q_CLASSINFO for replica/simplesource/source types, or a static name() function for the SourceAPI type). If you pass your own QObject type to <a href="qremoteobjecthostbase.html#enableRemoting">QRemoteObjectHostBase::enableRemoting</a>(), the name will be determined using the following logic:</p>
<ul>
<li>A name can optionally be passed to <a href="qremoteobjecthostbase.html#enableRemoting">QRemoteObjectHostBase::enableRemoting</a>(). If provided, that name will be used.</li>
<li>If the object or any of its ancestors has Q_CLASSINFO of type &quot;RemoteObject Type&quot; defined, the defined type name will be used.</li>
<li>Otherwise, the QObject's objectName (if set) will be used.</li>
<li>If none of the above are available, the call to <a href="qremoteobjecthostbase.html#enableRemoting">QRemoteObjectHostBase::enableRemoting</a>() will fail, returning false.</li>
</ul>
</div>
<!-- @@@qtremoteobjects-source.html -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>