1 /*
2  *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 #ifndef KISTYPES_H_
19 #define KISTYPES_H_
20 
21 #include <QVector>
22 #include <QPoint>
23 #include <QList>
24 
25 #include "kritaimage_export.h"
26 
27 template<class T>
28 class KisWeakSharedPtr;
29 template<class T>
30 class KisSharedPtr;
31 
32 template<class T> class QSharedPointer;
33 template<class T> class QWeakPointer;
34 
35 template <class T>
qHash(KisSharedPtr<T> ptr)36 uint qHash(KisSharedPtr<T> ptr) {
37     return qHash(ptr.data());
38 }
39 
40 template <class T>
qHash(KisWeakSharedPtr<T> ptr)41 uint qHash(KisWeakSharedPtr<T> ptr) {
42     return qHash(ptr.data());
43 }
44 
45 /**
46  * Define lots of shared pointer versions of Krita classes.
47  * Shared pointer classes have the advantage of near automatic
48  * memory management (but beware of circular references)
49  * These types should never be passed by reference,
50  * because that will mess up their reference counter.
51  *
52  * An example of the naming pattern used:
53  *
54  * KisPaintDeviceSP is a KisSharedPtr of KisPaintDevice
55  * KisPaintDeviceWSP is a KisWeakSharedPtr of KisPaintDevice
56  * vKisPaintDeviceSP is a QVector of KisPaintDeviceSP
57  * vKisPaintDeviceSP_it is an iterator of vKisPaintDeviceSP
58  *
59  */
60 class KisImage;
61 typedef KisSharedPtr<KisImage> KisImageSP;
62 typedef KisWeakSharedPtr<KisImage> KisImageWSP;
63 
64 class KisPaintDevice;
65 typedef KisSharedPtr<KisPaintDevice> KisPaintDeviceSP;
66 typedef KisWeakSharedPtr<KisPaintDevice> KisPaintDeviceWSP;
67 typedef QVector<KisPaintDeviceSP> vKisPaintDeviceSP;
68 typedef vKisPaintDeviceSP::iterator vKisPaintDeviceSP_it;
69 
70 class KisFixedPaintDevice;
71 typedef KisSharedPtr<KisFixedPaintDevice> KisFixedPaintDeviceSP;
72 
73 class KisMask;
74 typedef KisSharedPtr<KisMask> KisMaskSP;
75 typedef KisWeakSharedPtr<KisMask> KisMaskWSP;
76 
77 class KisNode;
78 typedef KisSharedPtr<KisNode> KisNodeSP;
79 typedef KisWeakSharedPtr<KisNode> KisNodeWSP;
80 typedef QVector<KisNodeSP> vKisNodeSP;
81 typedef vKisNodeSP::iterator vKisNodeSP_it;
82 typedef vKisNodeSP::const_iterator vKisNodeSP_cit;
83 
84 class KisBaseNode;
85 typedef KisSharedPtr<KisBaseNode> KisBaseNodeSP;
86 typedef KisWeakSharedPtr<KisBaseNode> KisBaseNodeWSP;
87 
88 class KisEffectMask;
89 typedef KisSharedPtr<KisEffectMask> KisEffectMaskSP;
90 typedef KisWeakSharedPtr<KisEffectMask> KisEffectMaskWSP;
91 
92 class KisFilterMask;
93 typedef KisSharedPtr<KisFilterMask> KisFilterMaskSP;
94 typedef KisWeakSharedPtr<KisFilterMask> KisFilterMaskWSP;
95 
96 class KisTransformMask;
97 typedef KisSharedPtr<KisTransformMask> KisTransformMaskSP;
98 typedef KisWeakSharedPtr<KisTransformMask> KisTransformMaskWSP;
99 
100 class KisTransformMaskParamsInterface;
101 typedef QSharedPointer<KisTransformMaskParamsInterface> KisTransformMaskParamsInterfaceSP;
102 typedef QWeakPointer<KisTransformMaskParamsInterface> KisTransformMaskParamsInterfaceWSP;
103 
104 class KisTransparencyMask;
105 typedef KisSharedPtr<KisTransparencyMask> KisTransparencyMaskSP;
106 typedef KisWeakSharedPtr<KisTransparencyMask> KisTransparencyMaskWSP;
107 
108 class KisColorizeMask;
109 typedef KisSharedPtr<KisColorizeMask> KisColorizeMaskSP;
110 typedef KisWeakSharedPtr<KisColorizeMask> KisColorizeMaskWSP;
111 
112 class KisLayer;
113 typedef KisSharedPtr<KisLayer> KisLayerSP;
114 typedef KisWeakSharedPtr<KisLayer> KisLayerWSP;
115 
116 class KisShapeLayer;
117 typedef KisSharedPtr<KisShapeLayer> KisShapeLayerSP;
118 
119 class KisPaintLayer;
120 typedef KisSharedPtr<KisPaintLayer> KisPaintLayerSP;
121 
122 class KisAdjustmentLayer;
123 typedef KisSharedPtr<KisAdjustmentLayer> KisAdjustmentLayerSP;
124 
125 class KisGeneratorLayer;
126 typedef KisSharedPtr<KisGeneratorLayer> KisGeneratorLayerSP;
127 
128 class KisCloneLayer;
129 typedef KisSharedPtr<KisCloneLayer> KisCloneLayerSP;
130 typedef KisWeakSharedPtr<KisCloneLayer> KisCloneLayerWSP;
131 
132 class KisGroupLayer;
133 typedef KisSharedPtr<KisGroupLayer> KisGroupLayerSP;
134 typedef KisWeakSharedPtr<KisGroupLayer> KisGroupLayerWSP;
135 
136 class KisFileLayer;
137 typedef KisSharedPtr<KisFileLayer> KisFileLayerSP;
138 typedef KisWeakSharedPtr<KisFileLayer> KisFileLayerWSP;
139 
140 class KisSelection;
141 typedef KisSharedPtr<KisSelection> KisSelectionSP;
142 typedef KisWeakSharedPtr<KisSelection> KisSelectionWSP;
143 
144 class KisSelectionComponent;
145 typedef KisSharedPtr<KisSelectionComponent> KisSelectionComponentSP;
146 
147 class KisSelectionMask;
148 typedef KisSharedPtr<KisSelectionMask> KisSelectionMaskSP;
149 
150 class KisPixelSelection;
151 typedef KisSharedPtr<KisPixelSelection> KisPixelSelectionSP;
152 
153 class KisHistogram;
154 typedef KisSharedPtr<KisHistogram> KisHistogramSP;
155 
156 typedef QVector<QPoint> vKisSegments;
157 
158 class KisFilter;
159 typedef KisSharedPtr<KisFilter> KisFilterSP;
160 
161 class KisLayerStyleFilter;
162 typedef KisSharedPtr<KisLayerStyleFilter> KisLayerStyleFilterSP;
163 
164 class KisGenerator;
165 typedef KisSharedPtr<KisGenerator> KisGeneratorSP;
166 
167 class KisConvolutionKernel;
168 typedef KisSharedPtr<KisConvolutionKernel> KisConvolutionKernelSP;
169 
170 class KisAnnotation;
171 typedef KisSharedPtr<KisAnnotation> KisAnnotationSP;
172 typedef QVector<KisAnnotationSP> vKisAnnotationSP;
173 typedef vKisAnnotationSP::iterator vKisAnnotationSP_it;
174 typedef vKisAnnotationSP::const_iterator vKisAnnotationSP_cit;
175 
176 class KisAnimationFrameCache;
177 typedef KisSharedPtr<KisAnimationFrameCache> KisAnimationFrameCacheSP;
178 typedef KisWeakSharedPtr<KisAnimationFrameCache> KisAnimationFrameCacheWSP;
179 
180 class KisPaintingAssistant;
181 typedef QSharedPointer<KisPaintingAssistant> KisPaintingAssistantSP;
182 typedef QWeakPointer<KisPaintingAssistant> KisPaintingAssistantWSP;
183 
184 class KisReferenceImage;
185 typedef QSharedPointer<KisReferenceImage> KisReferenceImageSP;
186 typedef QWeakPointer<KisReferenceImage> KisReferenceImageWSP;
187 
188 // Repeat iterators
189 class KisHLineIterator2;
190 template<class T> class KisRepeatHLineIteratorPixelBase;
191 typedef KisRepeatHLineIteratorPixelBase< KisHLineIterator2 > KisRepeatHLineConstIteratorNG;
192 typedef KisSharedPtr<KisRepeatHLineConstIteratorNG> KisRepeatHLineConstIteratorSP;
193 
194 class KisVLineIterator2;
195 template<class T> class KisRepeatVLineIteratorPixelBase;
196 typedef KisRepeatVLineIteratorPixelBase< KisVLineIterator2 > KisRepeatVLineConstIteratorNG;
197 typedef KisSharedPtr<KisRepeatVLineConstIteratorNG> KisRepeatVLineConstIteratorSP;
198 
199 
200 // NG Iterators
201 class KisHLineIteratorNG;
202 typedef KisSharedPtr<KisHLineIteratorNG> KisHLineIteratorSP;
203 
204 class KisHLineConstIteratorNG;
205 typedef KisSharedPtr<KisHLineConstIteratorNG> KisHLineConstIteratorSP;
206 
207 class KisVLineIteratorNG;
208 typedef KisSharedPtr<KisVLineIteratorNG> KisVLineIteratorSP;
209 
210 class KisVLineConstIteratorNG;
211 typedef KisSharedPtr<KisVLineConstIteratorNG> KisVLineConstIteratorSP;
212 
213 class KisRandomConstAccessorNG;
214 typedef KisSharedPtr<KisRandomConstAccessorNG> KisRandomConstAccessorSP;
215 
216 class KisRandomAccessorNG;
217 typedef KisSharedPtr<KisRandomAccessorNG> KisRandomAccessorSP;
218 
219 class KisRandomSubAccessor;
220 typedef KisSharedPtr<KisRandomSubAccessor> KisRandomSubAccessorSP;
221 
222 // Things
223 
224 typedef QVector<QPointF> vQPointF;
225 
226 class KisPaintOpPreset;
227 typedef KisSharedPtr<KisPaintOpPreset> KisPaintOpPresetSP;
228 typedef KisWeakSharedPtr<KisPaintOpPreset> KisPaintOpPresetWSP;
229 
230 template <typename T>
231 class KisPinnedSharedPtr;
232 
233 class KisPaintOpSettings;
234 typedef KisPinnedSharedPtr<KisPaintOpSettings> KisPaintOpSettingsSP;
235 
236 template <typename T>
237 class KisRestrictedSharedPtr;
238 typedef KisRestrictedSharedPtr<KisPaintOpSettings> KisPaintOpSettingsRestrictedSP;
239 
240 class KisPaintOp;
241 typedef KisSharedPtr<KisPaintOp> KisPaintOpSP;
242 
243 class KoID;
244 typedef QList<KoID> KoIDList;
245 
246 class KoUpdater;
247 template<class T> class QPointer;
248 typedef QPointer<KoUpdater> KoUpdaterPtr;
249 
250 class KisProcessingVisitor;
251 typedef KisSharedPtr<KisProcessingVisitor> KisProcessingVisitorSP;
252 
253 class KUndo2Command;
254 typedef QSharedPointer<KUndo2Command> KUndo2CommandSP;
255 
256 typedef QList<KisNodeSP> KisNodeList;
257 typedef QSharedPointer<KisNodeList> KisNodeListSP;
258 
259 typedef QList<KisPaintDeviceSP> KisPaintDeviceList;
260 
261 class KisStroke;
262 typedef QSharedPointer<KisStroke> KisStrokeSP;
263 typedef QWeakPointer<KisStroke> KisStrokeWSP;
264 typedef KisStrokeWSP KisStrokeId;
265 
266 class KisFilterConfiguration;
267 typedef KisPinnedSharedPtr<KisFilterConfiguration> KisFilterConfigurationSP;
268 
269 class KisPropertiesConfiguration;
270 typedef KisPinnedSharedPtr<KisPropertiesConfiguration> KisPropertiesConfigurationSP;
271 
272 class KisLockedProperties;
273 typedef KisSharedPtr<KisLockedProperties> KisLockedPropertiesSP;
274 
275 class KisProjectionUpdatesFilter;
276 typedef QSharedPointer<KisProjectionUpdatesFilter> KisProjectionUpdatesFilterSP;
277 using KisProjectionUpdatesFilterCookie = void*;
278 
279 class KisAbstractProjectionPlane;
280 typedef QSharedPointer<KisAbstractProjectionPlane> KisAbstractProjectionPlaneSP;
281 typedef QWeakPointer<KisAbstractProjectionPlane> KisAbstractProjectionPlaneWSP;
282 
283 class KisProjectionLeaf;
284 typedef QSharedPointer<KisProjectionLeaf> KisProjectionLeafSP;
285 typedef QWeakPointer<KisProjectionLeaf> KisProjectionLeafWSP;
286 
287 class KisKeyframe;
288 typedef QSharedPointer<KisKeyframe> KisKeyframeSP;
289 typedef QWeakPointer<KisKeyframe> KisKeyframeWSP;
290 
291 class KisFilterChain;
292 typedef KisSharedPtr<KisFilterChain> KisFilterChainSP;
293 
294 class KisProofingConfiguration;
295 typedef QSharedPointer<KisProofingConfiguration> KisProofingConfigurationSP;
296 typedef QWeakPointer<KisProofingConfiguration> KisProofingConfigurationWSP;
297 
298 class KisLayerComposition;
299 typedef QSharedPointer<KisLayerComposition> KisLayerCompositionSP;
300 typedef QWeakPointer<KisLayerComposition> KisLayerCompositionWSP;
301 
302 class KisMirrorAxis;
303 typedef KisSharedPtr<KisMirrorAxis> KisMirrorAxisSP;
304 typedef KisWeakSharedPtr<KisMirrorAxis> KisMirrorAxisWSP;
305 
306 
307 #include <QSharedPointer>
308 #include <QWeakPointer>
309 #include <kis_shared_ptr.h>
310 #include <kis_restricted_shared_ptr.h>
311 #include <kis_pinned_shared_ptr.h>
312 
313 #endif // KISTYPES_H_
314 
315