diff options
author | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /doc/html/qdeepcopy.html | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'doc/html/qdeepcopy.html')
-rw-r--r-- | doc/html/qdeepcopy.html | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/doc/html/qdeepcopy.html b/doc/html/qdeepcopy.html new file mode 100644 index 000000000..2d6a01c23 --- /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>TQDeepCopy 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 Classes</font></a> + | <a href="mainclasses.html"> +<font color="#004faf">Main Classes</font></a> + | <a href="annotated.html"> +<font color="#004faf">Annotated</font></a> + | <a href="groups.html"> +<font color="#004faf">Grouped 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>TQDeepCopy Class Reference</h1> + +<p>The TQDeepCopy 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 TQt is built with thread support.</p> +<p><tt>#include <<a href="qdeepcopy-h.html">qdeepcopy.h</a>></tt> +<p><a href="qdeepcopy-members.html">List of all member functions.</a> +<h2>Public Members</h2> +<ul> +<li class=fn><a href="#TQDeepCopy"><b>TQDeepCopy</b></a> ()</li> +<li class=fn><a href="#TQDeepCopy-2"><b>TQDeepCopy</b></a> ( const T & t )</li> +<li class=fn>TQDeepCopy<T> & <a href="#operator-eq"><b>operator=</b></a> ( const T & 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 TQDeepCopy 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">TQString</a> s1 = "abcd"; + <a href="qstring.html">TQString</a> s2 = s1; + <a href="qstring.html">TQString</a> s3 = s2; + <a href="qstring.html">TQString</a> s4 = s3; + <a href="qstring.html">TQString</a> s5 = s2; + </pre> + +<p> TQDeepCopy 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">TQString</a> s1 = "abcd"; + <a href="qstring.html">TQString</a> s2 = s1; + TQDeepCopy<TQString> s3 = s2; // s3 is a <a href="shclass.html#deep-copy">deep copy</a> of s2 + <a href="qstring.html">TQString</a> s4 = s3; // s4 is a deep copy of s3 + <a href="qstring.html">TQString</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">TQString</a> s1 = "abcd"; + <a href="qstring.html">TQString</a> s2 = s1; + <a href="qstring.html">TQString</a> s3 = TQDeepCopy<TQString>( s2 ); // s3 is a deep copy of s2 + <a href="qstring.html">TQString</a> s4 = s3; // s4 is a <a href="shclass.html#shallow-copy">shallow copy</a> of s3 + <a href="qstring.html">TQString</a> s5 = s2; + </pre> + +<p> TQDeepCopy 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> + TQDeepCopy<TQString> global_string; // global string data + <a href="qmutex.html">TQMutex</a> global_mutex; // mutex to protext global_string + + ... + + void setGlobalString( const <a href="qstring.html">TQString</a> &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">TQString</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">TQString</a>, which is an implicitly shared +class. The behavior of TQDeepCopy is the same when using explicitly +shared classes like <a href="qbytearray.html">TQByteArray</a>. +<p> Currently, TQDeepCopy works with the following classes: +<ul> +<li> <a href="qmemarray.html">TQMemArray</a> (including subclasses like TQByteArray and <a href="qcstring.html">TQCString</a>) +<li> <a href="qmap.html">TQMap</a> +<li> TQString +<li> <a href="qvaluelist.html">TQValueList</a> (including subclasses like <a href="qstringlist.html">TQStringList</a> and <a href="qvaluestack.html">TQValueStack</a>) +<li> <a href="qvaluevector.html">TQValueVector</a> +</ul> +<p> <p>See also <a href="threads.html">Thread Support in TQt</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="TQDeepCopy"></a>TQDeepCopy::TQDeepCopy () +</h3> + +<p> Constructs an empty instance of type <em>T</em>. + +<h3 class=fn><a name="TQDeepCopy-2"></a>TQDeepCopy::TQDeepCopy ( const T & 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>TQDeepCopy::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">TQDeepCopy</a><T> & <a name="operator-eq"></a>TQDeepCopy::operator= ( const T & 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">TQt toolkit</a>. +Copyright © 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 © 2007 +<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> +<td align=right><div align=right>TQt 3.3.8</div> +</table></div></address></body> +</html> |