]> vaikene.ee Git - evaf/blobdiff - www/pswgen06.html
Warning fixes and copyright update.
[evaf] / www / pswgen06.html
index aefb6ece066c647cb56786a7d31d909062de451d..ad523d7a787550a2197ae63d181711d9590af3a7 100644 (file)
@@ -12,6 +12,8 @@
     </head>
 
     <body>
+    
+        <p>Next: <a href="pswgen07.html">07 - Storage Module</a>, Previous: <a href="pswgen05.html">05 - Building Generator Module</a></p>
 
         <h1>eVaf Tutorial</h1>
 
 
     <span class="hl kwc">virtual</span> QExplicitlySharedDataPointer<span class="hl opt">&lt;</span>Storage<span class="hl opt">::</span>Data<span class="hl opt">&gt;</span> <span class="hl kwd">query</span><span class="hl opt">(</span>QString <span class="hl kwb">const</span> <span class="hl opt">&amp;</span> name<span class="hl opt">)</span> <span class="hl kwb">const</span> <span class="hl opt">=</span> <span class="hl num">0</span><span class="hl opt">;</span></pre>
 
+    <p>The <tt>query()</tt> method returns an explicitly shared shared data pointer, which has the following advantages:</p>
+    <ul>
+        <li>The same data object is shared between multiple modules and if a module changes attributes in the data object, these
+        changes are immediately seen by any other modules;</li>
+        <li>No need to worry about ownership -- the shared data object is deleted when the last module stops using it;</li>
+        <li>The <tt>query()</tt> method can return an empty shared data pointer to indicate that no data objects with the
+        given name exist.</tt>
+    </ul>
+
+    <p>The drawback is that if a module needs a local copy of the data object, it has to use the <tt>QExplicitlySharedDataPointer::detach()</tt> method to create a deep copy of the data object.</p>
+
     <p>The specification also mentions partial matches where entering "fa" would offer "facebook.com" if it exists. This could be done by
     using the <tt>QCompleter</tt> class that provides auto completion in Qt widgets like <tt>QLineEdit</tt> and <tt>QComboBox</tt>. The
     <tt>QCompleter<tt> class needs a <tt>QAbstractItemModel</tt> for the auto completion word list and we can provide it