summaryrefslogtreecommitdiffstats
path: root/doc/html/qdeepcopy.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/html/qdeepcopy.html')
-rw-r--r--doc/html/qdeepcopy.html168
1 files changed, 168 insertions, 0 deletions
diff --git a/doc/html/qdeepcopy.html b/doc/html/qdeepcopy.html
new file mode 100644
index 0000000..3d5cf61
--- /dev/null
+++ b/doc/html/qdeepcopy.html
@@ -0,0 +1,168 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qdeepcopy.cpp:40 -->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>QDeepCopy Class</title>
+<style type="text/css"><!--
+fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+body { background: #ffffff; color: black; }
+--></style>
+</head>
+<body>
+
+<table border="0" cellpadding="0" cellspacing="0" width="100%">
+<tr bgcolor="#E5E5E5">
+<td valign=center>
+ <a href="index.html">
+<font color="#004faf">Home</font></a>
+ | <a href="classes.html">
+<font color="#004faf">All&nbsp;Classes</font></a>
+ | <a href="mainclasses.html">
+<font color="#004faf">Main&nbsp;Classes</font></a>
+ | <a href="annotated.html">
+<font color="#004faf">Annotated</font></a>
+ | <a href="groups.html">
+<font color="#004faf">Grouped&nbsp;Classes</font></a>
+ | <a href="functions.html">
+<font color="#004faf">Functions</font></a>
+</td>
+<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDeepCopy Class Reference</h1>
+
+<p>The QDeepCopy class is a template class which ensures that
+implicitly shared and explicitly shared classes reference unique
+data.
+<a href="#details">More...</a>
+<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
+<p><tt>#include &lt;<a href="qdeepcopy-h.html">qdeepcopy.h</a>&gt;</tt>
+<p><a href="qdeepcopy-members.html">List of all member functions.</a>
+<h2>Public Members</h2>
+<ul>
+<li class=fn><a href="#QDeepCopy"><b>QDeepCopy</b></a> ()</li>
+<li class=fn><a href="#QDeepCopy-2"><b>QDeepCopy</b></a> ( const&nbsp;T&nbsp;&amp;&nbsp;t )</li>
+<li class=fn>QDeepCopy&lt;T&gt; &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;T&nbsp;&amp;&nbsp;t )</li>
+<li class=fn><a href="#operator-T"><b>operator T</b></a> ()</li>
+</ul>
+<hr><a name="details"></a><h2>Detailed Description</h2>
+
+
+The QDeepCopy class is a template class which ensures that
+<a href="shclass.html#implicitly-shared">implicitly shared</a> and <a href="shclass.html#explicitly-shared">explicitly shared</a> classes reference unique
+data.
+<p>
+<p>
+
+<p> Normally, shared copies reference the same data to optimize memory
+use and for maximum speed. In the example below, <tt>s1</tt>, <tt>s2</tt>, <tt>s3</tt>, <tt>s4</tt> and <tt>s5</tt> share data.
+<p> <pre>
+ // all 5 strings share the same data
+ <a href="qstring.html">QString</a> s1 = "abcd";
+ <a href="qstring.html">QString</a> s2 = s1;
+ <a href="qstring.html">QString</a> s3 = s2;
+ <a href="qstring.html">QString</a> s4 = s3;
+ <a href="qstring.html">QString</a> s5 = s2;
+ </pre>
+
+<p> QDeepCopy can be used several ways to ensure that an object
+references unique, unshared data. In the example below, <tt>s1</tt>, <tt>s2</tt> and <tt>s5</tt> share data, while neither <tt>s3</tt> nor <tt>s4</tt> share data.
+<pre>
+ // s1, s2 and s5 share the same data, neither s3 nor s4 are shared
+ <a href="qstring.html">QString</a> s1 = "abcd";
+ <a href="qstring.html">QString</a> s2 = s1;
+ QDeepCopy&lt;QString&gt; s3 = s2; // s3 is a <a href="shclass.html#deep-copy">deep copy</a> of s2
+ <a href="qstring.html">QString</a> s4 = s3; // s4 is a deep copy of s3
+ <a href="qstring.html">QString</a> s5 = s2;
+ </pre>
+
+<p> In the example below, <tt>s1</tt>, <tt>s2</tt> and <tt>s5</tt> share data, and <tt>s3</tt>
+and <tt>s4</tt> share data.
+<pre>
+ // s1, s2 and s5 share the same data, s3 and s4 share the same data
+ <a href="qstring.html">QString</a> s1 = "abcd";
+ <a href="qstring.html">QString</a> s2 = s1;
+ <a href="qstring.html">QString</a> s3 = QDeepCopy&lt;QString&gt;( s2 ); // s3 is a deep copy of s2
+ <a href="qstring.html">QString</a> s4 = s3; // s4 is a <a href="shclass.html#shallow-copy">shallow copy</a> of s3
+ <a href="qstring.html">QString</a> s5 = s2;
+ </pre>
+
+<p> QDeepCopy can also provide safety in multithreaded applications
+that use shared classes. In the example below, the variable <tt>global_string</tt> is used safely since the data contained in <tt>global_string</tt> is always a deep copy. This ensures that all threads
+get a unique copy of the data, and that any assignments to <tt>global_string</tt> will result in a deep copy.
+<p> <pre>
+ QDeepCopy&lt;QString&gt; global_string; // global string data
+ <a href="qmutex.html">QMutex</a> global_mutex; // mutex to protext global_string
+
+ ...
+
+ void setGlobalString( const <a href="qstring.html">QString</a> &amp;str )
+ {
+ global_mutex.<a href="qmutex.html#lock">lock</a>();
+ global_string = str; // global_string is a deep copy of str
+ global_mutex.<a href="qmutex.html#unlock">unlock</a>();
+ }
+
+ ...
+
+ void MyThread::run()
+ {
+ global_mutex.<a href="qmutex.html#lock">lock</a>();
+ <a href="qstring.html">QString</a> str = global_string; // str is a deep copy of global_string
+ global_mutex.<a href="qmutex.html#unlock">unlock</a>();
+
+ // process the string data
+ ...
+
+ // update global_string
+ setGlobalString( str );
+ }
+ </pre>
+
+<p> <b>Warning:</b> It is the application developer's responsibility to
+protect the object shared across multiple threads.
+<p> The examples above use <a href="qstring.html">QString</a>, which is an implicitly shared
+class. The behavior of QDeepCopy is the same when using explicitly
+shared classes like <a href="qbytearray.html">QByteArray</a>.
+<p> Currently, QDeepCopy works with the following classes:
+<ul>
+<li> <a href="qmemarray.html">QMemArray</a> (including subclasses like QByteArray and <a href="qcstring.html">QCString</a>)
+<li> <a href="qmap.html">QMap</a>
+<li> QString
+<li> <a href="qvaluelist.html">QValueList</a> (including subclasses like <a href="qstringlist.html">QStringList</a> and <a href="qvaluestack.html">QValueStack</a>)
+<li> <a href="qvaluevector.html">QValueVector</a>
+</ul>
+<p> <p>See also <a href="threads.html">Thread Support in Qt</a>, <a href="shared.html">Implicitly and Explicitly Shared Classes</a>, and <a href="tools.html">Non-GUI Classes</a>.
+
+<hr><h2>Member Function Documentation</h2>
+<h3 class=fn><a name="QDeepCopy"></a>QDeepCopy::QDeepCopy ()
+</h3>
+
+<p> Constructs an empty instance of type <em>T</em>.
+
+<h3 class=fn><a name="QDeepCopy-2"></a>QDeepCopy::QDeepCopy ( const&nbsp;T&nbsp;&amp;&nbsp;t )
+</h3>
+
+<p> Constructs a <a href="shclass.html#deep-copy">deep copy</a> of <em>t</em>.
+
+<h3 class=fn><a name="operator-T"></a>QDeepCopy::operator T ()
+</h3>
+
+<p> Returns a <a href="shclass.html#deep-copy">deep copy</a> of the encapsulated data.
+
+<h3 class=fn><a href="qdeepcopy.html">QDeepCopy</a>&lt;T&gt;&nbsp;&amp; <a name="operator-eq"></a>QDeepCopy::operator= ( const&nbsp;T&nbsp;&amp;&nbsp;t )
+</h3>
+
+<p> Assigns a <a href="shclass.html#deep-copy">deep copy</a> of <em>t</em>.
+
+<!-- eof -->
+<hr><p>
+This file is part of the <a href="index.html">Qt toolkit</a>.
+Copyright &copy; 1995-2007
+<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
+<table width=100% cellspacing=0 border=0><tr>
+<td>Copyright &copy; 2007
+<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
+<td align=right><div align=right>Qt 3.3.8</div>
+</table></div></address></body>
+</html>