• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

WTF

  • kjs
  • wtf
ListRefPtr.h
Go to the documentation of this file.
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 2005 Apple Computer, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#ifndef WTF_ListRefPtr_h
24#define WTF_ListRefPtr_h
25
26#include "RefPtr.h"
27
28namespace WTF {
29
30 // Specialized version of RefPtr desgined for use in singly-linked lists.
31 // Derefs the list iteratively to avoid recursive derefing that can overflow the stack.
32 template <typename T> class ListRefPtr : public RefPtr<T>
33 {
34 public:
35 ListRefPtr() : RefPtr<T>() {}
36 ListRefPtr(T *ptr) : RefPtr<T>(ptr) {}
37 ListRefPtr(const RefPtr<T>& o) : RefPtr<T>(o) {}
38 // see comment in PassRefPtr.h for why this takes const reference
39 template <typename U> ListRefPtr(const PassRefPtr<U>& o) : RefPtr<T>(o) {}
40
41 ~ListRefPtr() {
42 RefPtr<T> reaper = this->release();
43 while (reaper && reaper->refcount() == 1)
44 reaper = reaper->releaseNext(); // implicitly protects reaper->next, then derefs reaper
45 }
46
47 ListRefPtr& operator=(T *optr) { RefPtr<T>::operator=(optr); return *this; }
48 ListRefPtr& operator=(const RefPtr<T>& o) { RefPtr<T>::operator=(o); return *this; }
49 ListRefPtr& operator=(const PassRefPtr<T>& o) { RefPtr<T>::operator=(o); return *this; }
50 template <typename U> ListRefPtr& operator=(const RefPtr<U>& o) { RefPtr<T>::operator=(o); return *this; }
51 template <typename U> ListRefPtr& operator=(const PassRefPtr<U>& o) { RefPtr<T>::operator=(o); return *this; }
52 };
53
54} // namespace WTF
55
56using WTF::ListRefPtr;
57
58#endif // WTF_ListRefPtr_h
59
RefPtr.h
WTF::ListRefPtr
Definition: ListRefPtr.h:33
WTF::ListRefPtr::ListRefPtr
ListRefPtr(const RefPtr< T > &o)
Definition: ListRefPtr.h:37
WTF::ListRefPtr::operator=
ListRefPtr & operator=(T *optr)
Definition: ListRefPtr.h:47
WTF::ListRefPtr::operator=
ListRefPtr & operator=(const PassRefPtr< T > &o)
Definition: ListRefPtr.h:49
WTF::ListRefPtr::ListRefPtr
ListRefPtr(T *ptr)
Definition: ListRefPtr.h:36
WTF::ListRefPtr::ListRefPtr
ListRefPtr(const PassRefPtr< U > &o)
Definition: ListRefPtr.h:39
WTF::ListRefPtr::operator=
ListRefPtr & operator=(const RefPtr< U > &o)
Definition: ListRefPtr.h:50
WTF::ListRefPtr::~ListRefPtr
~ListRefPtr()
Definition: ListRefPtr.h:41
WTF::ListRefPtr::operator=
ListRefPtr & operator=(const RefPtr< T > &o)
Definition: ListRefPtr.h:48
WTF::ListRefPtr::operator=
ListRefPtr & operator=(const PassRefPtr< U > &o)
Definition: ListRefPtr.h:51
WTF::ListRefPtr::ListRefPtr
ListRefPtr()
Definition: ListRefPtr.h:35
WTF::PassRefPtr
Definition: PassRefPtr.h:33
WTF::RefPtr
Definition: RefPtr.h:37
WTF::RefPtr::release
PassRefPtr< T > release()
Definition: RefPtr.h:59
WTF::RefPtr::operator=
RefPtr & operator=(const RefPtr &)
Definition: RefPtr.h:89
WTF
Definition: ASCIICType.h:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

WTF

Skip menu "WTF"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal