File indexing completed on 2024-05-12 15:58:29

0001 /*
0002  *  SPDX-FileCopyrightText: 2005 C. Boemann <cbo@boemann.dk>
0003  *  SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 #ifndef KIS_NODE_VISITOR_H_
0008 #define KIS_NODE_VISITOR_H_
0009 
0010 #include "kritaimage_export.h"
0011 
0012 class KisNode;
0013 class KisPaintLayer;
0014 class KisGroupLayer;
0015 class KisAdjustmentLayer;
0016 class KisExternalLayer;
0017 class KisCloneLayer;
0018 class KisFilterMask;
0019 class KisTransparencyMask;
0020 class KisSelectionMask;
0021 class KisGeneratorLayer;
0022 class KisTransformMask;
0023 class KisColorizeMask;
0024 
0025 
0026 class KRITAIMAGE_EXPORT KisNodeVisitor
0027 {
0028 public:
0029     KisNodeVisitor() {}
0030     virtual ~KisNodeVisitor() {}
0031 
0032 public:
0033     virtual bool visit(KisNode *node) = 0;
0034 
0035     virtual bool visit(KisPaintLayer *layer) = 0;
0036 
0037     virtual bool visit(KisGroupLayer *layer) = 0;
0038 
0039     virtual bool visit(KisAdjustmentLayer *layer) = 0;
0040 
0041     virtual bool visit(KisExternalLayer *layer) = 0;
0042 
0043     virtual bool visit(KisGeneratorLayer *layer) = 0;
0044 
0045     virtual bool visit(KisCloneLayer *layer) = 0;
0046 
0047     virtual bool visit(KisFilterMask *mask) = 0;
0048 
0049     virtual bool visit(KisTransformMask *mask) = 0;
0050 
0051     virtual bool visit(KisTransparencyMask *mask) = 0;
0052 
0053     virtual bool visit(KisSelectionMask *mask) = 0;
0054 
0055     virtual bool visit(KisColorizeMask *mask) = 0;
0056 
0057 protected:
0058 
0059     /**
0060      * Visit all child nodes of the given node starting with the first one until one node returns
0061      * false. Then visitAll returns false, otherwise true.
0062      *
0063      * @param node the parent node whose children will be visited
0064      * @param breakOnFail break if one of the children returns false on accept
0065      * @return true if none of the childnodes returns false on
0066      * accepting the visitor.
0067      */
0068     bool visitAll(KisNode * node, bool breakOnFail = false);
0069 
0070     /**
0071      * Visit all child nodes of the given node starting with the last one until one node returns
0072      * false. Then visitAll returns false, otherwise true.
0073      *
0074      * @param node the parent node whose children will be visited
0075      * @param breakOnFail break if one of the children returns false on accept
0076      * @return true if none of the childnodes returns false on
0077      * accepting the visitor.
0078      */
0079     bool visitAllInverse(KisNode * node, bool breakOnFail = false);
0080 };
0081 
0082 
0083 #endif // KIS_ NODE_VISITOR_H_
0084