annotate rdf/SimpleSPARQLQuery.h @ 489:82ab61fa9223
* Reorganise our sparql queries on the basis that Redland must be
available, not only optional. So for anything querying the pool
of data about plugins, we use a single datastore and model which
is initialised at the outset by PluginRDFIndexer and then queried
directly; for anything that "reads from a file" (e.g. loading
annotations) we query directly using Rasqal, going to the
datastore when we need additional plugin-related information.
This may improve performance, but mostly it simplifies the code
and fixes a serious issue with RDF import in the previous versions
(namely that multiple sequential RDF imports would end up sharing
the same RDF data pool!)
author |
Chris Cannam |
date |
Fri, 21 Nov 2008 16:12:29 +0000 |
parents |
a82645e788fc |
children |
23945cdd7161 |
rev |
line source |
Chris@439
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@439
|
2
|
Chris@439
|
3 /*
|
Chris@439
|
4 Sonic Visualiser
|
Chris@439
|
5 An audio file viewer and annotation editor.
|
Chris@439
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@439
|
7 This file copyright 2008 QMUL.
|
Chris@439
|
8
|
Chris@439
|
9 This program is free software; you can redistribute it and/or
|
Chris@439
|
10 modify it under the terms of the GNU General Public License as
|
Chris@439
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@439
|
12 License, or (at your option) any later version. See the file
|
Chris@439
|
13 COPYING included with this distribution for more information.
|
Chris@439
|
14 */
|
Chris@439
|
15
|
Chris@439
|
16 #ifndef _SIMPLE_SPARQL_QUERY_H_
|
Chris@439
|
17 #define _SIMPLE_SPARQL_QUERY_H_
|
Chris@439
|
18
|
Chris@439
|
19 #include <QString>
|
Chris@439
|
20 #include <map>
|
Chris@439
|
21 #include <vector>
|
Chris@439
|
22
|
Chris@439
|
23 class ProgressReporter;
|
Chris@439
|
24
|
Chris@439
|
25 class SimpleSPARQLQuery
|
Chris@439
|
26 {
|
Chris@439
|
27 public:
|
Chris@439
|
28 enum ValueType { NoValue, URIValue, LiteralValue, BlankValue };
|
Chris@439
|
29
|
Chris@439
|
30 struct Value {
|
Chris@439
|
31 Value() : type(NoValue), value() { }
|
Chris@439
|
32 Value(ValueType t, QString v) : type(t), value(v) { }
|
Chris@439
|
33 ValueType type;
|
Chris@439
|
34 QString value;
|
Chris@439
|
35 };
|
Chris@439
|
36
|
Chris@439
|
37 typedef std::map<QString, Value> KeyValueMap;
|
Chris@439
|
38 typedef std::vector<KeyValueMap> ResultList;
|
Chris@439
|
39
|
Chris@489
|
40 enum QueryType {
|
Chris@489
|
41 QueryFromModel,
|
Chris@489
|
42 QueryFromSingleSource
|
Chris@489
|
43 };
|
Chris@489
|
44
|
Chris@489
|
45 SimpleSPARQLQuery(QueryType type, QString query);
|
Chris@439
|
46 ~SimpleSPARQLQuery();
|
Chris@439
|
47
|
Chris@489
|
48 static bool addSourceToModel(QString sourceUri);
|
Chris@489
|
49
|
Chris@439
|
50 void setProgressReporter(ProgressReporter *reporter);
|
Chris@439
|
51 bool wasCancelled() const;
|
Chris@439
|
52
|
Chris@439
|
53 ResultList execute();
|
Chris@439
|
54
|
Chris@439
|
55 bool isOK() const;
|
Chris@439
|
56 QString getErrorString() const;
|
Chris@439
|
57
|
Chris@440
|
58 // Do a query and return the value for the given binding, from the
|
Chris@440
|
59 // first result that has a value for it
|
Chris@489
|
60 static Value singleResultQuery(QueryType type,
|
Chris@480
|
61 QString query,
|
Chris@480
|
62 QString binding);
|
Chris@480
|
63
|
Chris@439
|
64 protected:
|
Chris@439
|
65 class Impl;
|
Chris@439
|
66 Impl *m_impl;
|
Chris@439
|
67 };
|
Chris@439
|
68
|
Chris@439
|
69 #endif
|