1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2015 The Qt Company Ltd. |
4 | ** Contact: http://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtOrganizer module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL21$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 2.1 or version 3 as published by the Free |
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
22 | ** following information to ensure the GNU Lesser General Public License |
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
25 | ** |
26 | ** As a special exception, The Qt Company gives you certain additional |
27 | ** rights. These rights are described in The Qt Company LGPL Exception |
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
29 | ** |
30 | ** $QT_END_LICENSE$ |
31 | ** |
32 | ****************************************************************************/ |
33 | |
34 | #ifndef QORGANIZERITEMFILTER_P_H |
35 | #define QORGANIZERITEMFILTER_P_H |
36 | |
37 | // |
38 | // W A R N I N G |
39 | // ------------- |
40 | // |
41 | // This file is not part of the Qt API. It exists purely as an |
42 | // implementation detail. This header file may change from version to |
43 | // version without notice, or even be removed. |
44 | // |
45 | // We mean it. |
46 | // |
47 | |
48 | #ifndef QT_NO_DATASTREAM |
49 | #include <QtCore/qdatastream.h> |
50 | #endif |
51 | #ifndef QT_NO_DEBUG_STREAM |
52 | #include <QtCore/qdebug.h> |
53 | #endif |
54 | #include <QtCore/qlist.h> |
55 | #include <QtCore/qset.h> |
56 | #include <QtCore/qshareddata.h> |
57 | |
58 | #include <QtOrganizer/qorganizeritemfilter.h> |
59 | |
60 | /* Boiler plate code */ |
61 | #define Q_IMPLEMENT_ORGANIZERITEMFILTER_PRIVATE(Class) \ |
62 | Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \ |
63 | const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); } \ |
64 | Class::Class(const QOrganizerItemFilter& other) : QOrganizerItemFilter() { Class##Private::copyIfPossible(d_ptr, other); } |
65 | |
66 | #define Q_IMPLEMENT_ORGANIZERITEMFILTER_VIRTUALCTORS(Class, Type) \ |
67 | QOrganizerItemFilterPrivate* clone() const { return new Class##Private(*this); } \ |
68 | virtual QOrganizerItemFilter::FilterType type() const {return Type;} \ |
69 | static void copyIfPossible(QSharedDataPointer<QOrganizerItemFilterPrivate>& d_ptr, const QOrganizerItemFilter& other) \ |
70 | { \ |
71 | if (other.type() == Type) \ |
72 | d_ptr = extract_d(other); \ |
73 | else \ |
74 | d_ptr = new Class##Private; \ |
75 | } |
76 | |
77 | QT_BEGIN_NAMESPACE_ORGANIZER |
78 | |
79 | class QOrganizerItemFilterPrivate : public QSharedData |
80 | { |
81 | public: |
82 | QOrganizerItemFilterPrivate() |
83 | { |
84 | } |
85 | |
86 | virtual ~QOrganizerItemFilterPrivate() |
87 | { |
88 | } |
89 | |
90 | virtual bool compare(const QOrganizerItemFilterPrivate *other) const = 0; |
91 | |
92 | #ifndef QT_NO_DATASTREAM |
93 | virtual QDataStream &outputToStream(QDataStream &stream, quint8 formatVersion) const = 0; |
94 | virtual QDataStream &inputFromStream(QDataStream &stream, quint8 formatVersion) = 0; |
95 | #endif // QT_NO_DATASTREAM |
96 | |
97 | #ifndef QT_NO_DEBUG_STREAM |
98 | virtual QDebug &debugStreamOut(QDebug &dbg) const = 0; |
99 | #endif // QT_NO_DEBUG_STREAM |
100 | |
101 | virtual QOrganizerItemFilterPrivate *clone() const = 0; |
102 | virtual QOrganizerItemFilter::FilterType type() const = 0; |
103 | |
104 | /* Helper functions for C++ protection rules */ |
105 | static const QSharedDataPointer<QOrganizerItemFilterPrivate> &(const QOrganizerItemFilter &other) { return other.d_ptr; } |
106 | }; |
107 | QT_END_NAMESPACE_ORGANIZER |
108 | |
109 | QT_BEGIN_NAMESPACE |
110 | #if defined(Q_CC_MWERKS) |
111 | // This results in multiple symbol definition errors on all other compilers |
112 | // but not having a definition here results in an attempt to use the unspecialized |
113 | // clone (which fails because of the pure virtuals above) |
114 | template<> QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemFilterPrivate) *QSharedDataPointer<QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemFilterPrivate)>::clone() |
115 | { |
116 | return d->clone(); |
117 | } |
118 | #else |
119 | template<> QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemFilterPrivate) *QSharedDataPointer<QTORGANIZER_PREPEND_NAMESPACE(QOrganizerItemFilterPrivate)>::clone(); |
120 | #endif |
121 | QT_END_NAMESPACE |
122 | |
123 | #endif // QORGANIZERITEMFILTER_P_H |
124 | |