This file is indexed.

/usr/share/qt5/doc/qtsensors/qtsensors-grue-example.html is in qtsensors5-doc-html 5.3.2+dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- grue.qdoc -->
  <title>Qt Sensors - Grue Sensor Example | QtSensors 5.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
    <div class="main">
    <div class="main-rounded">
        <div class="navigationbar">
        <ul>
<li>Qt 5.3</li>
<li><a href="qtsensors-index.html">Qt Sensors</a></li>
<li>Qt Sensors - Grue Sensor Example</li>
<li id="buildversion">
Qt 5.3.2 Reference Documentation</li>
    </ul>
    </div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#grue-sensor-definition">Grue Sensor Definition</a></li>
<li class="level1"><a href="#grue-sensor-implementation">Grue Sensor Implementation</a></li>
<li class="level1"><a href="#grue-sensor-console-application">Grue Sensor Console Application</a></li>
<li class="level1"><a href="#grue-sensor-qml-import">Grue Sensor QML Import</a></li>
<li class="level1"><a href="#grue-sensor-qml-application">Grue Sensor QML Application</a></li>
</ul>
</div>
<h1 class="title">Qt Sensors - Grue Sensor Example</h1>
<span class="subtitle"></span>
<!-- $$$grue-description -->
<div class="descr"> <a name="details"></a>
<p>The Qt Sensors - Grue sensor example demonstrates all the steps from creating a new sensor to using it.<p class="centerAlign"><img src="images/qtsensors-examples-grue.png" alt="" /></p><p>The Qt Sensors - Grue sensor example demonstrates all the steps from creating a new sensor to using it.</p>
<p>The sensor definition is placed in a library where client apps can access it. The actual implementation lives in a plugin.</p>
<ul>
<li><a href="#grue-sensor-definition">Grue Sensor Definition</a></li>
<li><a href="#grue-sensor-implementation">Grue Sensor Implementation</a></li>
</ul>
<p>The sensor can now be used by a C++ application, even if the application does not have access to the definition.</p>
<ul>
<li><a href="#grue-sensor-console-application">Grue Sensor Console Application</a></li>
</ul>
<p>To make the sensor available to a QML application an import must be created.</p>
<ul>
<li><a href="#grue-sensor-qml-import">Grue Sensor QML Import</a></li>
<li><a href="#grue-sensor-qml-application">Grue Sensor QML Application</a></li>
</ul>
<a name="grue-sensor-definition"></a>
<h2>Grue Sensor Definition</h2>
<p>The Grue sensor is defined in a library so that applications can use it. The source code is available in the <tt>grue/lib</tt> subdirectory.</p>
<p>First up is the sensor type. This is the interface for sensors that report on your likelihood of being eaten by a Grue. Such sensors are very important to adventurers, particularly if they are going into dark places as this is where Grues live.</p>
<p>The interface is a simple one. It provides only 1 piece of information, your chance of being eaten. For the details on how this is property should be interpreted please see the documentation in gruesensor.cpp.</p>
<p>This example was created using the make_sensor.pl script which can be found in src/sensors. As such, it contains some generated code that defines the convenience classes GrueFilter and GrueSensor.</p>
<a name="grue-sensor-implementation"></a>
<h2>Grue Sensor Implementation</h2>
<p>The Grue sensor implementation lives in a plugin that is loaded by the Qt Sensors library. The source code is available in the <tt>grue/plugin</tt> subdirectory.</p>
<p>The Grue sensor needs a backend before it can be used. The backend provided is rather basic and it relies on some kind of light sensor to work but it gets the job done. If new hardware that can detect the actual presence of Grues becomes available a backend could be created that supports this hardware and applications using the Grue sensor would be able to use it without any changes.</p>
<p>There are a few mandatory parts to a backend. They are the start and stop methods and the setReading call. The start and stop methods are used to start and stop any underlying hardware. In the case of this backend they start and stop a light sensor. In the start method, the backend should be sure to call the sensorStopped() or sensorBusy() methods if it cannot start.</p>
<pre class="cpp">    lightSensor<span class="operator">-</span><span class="operator">&gt;</span>setDataRate(sensor()<span class="operator">-</span><span class="operator">&gt;</span>dataRate());
    lightSensor<span class="operator">-</span><span class="operator">&gt;</span>start();
    <span class="comment">// If the light sensor doesn't work we don't work either</span>
    <span class="keyword">if</span> (<span class="operator">!</span>lightSensor<span class="operator">-</span><span class="operator">&gt;</span>isActive())
        sensorStopped();
    <span class="keyword">if</span> (lightSensor<span class="operator">-</span><span class="operator">&gt;</span>isBusy())
        sensorBusy();</pre>
