File indexing completed on 2023-09-24 04:15:35
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_NODE_H 0009 #define SYNDICATION_RDF_NODE_H 0010 0011 #include <QSharedPointer> 0012 #include <QString> 0013 #include <syndication_export.h> 0014 0015 namespace Syndication 0016 { 0017 namespace RDF 0018 { 0019 class Model; 0020 class Node; 0021 class NodeVisitor; 0022 //@cond PRIVATE 0023 typedef QSharedPointer<Node> NodePtr; 0024 //@endcond 0025 0026 /** 0027 * an RDF node, abstract baseclass for all RDF node types, like resources and 0028 * literals 0029 */ 0030 class SYNDICATION_EXPORT Node 0031 { 0032 public: 0033 /** 0034 * destructor 0035 */ 0036 virtual ~Node(); 0037 0038 /** 0039 * Used by visitors for double dispatch. See NodeVisitor 0040 * for more information. 0041 * @param visitor the visitor calling the method 0042 * @param ptr a shared pointer object for this node 0043 */ 0044 virtual void accept(NodeVisitor *visitor, NodePtr ptr); 0045 0046 /** 0047 * checks whether two nodes are equal. The meaning of equality 0048 * is defined per subclass (e.g. equality of URIs, IDs etc.) 0049 * 0050 * @param other the node to compare to 0051 */ 0052 virtual bool operator==(const Node &other) const = 0; 0053 0054 /** 0055 * returns a copy of the object. Must be implemented 0056 * by subclasses to return a copy using the concrete 0057 * type 0058 */ 0059 virtual Node *clone() const = 0; 0060 0061 /** 0062 * returns whether this node is a null node 0063 */ 0064 virtual bool isNull() const = 0; 0065 0066 /** 0067 * returns whether this node is a resource 0068 */ 0069 virtual bool isResource() const = 0; 0070 0071 /** 0072 * returns whether this node is a property 0073 */ 0074 virtual bool isProperty() const = 0; 0075 0076 /** 0077 * returns whether this node is a literal 0078 */ 0079 virtual bool isLiteral() const = 0; 0080 0081 /** 0082 * returns whether this node is an RDF sequence 0083 */ 0084 virtual bool isSequence() const = 0; 0085 0086 /** 0087 * returns whether this node is an anonymous resource 0088 */ 0089 virtual bool isAnon() const = 0; 0090 0091 /** 0092 * the identifier of this node. the ID is unique per model 0093 * and set by the associated model at creation time. 0094 */ 0095 virtual unsigned int id() const = 0; 0096 0097 /** 0098 * returns a textual representation of the node. 0099 * This is the literal string for literals, and a null string for other 0100 * node types. 0101 */ 0102 virtual QString text() const = 0; 0103 0104 /** 0105 * used in Model 0106 * @internal 0107 */ 0108 virtual void setModel(const Model &model) = 0; 0109 0110 /** 0111 * used in Model 0112 * @internal 0113 */ 0114 virtual void setId(unsigned int id) = 0; 0115 0116 protected: 0117 /** 0118 * used to generate unique IDs for node objects 0119 */ 0120 static unsigned int idCounter; 0121 }; 0122 0123 } // namespace RDF 0124 } // namespace Syndication 0125 0126 #endif // SYNDICATION_RDF_NODE_H