Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QPtrCollection Class Reference

The QPtrCollection class is the base class of most pointer-based Qt collections. More...

#include </home/clem/local/src/opie/qmake/include/qptrcollection.h>

Inheritance diagram for QPtrCollection:

Inheritance graph
[legend]
List of all members.

Public Types

typedef void * Item

Public Member Functions

bool autoDelete () const
void setAutoDelete (bool enable)
virtual uint count () const =0
virtual void clear ()=0

Protected Member Functions

 QPtrCollection ()
 QPtrCollection (const QPtrCollection &)
virtual ~QPtrCollection ()
virtual Item newItem (Item)
virtual void deleteItem (Item)=0

Protected Attributes

bool del_item

Detailed Description

The QPtrCollection class is the base class of most pointer-based Qt collections.

The QPtrCollection class is an abstract base class for the Qt collection classes QDict, QPtrList, etc. Qt also includes value based collections, e.g. QValueList, QMap, etc.

A QPtrCollection only knows about the number of objects in the collection and the deletion strategy (see setAutoDelete()).

A collection is implemented using the Item (generic collection item) type, which is a void*. The template classes that create the real collections cast the Item to the required type.

Definition at line 49 of file qptrcollection.h.


Member Typedef Documentation

typedef void* QPtrCollection::Item
 

This type is the generic "item" in a QPtrCollection.

Definition at line 58 of file qptrcollection.h.


Constructor & Destructor Documentation

QPtrCollection::QPtrCollection  )  [inline, protected]
 

Constructs a collection. The constructor is protected because QPtrCollection is an abstract class.

Definition at line 61 of file qptrcollection.h.

References FALSE.

QPtrCollection::QPtrCollection const QPtrCollection source  )  [inline, protected]
 

Constructs a copy of source with autoDelete() set to FALSE. The constructor is protected because QPtrCollection is an abstract class.

Note that if source has autoDelete turned on, copying it will risk memory leaks, reading freed memory, or both.

Definition at line 62 of file qptrcollection.h.

References FALSE.

QPtrCollection::~QPtrCollection  )  [inline, protected, virtual]
 

Destroys the collection. The destructor is protected because QPtrCollection is an abstract class.

Definition at line 63 of file qptrcollection.h.


Member Function Documentation

bool QPtrCollection::autoDelete  )  const [inline]
 

Returns the setting of the auto-delete option. The default is FALSE.

See also:
setAutoDelete()

Definition at line 52 of file qptrcollection.h.

void QPtrCollection::clear  )  [pure virtual]
 

Removes all objects from the collection. The objects will be deleted if auto-delete has been enabled.

See also:
setAutoDelete()

Implemented in QAsciiDict< type >, QCache< type >, QDict< type >, QGCache, QGDict, QGList, QGVector, QIntDict< type >, QPtrList< type >, QPtrVector< type >, QCDict, QAsciiDict< QString >, QAsciiDict< int >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, QCache< QFontStruct >, QDict< NetworkSetup >, QDict< OPackage >, QDict< InterfaceInfo >, QDict< ANetNodeInstance >, QDict< QString >, QDict< QObject >, QDict< SubUnit >, QDict< int >, QDict< MountInfo >, QDict< QStyleSheetItem >, QDict< void >, QDict< ONetworkInterface >, QDict< OBluetoothDevice >, QDict< OSoundCard >, QDict< MimeTypeData >, QDict< ANetNode >, QDict< AppLnkImagePrivate >, QDict< OipkgPackage >, QDict< SystemFile >, QDict< QTime >, QDict< bool >, QDict< ListViewItemOipkg >, QDict< OPimContact >, QDict< QLibrary >, QDict< QTextFormat >, QDict< OInputDevice >, QDict< LauncherTab >, QDict< Category >, QDict< QStringList >, QDict< PackageList >, QDict< OBluetoothInterface >, QDict< OContact >, QIntDict< QPixmap >, QIntDict< QCanvasPixmapArray >, QIntDict< QLabel >, QIntDict< QString >, QIntDict< int >, QIntDict< MenuApplet >, QIntDict< AppLnk >, QIntDict< Key >, QIntDict< TVVariant >, QPtrList< QWidget >, QPtrList< QTextDocument >, QPtrList< QCanvasSprite >, QPtrList< KExhaust >, QPtrList< KBit >, QPtrList< QTextCommand >, QPtrList< QTextTableCell >, QPtrList< KMissile >, QPtrList< QFileInfo >, QPtrList< QGDictIterator >, QPtrList< KPowerup >, QPtrList< ColorRange >, QPtrList< Proc >, QPtrList< Type * >, QPtrList< char >, QPtrList< QTextCustomItem >, QPtrList< QCacheItem >, QPtrVector< Lookahead >, QPtrVector< CharClass >, and QPtrVector< State >.

