Syndication

node.h
1/*
2 This file is part of the syndication library
3 SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
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
16namespace Syndication
17{
18namespace RDF
19{
20class Model;
21class Node;
22class NodeVisitor;
23//@cond PRIVATE
24typedef QSharedPointer<Node> NodePtr;
25//@endcond
26
27/**
28 * an RDF node, abstract baseclass for all RDF node types, like resources and
29 * literals
30 */
31class Node
32{
33public:
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 * returns a copy of the object. Must be implemented
49 * by subclasses to return a copy using the concrete
50 * type
51 */
52 virtual Node *clone() const = 0;
53
54 /**
55 * returns whether this node is a null node
56 */
57 virtual bool isNull() const = 0;
58
59 /**
60 * returns whether this node is a resource
61 */
62 virtual bool isResource() const = 0;
63
64 /**
65 * returns whether this node is a property
66 */
67 virtual bool isProperty() const = 0;
68
69 /**
70 * returns whether this node is a literal
71 */
72 virtual bool isLiteral() const = 0;
73
74 /**
75 * returns whether this node is an RDF sequence
76 */
77 virtual bool isSequence() const = 0;
78
79 /**
80 * returns whether this node is an anonymous resource
81 */
82 virtual bool isAnon() const = 0;
83
84 /**
85 * the identifier of this node. the ID is unique per model
86 * and set by the associated model at creation time.
87 */
88 virtual unsigned int id() const = 0;
89
90 /**
91 * returns a textual representation of the node.
92 * This is the literal string for literals, and a null string for other
93 * node types.
94 */
95 virtual QString text() const = 0;
96
97 /**
98 * used in Model
99 * @internal
100 */
101 virtual void setModel(const Model &model) = 0;
102
103 /**
104 * used in Model
105 * @internal
106 */
107 virtual void setId(unsigned int id) = 0;
108
109protected:
110 /**
111 * used to generate unique IDs for node objects
112 */
113 static unsigned int idCounter;
114};
115
116} // namespace RDF
117} // namespace Syndication
118
119#endif // SYNDICATION_RDF_NODE_H
An RDF model, a set of RDF statements.
Definition model.h:37
Visitor interface, following the Visitor design pattern.
Definition nodevisitor.h:42
an RDF node, abstract baseclass for all RDF node types, like resources and literals
Definition node.h:32
virtual void accept(NodeVisitor *visitor, NodePtr ptr)
Used by visitors for double dispatch.
Definition node.cpp:17
virtual bool isResource() const =0
returns whether this node is a resource
virtual bool isSequence() const =0
returns whether this node is an RDF sequence
static unsigned int idCounter
used to generate unique IDs for node objects
Definition node.h:113
virtual bool isNull() const =0
returns whether this node is a null node
virtual Node * clone() const =0
returns a copy of the object.
virtual QString text() const =0
returns a textual representation of the node.
virtual bool isLiteral() const =0
returns whether this node is a literal
virtual bool isProperty() const =0
returns whether this node is a property
virtual ~Node()
destructor
Definition node.cpp:22
virtual void setModel(const Model &model)=0
used in Model
virtual bool isAnon() const =0
returns whether this node is an anonymous resource
virtual void setId(unsigned int id)=0
used in Model
virtual unsigned int id() const =0
the identifier of this node.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:15 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.