Syndication

node.h
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2006 Frank Osterfeld <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef SYNDICATION_RDF_NODE_H
9 #define SYNDICATION_RDF_NODE_H
10 
11 #include "../syndication_export.h"
12 
13 #include <QSharedPointer>
14 #include <QString>
15 
16 namespace Syndication
17 {
18 namespace RDF
19 {
20 class Model;
21 class Node;
22 class NodeVisitor;
23 //@cond PRIVATE
24 typedef QSharedPointer<Node> NodePtr;
25 //@endcond
26 
27 /**
28  * an RDF node, abstract baseclass for all RDF node types, like resources and
29  * literals
30  */
31 class SYNDICATION_EXPORT Node
32 {
33 public:
34  /**
35  * destructor
36  */
37  virtual ~Node();
38 
39  /**
40  * Used by visitors for double dispatch. See NodeVisitor
41  * for more information.
42  * @param visitor the visitor calling the method
43  * @param ptr a shared pointer object for this node
44  */
45  virtual void accept(NodeVisitor *visitor, NodePtr ptr);
46 
47  /**
48  * checks whether two nodes are equal. The meaning of equality
49  * is defined per subclass (e.g. equality of URIs, IDs etc.)
50  *
51  * @param other the node to compare to
52  */
53  virtual bool operator==(const Node &other) const = 0;
54 
55  /**
56  * returns a copy of the object. Must be implemented
57  * by subclasses to return a copy using the concrete
58  * type
59  */
60  virtual Node *clone() const = 0;
61 
62  /**
63  * returns whether this node is a null node
64  */
65  virtual bool isNull() const = 0;
66 
67  /**
68  * returns whether this node is a resource
69  */
70  virtual bool isResource() const = 0;
71 
72  /**
73  * returns whether this node is a property
74  */
75  virtual bool isProperty() const = 0;
76 
77  /**
78  * returns whether this node is a literal
79  */
80  virtual bool isLiteral() const = 0;
81 
82  /**
83  * returns whether this node is an RDF sequence
84  */
85  virtual bool isSequence() const = 0;
86 
87  /**
88  * returns whether this node is an anonymous resource
89  */
90  virtual bool isAnon() const = 0;
91 
92  /**
93  * the identifier of this node. the ID is unique per model
94  * and set by the associated model at creation time.
95  */
96  virtual unsigned int id() const = 0;
97 
98  /**
99  * returns a textual representation of the node.
100  * This is the literal string for literals, and a null string for other
101  * node types.
102  */
103  virtual QString text() const = 0;
104 
105  /**
106  * used in Model
107  * @internal
108  */
109  virtual void setModel(const Model &model) = 0;
110 
111  /**
112  * used in Model
113  * @internal
114  */
115  virtual void setId(unsigned int id) = 0;
116 
117 protected:
118  /**
119  * used to generate unique IDs for node objects
120  */
121  static unsigned int idCounter;
122 };
123 
124 } // namespace RDF
125 } // namespace Syndication
126 
127 #endif // SYNDICATION_RDF_NODE_H
An RDF model, a set of RDF statements.
Definition: model.h:36
an RDF node, abstract baseclass for all RDF node types, like resources and literals
Definition: node.h:31
Model
Definition: resource.h:38
Visitor interface, following the Visitor design pattern.
Definition: nodevisitor.h:41
static unsigned int idCounter
used to generate unique IDs for node objects
Definition: node.h:121
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Jun 6 2023 03:56:27 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.