1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtCore module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QSHAREDPOINTER_H
43 #define QSHAREDPOINTER_H
45 #include <QtCore/qglobal.h>
46 #include <QtCore/qatomic.h>
47 #include <QtCore/qshareddata.h>
50 # include <QtCore/qsharedpointer_impl.h>
58 // These classes are here to fool qdoc into generating a better documentation
64 // basic accessor functions
67 operator bool() const;
68 bool operator!() const;
70 T *operator ->() const;
74 explicit QSharedPointer(T *ptr);
75 QSharedPointer(T *ptr, Deleter d);
76 QSharedPointer(const QSharedPointer<T> &other);
77 QSharedPointer(const QWeakPointer<T> &other);
81 QSharedPointer<T> &operator=(const QSharedPointer<T> &other);
82 QSharedPointer<T> &operator=(const QWeakPointer<T> &other);
84 QWeakPointer<T> toWeakRef() const;
90 template <typename Deleter>
91 void reset(T *t, Deleter deleter);
94 template <class X> QSharedPointer<X> staticCast() const;
95 template <class X> QSharedPointer<X> dynamicCast() const;
96 template <class X> QSharedPointer<X> constCast() const;
97 template <class X> QSharedPointer<X> objectCast() const;
104 // basic accessor functions
106 operator bool() const;
107 bool operator!() const;
111 QWeakPointer(const QWeakPointer<T> &other);
112 QWeakPointer(const QSharedPointer<T> &other);
116 QWeakPointer<T> operator=(const QWeakPointer<T> &other);
117 QWeakPointer<T> operator=(const QSharedPointer<T> &other);
119 QWeakPointer(const QObject *other);
120 QWeakPointer<T> operator=(const QObject *other);
125 QSharedPointer<T> toStrongRef() const;
128 template<class T, class X> bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2);
129 template<class T, class X> bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2);
130 template<class T, class X> bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2);
131 template<class T, class X> bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2);
132 template<class T, class X> bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2);
133 template<class T, class X> bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2);
134 template<class T, class X> bool operator==(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2);
135 template<class T, class X> bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2);
136 template<class T, class X> bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
137 template<class T, class X> bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
139 template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &other);
140 template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other);
141 template <class X, class T> QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &src);
142 template <class X, class T> QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer<T> &src);
143 template <class X, class T> QSharedPointer<X> qSharedPointerConstCast(const QSharedPointer<T> &src);
144 template <class X, class T> QSharedPointer<X> qSharedPointerConstCast(const QWeakPointer<T> &src);
145 template <class X, class T> QSharedPointer<X> qSharedPointerObjectCast(const QSharedPointer<T> &src);
146 template <class X, class T> QSharedPointer<X> qSharedPointerObjectCast(const QWeakPointer<T> &src);
148 template <class X, class T> QWeakPointer<X> qWeakPointerCast(const QWeakPointer<T> &src);
156 #endif // QSHAREDPOINTER_H