[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qptrcollection.cpp:40 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QPtrCollection Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPtrCollection Class Reference</h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QPtrCollection class is the base class of most pointer-based Qt collections.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
---|
| 37 | <p><tt>#include <<a href="qptrcollection-h.html">qptrcollection.h</a>></tt>
|
---|
| 38 | <p>Inherited by <a href="qasciicache.html">QAsciiCache</a>, <a href="qasciidict.html">QAsciiDict</a>, <a href="qcache.html">QCache</a>, <a href="qdict.html">QDict</a>, <a href="qintcache.html">QIntCache</a>, <a href="qintdict.html">QIntDict</a>, <a href="qptrlist.html">QPtrList</a>, <a href="qptrdict.html">QPtrDict</a>, and <a href="qptrvector.html">QPtrVector</a>.
|
---|
| 39 | <p><a href="qptrcollection-members.html">List of all member functions.</a>
|
---|
| 40 | <h2>Public Members</h2>
|
---|
| 41 | <ul>
|
---|
| 42 | <li class=fn>bool <a href="#autoDelete"><b>autoDelete</b></a> () const</li>
|
---|
| 43 | <li class=fn>void <a href="#setAutoDelete"><b>setAutoDelete</b></a> ( bool enable )</li>
|
---|
| 44 | <li class=fn>virtual uint <a href="#count"><b>count</b></a> () const = 0</li>
|
---|
| 45 | <li class=fn>virtual void <a href="#clear"><b>clear</b></a> () = 0</li>
|
---|
| 46 | <li class=fn>typedef void * <a href="#Item"><b>Item</b></a></li>
|
---|
| 47 | </ul>
|
---|
| 48 | <h2>Protected Members</h2>
|
---|
| 49 | <ul>
|
---|
| 50 | <li class=fn><a href="#QPtrCollection"><b>QPtrCollection</b></a> ()</li>
|
---|
| 51 | <li class=fn><a href="#QPtrCollection-2"><b>QPtrCollection</b></a> ( const QPtrCollection & source )</li>
|
---|
| 52 | <li class=fn>virtual <a href="#~QPtrCollection"><b>~QPtrCollection</b></a> ()</li>
|
---|
| 53 | <li class=fn>virtual Item <a href="#newItem"><b>newItem</b></a> ( Item d )</li>
|
---|
| 54 | <li class=fn>virtual void <a href="#deleteItem"><b>deleteItem</b></a> ( Item d ) = 0</li>
|
---|
| 55 | </ul>
|
---|
| 56 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | The QPtrCollection class is the base class of most pointer-based Qt collections.
|
---|
| 61 | <p>
|
---|
| 62 |
|
---|
| 63 | <p> The QPtrCollection class is an abstract base class for the Qt
|
---|
| 64 | <a href="collection.html">collection classes</a> <a href="qdict.html">QDict</a>, <a href="qptrlist.html">QPtrList</a>,
|
---|
| 65 | etc. Qt also includes value based collections, e.g. <a href="qvaluelist.html">QValueList</a>,
|
---|
| 66 | <a href="qmap.html">QMap</a>, etc.
|
---|
| 67 | <p> A QPtrCollection only knows about the number of objects in the
|
---|
| 68 | collection and the deletion strategy (see <a href="#setAutoDelete">setAutoDelete</a>()).
|
---|
| 69 | <p> A collection is implemented using the <a href="#Item">Item</a> (generic collection
|
---|
| 70 | item) type, which is a <tt>void*</tt>. The template classes that create
|
---|
| 71 | the real collections cast the <a href="#Item">Item</a> to the required type.
|
---|
| 72 | <p>See also <a href="collection.html">Collection Classes</a> and <a href="tools.html">Non-GUI Classes</a>.
|
---|
| 73 |
|
---|
| 74 | <hr><h2>Member Type Documentation</h2>
|
---|
| 75 | <h3 class=fn><a name="Item"></a>QPtrCollection::Item</h3>
|
---|
| 76 |
|
---|
| 77 | <p> This type is the generic "item" in a QPtrCollection.
|
---|
| 78 |
|
---|
| 79 | <hr><h2>Member Function Documentation</h2>
|
---|
| 80 | <h3 class=fn><a name="QPtrCollection"></a>QPtrCollection::QPtrCollection ()<tt> [protected]</tt>
|
---|
| 81 | </h3>
|
---|
| 82 |
|
---|
| 83 | <p> Constructs a collection. The constructor is protected because
|
---|
| 84 | QPtrCollection is an abstract class.
|
---|
| 85 |
|
---|
| 86 | <h3 class=fn><a name="QPtrCollection-2"></a>QPtrCollection::QPtrCollection ( const <a href="qptrcollection.html">QPtrCollection</a> & source )<tt> [protected]</tt>
|
---|
| 87 | </h3>
|
---|
| 88 |
|
---|
| 89 | <p> Constructs a copy of <em>source</em> with <a href="#autoDelete">autoDelete</a>() set to FALSE. The
|
---|
| 90 | constructor is protected because QPtrCollection is an abstract
|
---|
| 91 | class.
|
---|
| 92 | <p> Note that if <em>source</em> has autoDelete turned on, copying it will
|
---|
| 93 | risk memory leaks, reading freed memory, or both.
|
---|
| 94 |
|
---|
| 95 | <h3 class=fn><a name="~QPtrCollection"></a>QPtrCollection::~QPtrCollection ()<tt> [virtual protected]</tt>
|
---|
| 96 | </h3>
|
---|
| 97 |
|
---|
| 98 | <p> Destroys the collection. The destructor is protected because
|
---|
| 99 | QPtrCollection is an abstract class.
|
---|
| 100 |
|
---|
| 101 | <h3 class=fn>bool <a name="autoDelete"></a>QPtrCollection::autoDelete () const
|
---|
| 102 | </h3>
|
---|
| 103 |
|
---|
| 104 | <p> Returns the setting of the auto-delete option. The default is FALSE.
|
---|
| 105 | <p> <p>See also <a href="#setAutoDelete">setAutoDelete</a>().
|
---|
| 106 |
|
---|
| 107 | <h3 class=fn>void <a name="clear"></a>QPtrCollection::clear ()<tt> [pure virtual]</tt>
|
---|
| 108 | </h3>
|
---|
| 109 |
|
---|
| 110 | <p> Removes all objects from the collection. The objects will be
|
---|
| 111 | deleted if auto-delete has been enabled.
|
---|
| 112 | <p> <p>See also <a href="#setAutoDelete">setAutoDelete</a>().
|
---|
| 113 |
|
---|
| 114 | <p>Reimplemented in <a href="qasciicache.html#clear">QAsciiCache</a>, <a href="qasciidict.html#clear">QAsciiDict</a>, <a href="qcache.html#clear">QCache</a>, <a href="qdict.html#clear">QDict</a>, <a href="qintcache.html#clear">QIntCache</a>, <a href="qintdict.html#clear">QIntDict</a>, <a href="qptrlist.html#clear">QPtrList</a>, <a href="qptrdict.html#clear">QPtrDict</a>, and <a href="qptrvector.html#clear">QPtrVector</a>.
|
---|
| 115 | <h3 class=fn>uint <a name="count"></a>QPtrCollection::count () const<tt> [pure virtual]</tt>
|
---|
| 116 | </h3>
|
---|
| 117 |
|
---|
| 118 | <p> Returns the number of objects in the collection.
|
---|
| 119 |
|
---|
| 120 | <p>Reimplemented in <a href="qasciicache.html#count">QAsciiCache</a>, <a href="qasciidict.html#count">QAsciiDict</a>, <a href="qcache.html#count">QCache</a>, <a href="qdict.html#count">QDict</a>, <a href="qintcache.html#count">QIntCache</a>, <a href="qintdict.html#count">QIntDict</a>, <a href="qptrlist.html#count">QPtrList</a>, <a href="qptrdict.html#count">QPtrDict</a>, and <a href="qptrvector.html#count">QPtrVector</a>.
|
---|
| 121 | <h3 class=fn>void <a name="deleteItem"></a>QPtrCollection::deleteItem ( <a href="qptrcollection.html#Item">Item</a> d )<tt> [pure virtual protected]</tt>
|
---|
| 122 | </h3>
|
---|
| 123 |
|
---|
| 124 | <p> Reimplement this function if you want to be able to delete items.
|
---|
| 125 | <p> Deletes an item that is about to be removed from the collection.
|
---|
| 126 | <p> This function has to reimplemented in the collection template
|
---|
| 127 | classes, and should <em>only</em> delete item <em>d</em> if auto-delete has
|
---|
| 128 | been enabled.
|
---|
| 129 | <p> <b>Warning:</b> If you reimplement this function you must also
|
---|
| 130 | reimplement the destructor and call the virtual function <a href="#clear">clear</a>()
|
---|
| 131 | from your destructor. This is due to the way virtual functions and
|
---|
| 132 | destructors work in C++: Virtual functions in derived classes
|
---|
| 133 | cannot be called from a destructor. If you do not do this, your
|
---|
| 134 | <a href="#deleteItem">deleteItem</a>() function will not be called when the container is
|
---|
| 135 | destroyed.
|
---|
| 136 | <p> <p>See also <a href="#newItem">newItem</a>() and <a href="#setAutoDelete">setAutoDelete</a>().
|
---|
| 137 |
|
---|
| 138 | <h3 class=fn><a href="qptrcollection.html#Item">Item</a> <a name="newItem"></a>QPtrCollection::newItem ( <a href="qptrcollection.html#Item">Item</a> d )<tt> [virtual protected]</tt>
|
---|
| 139 | </h3>
|
---|
| 140 | Virtual function that creates a copy of an object that is about to
|
---|
| 141 | be inserted into the collection.
|
---|
| 142 | <p> The default implementation returns the <em>d</em> pointer, i.e. no copy
|
---|
| 143 | is made.
|
---|
| 144 | <p> This function is seldom reimplemented in the collection template
|
---|
| 145 | classes. It is not common practice to make a copy of something
|
---|
| 146 | that is being inserted.
|
---|
| 147 | <p> <p>See also <a href="#deleteItem">deleteItem</a>().
|
---|
| 148 |
|
---|
| 149 | <h3 class=fn>void <a name="setAutoDelete"></a>QPtrCollection::setAutoDelete ( bool enable )
|
---|
| 150 | </h3>
|
---|
| 151 |
|
---|
| 152 | <p> Sets the collection to auto-delete its contents if <em>enable</em> is
|
---|
| 153 | TRUE and to never delete them if <em>enable</em> is FALSE.
|
---|
| 154 | <p> If auto-deleting is turned on, all the items in a collection are
|
---|
| 155 | deleted when the collection itself is deleted. This is convenient
|
---|
| 156 | if the collection has the only pointer to the items.
|
---|
| 157 | <p> The default setting is FALSE, for safety. If you turn it on, be
|
---|
| 158 | careful about copying the collection - you might find yourself
|
---|
| 159 | with two collections deleting the same items.
|
---|
| 160 | <p> Note that the auto-delete setting may also affect other functions
|
---|
| 161 | in subclasses. For example, a subclass that has a remove()
|
---|
| 162 | function will remove the item from its data structure, and if
|
---|
| 163 | auto-delete is enabled, will also delete the item.
|
---|
| 164 | <p> <p>See also <a href="#autoDelete">autoDelete</a>().
|
---|
| 165 |
|
---|
| 166 | <p>Examples: <a href="grapher-nsplugin-example.html#x2769">grapher/grapher.cpp</a>, <a href="scribble-example.html#x924">scribble/scribble.cpp</a>, and <a href="bigtable-example.html#x1291">table/bigtable/main.cpp</a>.
|
---|
| 167 | <!-- eof -->
|
---|
| 168 | <hr><p>
|
---|
| 169 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 170 | Copyright © 1995-2007
|
---|
| 171 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 172 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 173 | <td>Copyright © 2007
|
---|
| 174 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 175 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 176 | </table></div></address></body>
|
---|
| 177 | </html>
|
---|