Syndication

resource.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_RESOURCE_H
9 #define SYNDICATION_RDF_RESOURCE_H
10 
11 #include <syndication/rdf/node.h>
12 
13 class QString;
14 
15 template<class T>
16 class QList;
17 
18 namespace Syndication
19 {
20 namespace RDF
21 {
22 class Model;
23 class Property;
24 typedef QSharedPointer<Property> PropertyPtr;
25 class Resource;
26 class Statement;
27 typedef QSharedPointer<Statement> StatementPtr;
28 
29 typedef 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  */
36 class SYNDICATION_EXPORT Resource : public Node
37 {
38  friend class Model;
39 
40 public:
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 Node &other) const override;
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  */
116  virtual StatementPtr property(PropertyPtr property) const;
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  */
126  virtual QList<StatementPtr> properties(PropertyPtr property) const;
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 
188 private:
189  class ResourcePrivate;
190  typedef QSharedPointer<ResourcePrivate> ResourcePrivatePtr;
191  ResourcePrivatePtr d;
192 };
193 
194 } // namespace RDF
195 } // namespace Syndication
196 
197 #endif // SYNDICATION_RDF_RESOURCE_H
KGuiItem properties()
Model
Definition: resource.h:38
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
Property
virtual bool hasProperty(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:57:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.