annotate rdf/SimpleSPARQLQuery.h @ 488:1c66e199e7d9

* remove some unused code
author Chris Cannam
date Fri, 21 Nov 2008 14:25:33 +0000
parents a82645e788fc
children 82ab61fa9223
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@480 40 SimpleSPARQLQuery(QString fromUri, QString query);
Chris@439 41 ~SimpleSPARQLQuery();
Chris@439 42
Chris@439 43 void setProgressReporter(ProgressReporter *reporter);
Chris@439 44 bool wasCancelled() const;
Chris@439 45
Chris@439 46 ResultList execute();
Chris@439 47
Chris@439 48 bool isOK() const;
Chris@439 49 QString getErrorString() const;
Chris@439 50
Chris@440 51 // Do a query and return the value for the given binding, from the
Chris@440 52 // first result that has a value for it
Chris@480 53 static Value singleResultQuery(QString fromUri,
Chris@480 54 QString query,
Chris@480 55 QString binding);
Chris@480 56
Chris@481 57 enum BackEndPreference {
Chris@481 58 AutoSelectBackEnd, // pick based on likely speed of available storage
Chris@481 59 DirectParserBackEnd, // use rasqal (simpler if seldom used)
Chris@481 60 DatastoreBackEnd, // use redland (faster if version not too old)
Chris@480 61 };
Chris@481 62 /**
Chris@481 63 * Select the preferred query back end. This should be called
Chris@481 64 * before any queries are made. The default is AutoSelectBackEnd.
Chris@481 65 */
Chris@481 66 static void setBackEnd(BackEndPreference);
Chris@440 67
Chris@439 68 protected:
Chris@439 69 class Impl;
Chris@439 70 Impl *m_impl;
Chris@439 71 };
Chris@439 72
Chris@439 73 #endif