uint QPtrCollection::count  )  const [pure virtual]
 

Returns the number of objects in the collection.

Implemented in QAsciiDict< type >, QCache< type >, QDict< type >, QGCache, QGDict, QGList, QGVector, QIntDict< type >, QPtrList< type >, QPtrVector< type >, QAsciiDict< QString >, QAsciiDict< int >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, QCache< QFontStruct >, QDict< NetworkSetup >, QDict< OPackage >, QDict< InterfaceInfo >, QDict< ANetNodeInstance >, QDict< QString >, QDict< QObject >, QDict< SubUnit >, QDict< int >, QDict< MountInfo >, QDict< QStyleSheetItem >, QDict< void >, QDict< ONetworkInterface >, QDict< OBluetoothDevice >, QDict< OSoundCard >, QDict< MimeTypeData >, QDict< ANetNode >, QDict< AppLnkImagePrivate >, QDict< OipkgPackage >, QDict< SystemFile >, QDict< QTime >, QDict< bool >, QDict< ListViewItemOipkg >, QDict< OPimContact >, QDict< QLibrary >, QDict< QTextFormat >, QDict< OInputDevice >, QDict< LauncherTab >, QDict< Category >, QDict< QStringList >, QDict< PackageList >, QDict< OBluetoothInterface >, QDict< OContact >, QIntDict< QPixmap >, QIntDict< QCanvasPixmapArray >, QIntDict< QLabel >, QIntDict< QString >, QIntDict< int >, QIntDict< MenuApplet >, QIntDict< AppLnk >, QIntDict< Key >, QIntDict< TVVariant >, QPtrList< QWidget >, QPtrList< QTextDocument >, QPtrList< QCanvasSprite >, QPtrList< KExhaust >, QPtrList< KBit >, QPtrList< QTextCommand >, QPtrList< QTextTableCell >, QPtrList< KMissile >, QPtrList< QFileInfo >, QPtrList< QGDictIterator >, QPtrList< KPowerup >, QPtrList< ColorRange >, QPtrList< Proc >, QPtrList< Type * >, QPtrList< char >, QPtrList< QTextCustomItem >, QPtrList< QCacheItem >, QPtrVector< Lookahead >, QPtrVector< CharClass >, and QPtrVector< State >.

void QPtrCollection::deleteItem Item  d  )  [protected, pure virtual]
 

Reimplement this function if you want to be able to delete items.

Deletes an item that is about to be removed from the collection.

This function has to reimplemented in the collection template classes, and should only delete item d if auto-delete has been enabled.

Warning:
If you reimplement this function you must also reimplement the destructor and call the virtual function clear() 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.
See also:
newItem(), setAutoDelete()

Implemented in QFontCache, QAsciiDict< QString >, QAsciiDict< int >, QCache< QPixmap >, QCache< SkinData >, QCache< QImage >, QCache< QFontStruct >, QDict< NetworkSetup >, QDict< OPackage >, QDict< InterfaceInfo >, QDict< ANetNodeInstance >, QDict< QString >, QDict< QObject >, QDict< SubUnit >, QDict< int >, QDict< MountInfo >, QDict< QStyleSheetItem >, QDict< void >, QDict< ONetworkInterface >, QDict< OBluetoothDevice >, QDict< OSoundCard >, QDict< MimeTypeData >, QDict< ANetNode >, QDict< AppLnkImagePrivate >, QDict< OipkgPackage >, QDict< SystemFile >, QDict< QTime >, QDict< bool >, QDict< ListViewItemOipkg >, QDict< OPimContact >, QDict< QLibrary >, QDict< QTextFormat >, QDict< OInputDevice >, QDict< LauncherTab >, QDict< Category >, QDict< QStringList >, QDict< PackageList >, QDict< OBluetoothInterface >, QDict< OContact >, QIntDict< QPixmap >, QIntDict< QCanvasPixmapArray >, QIntDict< QLabel >, QIntDict< QString >, QIntDict< int >, QIntDict< MenuApplet >, QIntDict< AppLnk >, QIntDict< Key >, QIntDict< TVVariant >, QPtrList< QWidget >, QPtrList< QTextDocument >, QPtrList< QCanvasSprite >, QPtrList< KExhaust >, QPtrList< KBit >, QPtrList< QTextCommand >, QPtrList< QTextTableCell >, QPtrList< KMissile >, QPtrList< QFileInfo >, QPtrList< QGDictIterator >, QPtrList< KPowerup >, QPtrList< ColorRange >, QPtrList< Proc >, QPtrList< Type * >, QPtrList< char >, QPtrList< QTextCustomItem >, QPtrList< QCacheItem >, QPtrVector< Lookahead >, QPtrVector< CharClass >, and QPtrVector< State >.

