Syndication

resource.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_RESOURCE_H
9#define SYNDICATION_RDF_RESOURCE_H
10
11#include <syndication/rdf/node.h>
12
13class QString;
14
15template<class T>
16class QList;
17
18namespace Syndication
19{
20namespace RDF
21{
22class Model;
23class Property;
24typedef QSharedPointer<Property> PropertyPtr;
25class Resource;
26class Statement;
27typedef QSharedPointer<Statement> StatementPtr;
28
29typedef QSharedPointer<Resource> ResourcePtr;
30
31/**
32 * Resources are the entities in the RDF graph.
33 * In RSS, e.g. the feed channel itself and the items are
34 * resources.
35 */
36class Resource : public Node
37{
38 friend class Model;
39
40public:
41 /**
42 * creates a null resource
43 */
44 Resource();
45
46 /**
47 * copies a resource
48 *
49 * @param other the resource to copy
50 */
51 Resource(const Resource &other);
52
53 /**
54 * creates a resource with a given URI.
55 * Do not use this directly, use Model::createResource() instead.
56 *
57 * @param uri the URI of the new resource
58 */
59 explicit Resource(const QString &uri);
60
61 /**
62 * destructor
63 */
64 ~Resource() override;
65
66 /**
67 * assigns a resource
68 *
69 * @param other the resource to assign
70 */
71 Resource &operator=(const Resource &other);
72
73 /**
74 * checks two resources for equality. Currently both URI (or anonID)
75 * _and_ id() must be equal!
76 *
77 * @param other the node to compare this node to
78 */
79 bool operator==(const Resource &other) const;
80
81 /**
82 * Used by visitors for double dispatch. See NodeVisitor
83 * for more information.
84 * @param visitor the visitor calling the method
85 * @param ptr a shared pointer object for this node
86 */
87 void accept(NodeVisitor *visitor, NodePtr ptr) override;
88
89 /**
90 * creates a copy of the resource object
91 */
92 Resource *clone() const override;
93
94 /**
95 * the model this resource belongs to
96 */
97 virtual Model model() const;
98
99 /**
100 * returns whether the resource has a property @p property in the
101 * associated model.
102 *
103 * @param property the property to check for
104 */
105 virtual bool hasProperty(PropertyPtr property) const;
106
107 /**
108 * returns a statement from the associated model where this resource is
109 * the subject and the given property the predicate.
110 *
111 * @param property the property to check for
112 *
113 * @return the first statement found that satisfies the conditions.
114 * If there are multiple statements, an arbitrary one is returned.
115 */
117
118 /**
119 * returns the list of all statements from the associated model where
120 * this resource is the subject and the given property the predicate.
121 *
122 * @param property the property to check for
123 *
124 * @return a list of the statements that satisfy the conditions.
125 */
127
128 /**
129 * returns whether the resource is a null resource
130 */
131 bool isNull() const override;
132
133 /**
134 * the identifier of this node. the ID is unique per model
135 * and set by the associated model at creation time.
136 */
137 unsigned int id() const override;
138
139 /**
140 * returns @p true
141 */
142 bool isResource() const override;
143
144 /**
145 * returns @p false
146 */
147 bool isLiteral() const override;
148
149 /**
150 * returns @p true if this resource is also a property, @p false
151 * otherwise
152 */
153 bool isProperty() const override;
154
155 /**
156 * returns whether this resource is an anonymous resource
157 */
158 bool isAnon() const override;
159
160 /**
161 * returns @p true if this resource is also a sequence, @p false
162 * otherwise.
163 */
164 bool isSequence() const override;
165
166 /**
167 * returns a null string
168 */
169 QString text() const override;
170
171 /**
172 * returns the URI of the resource
173 */
174 virtual QString uri() const;
175
176 /**
177 * used in Model
178 * @internal
179 */
180 void setModel(const Model &model) override;
181
182 /**
183 * used in Model
184 * @internal
185 */
186 void setId(unsigned int id) override;
187
188private:
189 class ResourcePrivate;
192};
193
194} // namespace RDF
195} // namespace Syndication
196
197#endif // SYNDICATION_RDF_RESOURCE_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
Resources are the entities in the RDF graph.
Definition resource.h:37
bool isSequence() const override
returns true if this resource is also a sequence, false otherwise.
Definition resource.cpp:183
void accept(NodeVisitor *visitor, NodePtr ptr) override
Used by visitors for double dispatch.
Definition resource.cpp:128
void setId(unsigned int id) override
used in Model
Definition resource.cpp:195
virtual QString uri() const
returns the URI of the resource
Definition resource.cpp:207
bool isAnon() const override
returns whether this resource is an anonymous resource
Definition resource.cpp:178
Resource * clone() const override
creates a copy of the resource object
Definition resource.cpp:123
virtual bool hasProperty(PropertyPtr property) const
returns whether the resource has a property property in the associated model.
Definition resource.cpp:85
void setModel(const Model &model) override
used in Model
Definition resource.cpp:188
virtual QList< StatementPtr > properties(PropertyPtr property) const
returns the list of all statements from the associated model where this resource is the subject and t...
Definition resource.cpp:110
bool operator==(const Resource &other) const
checks two resources for equality.
Definition resource.cpp:77
Resource()
creates a null resource
Definition resource.cpp:48
~Resource() override
destructor
Definition resource.cpp:67
bool isLiteral() const override
returns false
Definition resource.cpp:173
bool isResource() const override
returns true
Definition resource.cpp:163
bool isProperty() const override
returns true if this resource is also a property, false otherwise
Definition resource.cpp:168
unsigned int id() const override
the identifier of this node.
Definition resource.cpp:136
Resource & operator=(const Resource &other)
assigns a resource
Definition resource.cpp:71
bool isNull() const override
returns whether the resource is a null resource
Definition resource.cpp:141
QString text() const override
returns a null string
Definition resource.cpp:202
virtual Model model() const
the model this resource belongs to
Definition resource.cpp:146
virtual StatementPtr property(PropertyPtr property) const
returns a statement from the associated model where this resource is the subject and the given proper...
Definition resource.cpp:97
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.