Dataquay 0.8
ObjectLoader.h
Go to the documentation of this file.
1/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3/*
4 Dataquay
5
6 A C++/Qt library for simple RDF datastore management.
7 Copyright 2009-2012 Chris Cannam.
8
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use, copy,
13 modify, merge, publish, distribute, sublicense, and/or sell copies
14 of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be
18 included in all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 Except as contained in this notice, the name of Chris Cannam
29 shall not be used in advertising or otherwise to promote the sale,
30 use or other dealings in this Software without prior written
31 authorization.
32*/
33
34#ifndef DATAQUAY_OBJECT_LOADER_H
35#define DATAQUAY_OBJECT_LOADER_H
36
37#include "../Node.h"
38
39#include <QHash>
40#include <QPointer>
41
42class QObject;
43
44namespace Dataquay
45{
46
47class Store;
48class TypeMapping;
49
155{
156public:
158 typedef QHash<Node, QPointer<QObject> > NodeObjectMap;
159
166
168
171
180 typedef int FollowPolicy;
181
184
189
192
208 QObject *load(Node node);
209
214 QObjectList loadType(Uri type);
215
222 QObjectList loadType(Uri type, NodeObjectMap &map);
223
233 void reload(Nodes nodes, NodeObjectMap &map);
234
239 QObjectList loadAll();
240
249 QObjectList loadAll(NodeObjectMap &map);
250
252 virtual ~LoadCallback() { }
253
261 virtual void loaded(ObjectLoader *, NodeObjectMap &, Node, QObject *) = 0;
262 };
263
275
282 LoadCallbackType type);
283
284private slots:
285 void objectDestroyed(QObject *);
286
287private:
288 ObjectLoader(const ObjectLoader &);
289 ObjectLoader &operator=(const ObjectLoader &);
290 class D;
291 D *m_d;
292};
293
294}
295
296#endif
Node represents a single RDF node, with conversions to and from variant types.
Definition Node.h:65
ObjectLoader constructs objects corresponding to nodes in the RDF store and sets properties on those ...
QObjectList loadType(Uri type, NodeObjectMap &map)
For each node of the given RDF type found in the store, construct a corresponding QObject,...
QObjectList loadAll()
Load and return an object for each node in the store that can be loaded.
FollowOption
!! document this (after ObjectStorer) – or pull it into ObjectMapperDefs
QHash< Node, QPointer< QObject > > NodeObjectMap
Map from RDF node to object.
void setFollowPolicy(FollowPolicy policy)
void setTypeMapping(const TypeMapping &)
QObjectList loadType(Uri type)
For each node of the given RDF type found in the store, construct a corresponding QObject,...
void setAbsentPropertyPolicy(AbsentPropertyPolicy policy)
LoadCallbackType
Type of a load callback.
QObject * load(Node node)
Construct a QObject based on the properties of the given object URI in the object mapper's store.
const TypeMapping & getTypeMapping() const
AbsentPropertyPolicy getAbsentPropertyPolicy() const
void reload(Nodes nodes, NodeObjectMap &map)
Examine each of the nodes passed in, and if there is no corresponding object in the node-object map,...
void addLoadCallback(LoadCallback *callback, LoadCallbackType type)
Register the given callback (a subclass of the abstract LoadCallback class) as providing a "loaded" c...
QObjectList loadAll(NodeObjectMap &map)
Load and return an object for each node in the store that can be loaded, updating the map with all re...
ObjectLoader(Store *s)
Create an ObjectLoader ready to load objects from the given RDF store.
FollowPolicy getFollowPolicy() const
Store is an abstract interface for Dataquay RDF data stores.
Definition Store.h:72
TypeMapping describes a set of relationships between RDF entity and property URIs,...
Definition TypeMapping.h:77
Uri represents a single URI.
Definition Uri.h:77
QList< Node > Nodes
A list of node types.
Definition Node.h:246
virtual void loaded(ObjectLoader *, NodeObjectMap &, Node, QObject *)=0
An object has been loaded by the given ObjectLoader from the given RDF node.