From: Enar Väikene <enar@vaikene.net> Date: Fri, 23 Sep 2011 10:12:44 +0000 (+0300) Subject: Added more information about shared data objects. X-Git-Url: https://vaikene.ee/gitweb/pswgen05.html?a=commitdiff_plain;h=c57b6a5b0b36d6fdeb9ac581a3fae3648ea39485;p=evaf Added more information about shared data objects. --- diff --git a/www/pswgen06.html b/www/pswgen06.html index aefb6ec..6c7ea93 100644 --- a/www/pswgen06.html +++ b/www/pswgen06.html @@ -141,6 +141,17 @@ <span class="hl kwc">virtual</span> QExplicitlySharedDataPointer<span class="hl opt"><</span>Storage<span class="hl opt">::</span>Data<span class="hl opt">></span> <span class="hl kwd">query</span><span class="hl opt">(</span>QString <span class="hl kwb">const</span> <span class="hl opt">&</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