File indexing completed on 2024-12-01 09:59:00
0001 /* 0002 This file is part of the syndication library 0003 SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef SYNDICATION_RDF_NODEVISITOR_H 0009 #define SYNDICATION_RDF_NODEVISITOR_H 0010 0011 #include <QSharedPointer> 0012 0013 #include <syndication_export.h> 0014 0015 namespace Syndication 0016 { 0017 namespace RDF 0018 { 0019 //@cond PRIVATE 0020 class Literal; 0021 typedef QSharedPointer<Literal> LiteralPtr; 0022 class Node; 0023 typedef QSharedPointer<Node> NodePtr; 0024 class Property; 0025 typedef QSharedPointer<Property> PropertyPtr; 0026 class Resource; 0027 typedef QSharedPointer<Resource> ResourcePtr; 0028 class Sequence; 0029 typedef QSharedPointer<Sequence> SequencePtr; 0030 //@endcond 0031 0032 /** 0033 * Visitor interface, following the Visitor design pattern. Use this if you 0034 * want to process nodes and the way how to handle the nodes depends 0035 * on it's concrete type (e.g. Resource or Literal). 0036 * 0037 * TODO: insert code example 0038 * 0039 * @author Frank Osterfeld 0040 */ 0041 class SYNDICATION_EXPORT NodeVisitor // krazy:exclude=dpointer 0042 { 0043 public: 0044 /** 0045 * destructor 0046 */ 0047 virtual ~NodeVisitor(); 0048 0049 /** 0050 * call this method to handle a node. Depending on the concrete type 0051 * of the node, a specialized visit method is called. 0052 * 0053 * @param node the node to process 0054 */ 0055 virtual void visit(NodePtr node); 0056 0057 /** 0058 * reimplement this method to handle literals. 0059 * 0060 * @param item the literal to visit 0061 * @return whether the visitor handled the literal. 0062 * Reimplementations of this method must return @p true. 0063 */ 0064 virtual bool visitLiteral(LiteralPtr); 0065 0066 /** 0067 * reimplement this method to handle nodes that weren't handled 0068 * by the more specific method. 0069 * 0070 * @param node the node to visit 0071 * @return whether the visitor handled the node. 0072 * Reimplementations of this method must return @p true. 0073 */ 0074 virtual bool visitNode(NodePtr node); 0075 0076 /** 0077 * reimplement this method to handle properties. 0078 * 0079 * @param property the property to visit 0080 * @return whether the visitor handled the property. 0081 * Reimplementations of this method must return @p true. 0082 */ 0083 virtual bool visitProperty(PropertyPtr property); 0084 0085 /** 0086 * reimplement this method to handle resources. 0087 * 0088 * @param resource the resource to visit 0089 * @return whether the visitor handled the resource. 0090 * Reimplementations of this method must return @p true. 0091 */ 0092 virtual bool visitResource(ResourcePtr resource); 0093 0094 /** 0095 * reimplement this method to handle sequences. 0096 * 0097 * @param seq the sequence to visit 0098 * @return whether the visitor handled the sequence. 0099 * Reimplementations of this method must return @p true. 0100 */ 0101 virtual bool visitSequence(SequencePtr seq); 0102 }; 0103 0104 } // namespace RDF 0105 } // namespace Syndication 0106 0107 #endif // SYNDICATION_RDF_NODEVISITOR_H