Referenced by QGVector::clear(), QGList::clear(), QGDict::clear(), QGCache::clear(), QGVector::insert(), QGCache::makeRoomFor(), QGVector::remove(), QGList::remove(), QGDict::remove_ascii(), QGDict::remove_int(), QGCache::remove_other(), QGDict::remove_ptr(), QGDict::remove_string(), QGCache::remove_string(), QGList::removeAt(), QGList::removeNode(), QGList::removeRef(), QGList::replaceAt(), and QGVector::resize().

QPtrCollection::Item QPtrCollection::newItem Item  d  )  [protected, virtual]
 

Virtual function that creates a copy of an object that is about to be inserted into the collection.

The default implementation returns the d pointer, i.e. no copy is made.

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.

See also:
deleteItem()

Definition at line 177 of file qptrcollection.cpp.

Referenced by QGList::append(), QGVector::insert(), QGCache::insert_other(), QGCache::insert_string(), QGList::insertAt(), QGDict::look_ascii(), QGDict::look_int(), QGDict::look_ptr(), QGDict::look_string(), QGVector::operator=(), QGList::prepend(), QGVector::QGVector(), and QGList::replaceAt().

void QPtrCollection::setAutoDelete bool  enable  )  [inline]
 

Sets the collection to auto-delete its contents if enable is TRUE and to never delete them if enable is FALSE.

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.

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.

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.

See also:
autoDelete()

Reimplemented in QCList.

Definition at line 53 of file qptrcollection.h.

Referenced by Qt3::QTextCommandHistory::addCommand(), AppIcons::AppIcons(), AppLnkSetPrivate::AppLnkSetPrivate(), MimeType::data(), DataElem::DataElem(), OBackendFactory< T >::Default(), Opie::OBackendFactory< T >::defaultDB(), derefEngine(), OTodoAccessBackendSQL::fillDict(), Win32MakefileGenerator::findLibraries(), UnixMakefileGenerator::findLibraries(), FlatDecoration::FlatDecoration(), ProjectGenerator::init(), MakefileGenerator::init(), Qt3::QStyleSheet::init(), KALedMeter::KALedMeter(), KAsteroidsView::KAsteroidsView(), KeyList::KeyList(), liblist(), QGPluginManager::library(), LiquidStyle::LiquidStyle(), OTodoAccessXML::load(), Opie::OPimTodoAccessXML::load(), OContactAccessBackend_XML::load(), Opie::OPimContactAccessBackend_XML::load(), DateBookDB::loadFile(), ODateBookAccessBackend_XML::loadFile(), Opie::ODateBookAccessBackend_XML::loadFile(), StartMenu::loadMenu(), Opie::OPimTodoAccessBackend::occurrences(), OContactAccessBackend_XML::OContactAccessBackend_XML(), OPackageManager::OPackageManager(), Opie::OPimContactAccessBackend_XML::OPimContactAccessBackend_XML(), PackageManagerSettings::PackageManagerSettings(), ProcessManager::ProcessManager(), Win32MakefileGenerator::processPrlFiles(), UnixMakefileGenerator::processPrlFiles(), MetrowerksMakefileGenerator::processPrlFiles(), QGPluginManager::QGPluginManager(), Qt3::QTextFlow::QTextFlow(), Qt3::QTextFormatCollection::QTextFormatCollection(), Qt3::QTextTable::QTextTable(), QDir::readDirEntries(), KMolCalc::readElstable(), QString::section(), QCList::setAutoDelete(), Qt3::QTextDocument::setRichTextInternal(), StartingAppList::StartingAppList(), TransMenuHandler::TransMenuHandler(), Qt3::QTextFormatCollection::updateKeys(), and VcprojGenerator::writeSubDirs().


Member Data Documentation

bool QPtrCollection::del_item [protected]
 

Definition at line 65 of file qptrcollection.h.

Referenced by QCDict::deleteItem(), QPtrVector< type >::deleteItem(), QPtrList< type >::deleteItem(), QIntDict< type >::deleteItem(), QDict< type >::deleteItem(), QCache< type >::deleteItem(), QAsciiDict< type >::deleteItem(), and QStrList::operator=().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:48:17 2005 for OPIE by  doxygen 1.4.2