1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
// Copyright (C) 2025 Jarek Kobus
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QCONDITIONAL_H
#define QCONDITIONAL_H
#include <QtTaskTree/qttasktreeglobal.h>
#include <QtTaskTree/qtasktree.h>
#include <QtCore/QSharedData>
QT_BEGIN_NAMESPACE
namespace QtTaskTree {
class ConditionData;
class ElseIfItem;
class ElseItem;
class Then;
class ThenItem;
class ElsePrivate;
class ElseIfPrivate;
class IfPrivate;
class ThenPrivate;
class ElseIfItemPrivate;
class ElseItemPrivate;
class ThenItemPrivate;
class If final
{
public:
Q_TASKTREE_EXPORT explicit If(const ExecutableItem &condition);
template <typename Handler,
std::enable_if_t<!std::is_base_of_v<ExecutableItem, std::decay_t<Handler>>, bool> = true>
explicit If(Handler &&handler) : If(QSyncTask(std::forward<Handler>(handler))) {}
Q_TASKTREE_EXPORT ~If();
Q_TASKTREE_EXPORT If(const If &other);
Q_TASKTREE_EXPORT If(If &&other) noexcept;
Q_TASKTREE_EXPORT If &operator=(const If &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(If)
void swap(If &other) noexcept { d.swap(other.d); }
private:
Q_TASKTREE_EXPORT friend ThenItem operator>>(const If &ifItem, const Then &thenItem);
friend class ThenItem;
ExecutableItem condition() const;
QExplicitlySharedDataPointer<IfPrivate> d;
};
class ElseIf final
{
public:
Q_TASKTREE_EXPORT explicit ElseIf(const ExecutableItem &condition);
template <typename Handler,
std::enable_if_t<!std::is_base_of_v<ExecutableItem, std::decay_t<Handler>>, bool> = true>
explicit ElseIf(Handler &&handler) : ElseIf(QSyncTask(std::forward<Handler>(handler))) {}
Q_TASKTREE_EXPORT ~ElseIf();
Q_TASKTREE_EXPORT ElseIf(const ElseIf &other);
Q_TASKTREE_EXPORT ElseIf(ElseIf &&other) noexcept;
Q_TASKTREE_EXPORT ElseIf &operator=(const ElseIf &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(ElseIf)
void swap(ElseIf &other) noexcept { d.swap(other.d); }
private:
friend class ElseIfItem;
ExecutableItem condition() const;
QExplicitlySharedDataPointer<ElseIfPrivate> d;
};
class Else final
{
public:
Q_TASKTREE_EXPORT explicit Else(const GroupItems &children);
Q_TASKTREE_EXPORT explicit Else(std::initializer_list<GroupItem> children);
Q_TASKTREE_EXPORT ~Else();
Q_TASKTREE_EXPORT Else(const Else &other);
Q_TASKTREE_EXPORT Else(Else &&other) noexcept;
Q_TASKTREE_EXPORT Else &operator=(const Else &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(Else)
void swap(Else &other) noexcept { d.swap(other.d); }
private:
friend class ElseItem;
Group body() const;
QExplicitlySharedDataPointer<ElsePrivate> d;
};
class Then final
{
public:
Q_TASKTREE_EXPORT explicit Then(const GroupItems &children);
Q_TASKTREE_EXPORT explicit Then(std::initializer_list<GroupItem> children);
Q_TASKTREE_EXPORT ~Then();
Q_TASKTREE_EXPORT Then(const Then &other);
Q_TASKTREE_EXPORT Then(Then &&other) noexcept;
Q_TASKTREE_EXPORT Then &operator=(const Then &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(Then)
void swap(Then &other) noexcept { d.swap(other.d); }
private:
friend class ThenItem;
Group body() const;
QExplicitlySharedDataPointer<ThenPrivate> d;
};
class ThenItem final
{
public:
Q_TASKTREE_EXPORT operator ExecutableItem() const;
Q_TASKTREE_EXPORT ~ThenItem();
Q_TASKTREE_EXPORT ThenItem(const ThenItem &other);
Q_TASKTREE_EXPORT ThenItem(ThenItem &&other) noexcept;
Q_TASKTREE_EXPORT ThenItem &operator=(const ThenItem &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(ThenItem)
void swap(ThenItem &other) noexcept { d.swap(other.d); }
private:
ThenItem(const If &ifItem, const Then &thenItem);
ThenItem(const ElseIfItem &elseIfItem, const Then &thenItem);
Q_TASKTREE_EXPORT friend ElseItem operator>>(const ThenItem &thenItem, const Else &elseItem);
Q_TASKTREE_EXPORT friend ElseIfItem operator>>(const ThenItem &thenItem, const ElseIf &elseIfItem);
Q_TASKTREE_EXPORT friend ThenItem operator>>(const If &ifItem, const Then &thenItem);
Q_TASKTREE_EXPORT friend ThenItem operator>>(const ElseIfItem &elseIfItem, const Then &thenItem);
friend class ElseItem;
friend class ElseIfItem;
QList<ConditionData> conditions() const;
QExplicitlySharedDataPointer<ThenItemPrivate> d;
};
class ElseItem final
{
public:
Q_TASKTREE_EXPORT operator ExecutableItem() const;
Q_TASKTREE_EXPORT ~ElseItem();
Q_TASKTREE_EXPORT ElseItem(const ElseItem &other);
Q_TASKTREE_EXPORT ElseItem(ElseItem &&other) noexcept;
Q_TASKTREE_EXPORT ElseItem &operator=(const ElseItem &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(ElseItem)
void swap(ElseItem &other) noexcept { d.swap(other.d); }
private:
ElseItem(const ThenItem &thenItem, const Else &elseItem);
Q_TASKTREE_EXPORT friend ElseItem operator>>(const ThenItem &thenItem, const Else &elseItem);
QList<ConditionData> conditions() const;
QExplicitlySharedDataPointer<ElseItemPrivate> d;
};
class ElseIfItem final
{
public:
Q_TASKTREE_EXPORT ~ElseIfItem();
Q_TASKTREE_EXPORT ElseIfItem(const ElseIfItem &other);
Q_TASKTREE_EXPORT ElseIfItem(ElseIfItem &&other) noexcept;
Q_TASKTREE_EXPORT ElseIfItem &operator=(const ElseIfItem &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(ElseIfItem)
void swap(ElseIfItem &other) noexcept { d.swap(other.d); }
private:
ElseIfItem(const ThenItem &thenItem, const ElseIf &elseIfItem);
Q_TASKTREE_EXPORT friend ThenItem operator>>(const ElseIfItem &elseIfItem, const Then &thenItem);
Q_TASKTREE_EXPORT friend ElseIfItem operator>>(const ThenItem &thenItem, const ElseIf &elseIfItem);
friend class ThenItem;
QList<ConditionData> conditions() const;
ExecutableItem nextCondition() const;
QExplicitlySharedDataPointer<ElseIfItemPrivate> d;
};
Q_TASKTREE_EXPORT ThenItem operator>>(const If &ifItem, const Then &thenItem);
Q_TASKTREE_EXPORT ElseIfItem operator>>(const ThenItem &thenItem, const ElseIf &elseIfItem);
Q_TASKTREE_EXPORT ElseItem operator>>(const ThenItem &thenItem, const Else &elseItem);
Q_TASKTREE_EXPORT ThenItem operator>>(const ElseIfItem &elseIfItem, const Then &thenItem);
} // namespace QtTaskTree
QT_END_NAMESPACE
#endif // QCONDITIONAL_H
|