Dataquay 0.8
ObjectStorer.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_STORER_H
35#define DATAQUAY_OBJECT_STORER_H
36
37#include "../Node.h"
38
39#include "ObjectMapperDefs.h"
40
41#include <QHash>
42
43class QObject;
44
45namespace Dataquay
46{
47
48class Store;
49class TypeMapping;
50
108{
109public:
123 typedef QHash<QObject *, Node> ObjectNodeMap;
124
131
136
145
150
163
181
187
227
233
235 FollowNone = 0, // the default
240 // there is no FollowAll; it generally isn't a good idea
242 };
243 typedef int FollowPolicy;
244
276
288 Uri store(QObject *o);
289
302 Uri store(QObject *o, ObjectNodeMap &map);
303
308 void store(QObjectList o);
309
315 void store(QObjectList o, ObjectNodeMap &map);
316
326 void removeObject(Node node);
327
329 virtual ~StoreCallback() { }
330
338 virtual void stored(ObjectStorer *, ObjectNodeMap &, QObject *, Node) = 0;
339 };
340
347
348private:
349 ObjectStorer(const ObjectStorer &);
350 ObjectStorer &operator=(const ObjectStorer &);
351
352 class D;
353 D *m_d;
354};
355
356}
357
358#endif
Node represents a single RDF node, with conversions to and from variant types.
Definition Node.h:65
ObjectStorer is a storage handler capable of turning objects derived from QObject into RDF triples in...
Uri store(QObject *o)
Store the given object and return its URI in the datastore.
void setTypeMapping(const TypeMapping &)
Provide a TypeMapping object, which controls the URIs chosen by ObjectStorer to represent object type...
void setFollowPolicy(FollowPolicy policy)
Set the policy used to determine which objects to store, based on their relationship to an object who...
void addStoreCallback(StoreCallback *callback)
Register the given callback (a subclass of the abstract StoreCallback class) as providing a "stored" ...
void removeObject(Node node)
Remove an object from the store, given its node.
void store(QObjectList o, ObjectNodeMap &map)
Store the given objects, and add them and their nodes to the ObjectNodeMap.
PropertyStorePolicy getPropertyStorePolicy() const
Retrieve the current policy used to determine whether to store a property.
FollowPolicy getFollowPolicy() const
const TypeMapping & getTypeMapping() const
Retrieve the current TypeMapping object.
void setBlankNodePolicy(BlankNodePolicy policy)
Set the policy used to determine whether to give an object a URI or use a blank node for it.
void store(QObjectList o)
Store the given objects.
BlankNodePolicy getBlankNodePolicy() const
Retrieve the current policy used to determine whether to give an object a URI or use a blank node for...
QHash< QObject *, Node > ObjectNodeMap
ObjectNodeMap contains a record of the RDF node used for each object.
Uri store(QObject *o, ObjectNodeMap &map)
Store the given object; add the object and its node to the ObjectNodeMap, and return its URI in the d...
void setPropertyStorePolicy(PropertyStorePolicy policy)
Set the policy used to determine whether to store a property.
Store * getStore()
Retrieve the store object that was passed to the constructor.
@ StoreIfChanged
Store only properties that differ from default object.
@ StoreAlways
Store all properties (if storable, readable & writable) (default)
ObjectStorer(Store *s)
Create an ObjectStorer ready to store objects to the given datastore.
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
virtual void stored(ObjectStorer *, ObjectNodeMap &, QObject *, Node)=0
An object has been stored by the given ObjectStorer, resulting in the given RDF node.