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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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" />
<!-- q3ptrcollection.cpp -->
<title>Qt 4.8: Q3PtrCollection Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li>Qt3SupportLight</li>
<li>Q3PtrCollection</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">Q3PtrCollection Class Reference</h1>
<!-- $$$Q3PtrCollection-brief -->
<p>The Q3PtrCollection class is the base class of most pointer-based Qt collections. <a href="#details">More...</a></p>
<!-- @@@Q3PtrCollection -->
<pre class="cpp"> <span class="preprocessor">#include <Q3PtrCollection></span></pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html">Porting to Qt 4</a> for more information.</p>
<p><b>Inherited by: </b><a href="q3asciicache.html">Q3AsciiCache</a>, <a href="q3asciidict.html">Q3AsciiDict</a>, <a href="q3cache.html">Q3Cache</a>, <a href="q3dict.html">Q3Dict</a>, <a href="q3intcache.html">Q3IntCache</a>, <a href="q3intdict.html">Q3IntDict</a>, <a href="q3ptrdict.html">Q3PtrDict</a>, <a href="q3ptrlist.html">Q3PtrList</a>, <a href="q3ptrqueue.html">Q3PtrQueue</a>, <a href="q3ptrstack.html">Q3PtrStack</a>, and <a href="q3ptrvector.html">Q3PtrVector</a>.</p>
<p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="q3ptrcollection-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#Item-typedef">Item</a></b></td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#autoDelete">autoDelete</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#clear">clear</a></b> () = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual uint </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#count">count</a></b> () const = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a></b> ( bool <i>enable</i> )</td></tr>
</table>
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#Q3PtrCollection">Q3PtrCollection</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#Q3PtrCollection-2">Q3PtrCollection</a></b> ( const Q3PtrCollection & <i>source</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#dtor.Q3PtrCollection">~Q3PtrCollection</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#deleteItem">deleteItem</a></b> ( Item <i>d</i> ) = 0</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual Item </td><td class="memItemRight bottomAlign"><b><a href="q3ptrcollection.html#newItem">newItem</a></b> ( Item <i>d</i> )</td></tr>
</table>
<a name="details"></a>
<!-- $$$Q3PtrCollection-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The Q3PtrCollection class is the base class of most pointer-based Qt collections.</p>
<p>The Q3PtrCollection class is an abstract base class for the Qt collection classes QDict, <a href="q3ptrlist.html">Q3PtrList</a>, etc.</p>
<p>A Q3PtrCollection only knows about the number of objects in the collection and the deletion strategy (see <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>()).</p>
<p>A collection is implemented using the <tt>Item</tt> (generic collection item) type, which is a <tt>void*</tt>. The template classes that create the real collections cast the <tt>Item</tt> to the required type.</p>
</div>
<!-- @@@Q3PtrCollection -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Item -->
<h3 class="fn"><a name="Item-typedef"></a>typedef Q3PtrCollection::<span class="name">Item</span></h3>
<p>This type is the generic "item" in a <a href="q3ptrcollection.html" class="compat">Q3PtrCollection</a>.</p>
<!-- @@@Item -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$Q3PtrCollection[overload1]$$$Q3PtrCollection -->
<h3 class="fn"><a name="Q3PtrCollection"></a>Q3PtrCollection::<span class="name">Q3PtrCollection</span> ()<tt> [protected]</tt></h3>
<p>Constructs a collection. The constructor is protected because <a href="q3ptrcollection.html" class="compat">Q3PtrCollection</a> is an abstract class.</p>
<!-- @@@Q3PtrCollection -->
<!-- $$$Q3PtrCollection$$$Q3PtrCollectionconstQ3PtrCollection& -->
<h3 class="fn"><a name="Q3PtrCollection-2"></a>Q3PtrCollection::<span class="name">Q3PtrCollection</span> ( const <span class="type">Q3PtrCollection</span> & <i>source</i> )<tt> [protected]</tt></h3>
<p>Constructs a copy of <i>source</i> with <a href="q3ptrcollection.html#autoDelete">autoDelete</a>() set to false. The constructor is protected because <a href="q3ptrcollection.html" class="compat">Q3PtrCollection</a> is an abstract class.</p>
<p>Note that if <i>source</i> has autoDelete turned on, copying it will risk memory leaks, reading freed memory, or both.</p>
<!-- @@@Q3PtrCollection -->
<!-- $$$~Q3PtrCollection[overload1]$$$~Q3PtrCollection -->
<h3 class="fn"><a name="dtor.Q3PtrCollection"></a>Q3PtrCollection::<span class="name">~Q3PtrCollection</span> ()<tt> [virtual protected]</tt></h3>
<p>Destroys the collection. The destructor is protected because <a href="q3ptrcollection.html" class="compat">Q3PtrCollection</a> is an abstract class.</p>
<!-- @@@~Q3PtrCollection -->
<!-- $$$autoDelete[overload1]$$$autoDelete -->
<h3 class="fn"><a name="autoDelete"></a><span class="type">bool</span> Q3PtrCollection::<span class="name">autoDelete</span> () const</h3>
<p>Returns the setting of the auto-delete option. The default is false.</p>
<p><b>See also </b><a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
<!-- @@@autoDelete -->
<!-- $$$clear[overload1]$$$clear -->
<h3 class="fn"><a name="clear"></a><span class="type">void</span> Q3PtrCollection::<span class="name">clear</span> ()<tt> [pure virtual]</tt></h3>
<p>Removes all objects from the collection. The objects will be deleted if auto-delete has been enabled.</p>
<p><b>See also </b><a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
<!-- @@@clear -->
<!-- $$$count[overload1]$$$count -->
<h3 class="fn"><a name="count"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> Q3PtrCollection::<span class="name">count</span> () const<tt> [pure virtual]</tt></h3>
<p>Returns the number of objects in the collection.</p>
<!-- @@@count -->
<!-- $$$deleteItem[overload1]$$$deleteItemItem -->
<h3 class="fn"><a name="deleteItem"></a><span class="type">void</span> Q3PtrCollection::<span class="name">deleteItem</span> ( <span class="type"><a href="q3ptrcollection.html#Item-typedef">Item</a></span> <i>d</i> )<tt> [pure virtual protected]</tt></h3>
<p>Reimplement this function if you want to be able to delete items.</p>
<p>Deletes an item that is about to be removed from the collection.</p>
<p>This function has to reimplemented in the collection template classes, and should <i>only</i> delete item <i>d</i> if auto-delete has been enabled.</p>
<p><b>Warning:</b> If you reimplement this function you must also reimplement the destructor and call the virtual function <a href="q3ptrcollection.html#clear">clear</a>() from your destructor. This is due to the way virtual functions and destructors work in C++: Virtual functions in derived classes cannot be called from a destructor. If you do not do this, your deleteItem() function will not be called when the container is destroyed.</p>
<p><b>See also </b><a href="q3ptrcollection.html#newItem">newItem</a>() and <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
<!-- @@@deleteItem -->
<!-- $$$newItem[overload1]$$$newItemItem -->
<h3 class="fn"><a name="newItem"></a><span class="type"><a href="q3ptrcollection.html#Item-typedef">Item</a></span> Q3PtrCollection::<span class="name">newItem</span> ( <span class="type"><a href="q3ptrcollection.html#Item-typedef">Item</a></span> <i>d</i> )<tt> [virtual protected]</tt></h3>
<p>Virtual function that creates a copy of an object that is about to be inserted into the collection.</p>
<p>The default implementation returns the <i>d</i> pointer, i.e. no copy is made.</p>
<p>This function is seldom reimplemented in the collection template classes. It is not common practice to make a copy of something that is being inserted.</p>
<p><b>See also </b><a href="q3ptrcollection.html#deleteItem">deleteItem</a>().</p>
<!-- @@@newItem -->
<!-- $$$setAutoDelete[overload1]$$$setAutoDeletebool -->
<h3 class="fn"><a name="setAutoDelete"></a><span class="type">void</span> Q3PtrCollection::<span class="name">setAutoDelete</span> ( <span class="type">bool</span> <i>enable</i> )</h3>
<p>Sets the collection to auto-delete its contents if <i>enable</i> is true and to never delete them if <i>enable</i> is false.</p>
<p>If auto-deleting is turned on, all the items in a collection are deleted when the collection itself is deleted. This is convenient if the collection has the only pointer to the items.</p>
<p>The default setting is false, for safety. If you turn it on, be careful about copying the collection - you might find yourself with two collections deleting the same items.</p>
<p>Note that the auto-delete setting may also affect other functions in subclasses. For example, a subclass that has a remove() function will remove the item from its data structure, and if auto-delete is enabled, will also delete the item.</p>
<p><b>See also </b><a href="q3ptrcollection.html#autoDelete">autoDelete</a>().</p>
<!-- @@@setAutoDelete -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
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.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|