<p>The setReading method is needed so that the sensors library knows where the readings are coming from. This backend has a local copy of the reading so it passes a pointer to the function.</p>
<pre class="cpp">    <span class="comment">// Register our reading instance</span>
    setReading<span class="operator">&lt;</span>GrueSensorReading<span class="operator">&gt;</span>(<span class="operator">&amp;</span>m_reading);</pre>
<p>However it is also possible to pass null to the setReading method in which case the sensors library will create an instance and return a pointer.</p>
<pre class="cpp"><span class="comment">// Create a reading instance for us to use</span>
m_reading <span class="operator">=</span> setReading<span class="operator">&lt;</span>GrueSensorReading<span class="operator">&gt;</span>(<span class="number">0</span>);</pre>
<p>The Grue sensor backend also supplies some metadata.</p>
<p>The backend checks 2 things, how dark it is and how long you have been in the dark. It uses the readingChanged() signal to know when to check the light sensor's value. Once it is dark, it uses a timer to increase your chance of being eaten.</p>
<p>The Grue sensor backend is delivered as a plugin. The plugin has a factory object that registers the types available and does the actual instantiation of the backend.</p>
<a name="grue-sensor-console-application"></a>
<h2>Grue Sensor Console Application</h2>
<p>The Grue sensor console application demonstrates use of the Grue sensor. The source code is available in the <tt>grue/console_app</tt> subdirectory.</p>
<p>This is a simple commandline application. It demonstrates how to use the generic access feature of Qt Sensors to avoid a link-time dependency on the Grue Sensor library.</p>
<a name="grue-sensor-qml-import"></a>
<h2>Grue Sensor QML Import</h2>
<p>The Grue sensor QML import exports the GrueSensor class as a QML type. The source code is available in the <tt>grue/import</tt> subdirectory.</p>
<p>This creates the <i>Grue 1.0</i> import.</p>
<a name="grue-sensor-qml-application"></a>
<h2>Grue Sensor QML Application</h2>
<p>The Grue sensor QML application demonstrates the use of GrueSensor QML type.</p>
<p>The application consists of a single QML file and an image. It is built as an exucutable with C++ code that runs the QML, but it can also be launched directly using the <tt>qmlscene</tt> tool.</p>
<p>You should build the top-level 'grue' project before trying to run this example or it will not be able to find its dependencies.</p>
<pre class="cpp">qmlscene <span class="operator">-</span>I <span class="operator">.</span> grue<span class="operator">.</span>qml</pre>
<p>Above, the <tt>-I .</tt> parameter adds the current directory as a module import path to locate the Grue QML module.</p>
<p>Files:</p>
<ul>
<li><a href="qtsensors-grue-makefile-qml.html">grue/Makefile.qml</a></li>
<li><a href="qtsensors-grue-grue-qml.html">grue/grue.qml</a></li>
<li><a href="qtsensors-grue-lib-gruesensor-cpp.html">grue/lib/gruesensor.cpp</a></li>
<li><a href="qtsensors-grue-lib-gruesensor-h.html">grue/lib/gruesensor.h</a></li>
<li><a href="qtsensors-grue-lib-gruesensor-p-h.html">grue/lib/gruesensor_p.h</a></li>
<li><a href="qtsensors-grue-plugin-gruesensorimpl-cpp.html">grue/plugin/gruesensorimpl.cpp</a></li>
<li><a href="qtsensors-grue-plugin-gruesensorimpl-h.html">grue/plugin/gruesensorimpl.h</a></li>
<li><a href="qtsensors-grue-main-cpp.html">grue/main.cpp</a></li>
<li><a href="qtsensors-grue-grue-pro.html">grue/grue.pro</a></li>
<li><a href="qtsensors-grue-qml-pro.html">grue/qml.pro</a></li>
<li><a href="qtsensors-grue-qml-qrc.html">grue/qml.qrc</a></li>
<li><a href="qtsensors-grue-console-app-console-app-pro.html">grue/console_app/console_app.pro</a></li>
<li><a href="qtsensors-grue-import-import-pro.html">grue/import/import.pro</a></li>
<li><a href="qtsensors-grue-import-qmldir.html">grue/import/qmldir</a></li>
<li><a href="qtsensors-grue-lib-lib-pro.html">grue/lib/lib.pro</a></li>
<li><a href="qtsensors-grue-plugin-plugin-pro.html">grue/plugin/plugin.pro</a></li>
</ul>
</div>
<!-- @@@grue -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2014 Digia Plc and/or its
   subsidiaries. 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>    Digia, Qt and their respective logos are trademarks of Digia Plc     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>