QtSparql  0.2.6
qsparqlsparqlconnection_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (ivan.frade@nokia.com)
6 **
7 ** This file is part of the QtSparql module (not yet part of the Qt Toolkit).
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 ** If you have questions regarding the use of this file, please contact
35 ** Nokia at ivan.frade@nokia.com.
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QSPARQLSPARQLCONNECTION_P_H
41 #define QSPARQLSPARQLCONNECTION_P_H
42 
43 #include <qsparqlquerymodel.h>
44 
45 #include <QtCore/qglobal.h>
46 #include <QtCore/qdebug.h>
47 
48 #ifdef QT_VERSION_5
49 #include <QtQml/qqml.h>
50 #include <QQmlParserStatus>
51 #define QDeclarativeParserStatus QQmlParserStatus
52 #else
53 #include <QtDeclarative/qdeclarative.h>
54 #include <QDeclarativeParserStatus>
55 #endif
56 
57 QT_BEGIN_HEADER
58 
59 QT_BEGIN_NAMESPACE
60 
61 QT_MODULE(Sparql)
62 
63 class SparqlQuery;
64 class SparqlConnectionOptions;
65 
66 class Q_SPARQL_EXPORT SparqlConnection : public QSparqlConnection,
67  public QDeclarativeParserStatus
68 {
69  Q_OBJECT
70  Q_ENUMS(Status)
71  Q_PROPERTY(Status status READ status NOTIFY statusChanged)
72  Q_PROPERTY(QString driver WRITE setDriver READ getDriver)
73  Q_PROPERTY(QVariant result READ getResult NOTIFY resultReady)
74  Q_PROPERTY(SparqlConnectionOptions * options WRITE setOptions READ getOptions)
75  Q_CLASSINFO("DefaultProperty", "driver")
76  Q_INTERFACES(QDeclarativeParserStatus)
77 
78 public:
79  SparqlConnection();
80  ~SparqlConnection() {}
81 
82  enum Status { Null, Ready, Loading, Error };
83 
84  void classBegin();
85  void componentComplete();
86 
87  Q_INVOKABLE QVariant select(QString query, bool async = false);
88  Q_INVOKABLE QVariant select(QString query, QVariant boundValues, bool async = false);
89  Q_INVOKABLE QVariant ask(QString query, bool async = false);
90  Q_INVOKABLE QVariant ask(QString query, QVariant boundValues, bool async = false);
91  Q_INVOKABLE QVariant update(QString query, bool async = false);
92  Q_INVOKABLE QVariant update(QString query, QVariant boundValues, bool async = false);
93  Q_INVOKABLE QVariant construct(QString query, bool async = false);
94  Q_INVOKABLE QVariant construct(QString query, QVariant boundValues, bool async = false);
95  Q_INVOKABLE QString errorString() const;
96 
97 Q_SIGNALS:
98  void statusChanged(SparqlConnection::Status);
99  void resultReady(QVariant);
100  void onCompleted();
101 
102 private Q_SLOTS:
103  void onResultFinished();
104 
105 private:
106  QString driverName;
107  QString lastErrorMessage;
108  QSparqlResult *asyncResult; // for async queries
109  QVariant lastResult;
110  SparqlConnectionOptions *options;
111  Status connectionStatus;
112 
113  QVariant resultToVariant(QSparqlResult *result);
114  QVariant runQuery(QSparqlQuery query, bool async);
115  QVariant getResult();
116  void changeStatus(SparqlConnection::Status);
117  bool bindValues(QSparqlQuery *query, QVariant boundValues);
118  // property methods
119  void setOptions(SparqlConnectionOptions* options);
120  SparqlConnectionOptions* getOptions();
121  void setDriver(QString driverName);
122  QString getDriver();
123  Status status();
124 };
125 
126 QT_END_NAMESPACE
127 
128 QT_END_HEADER
129 
130 #endif
QSparqlQuery
The QSparqlQuery class provides a means of executing and manipulating SPARQL statements.
Definition: qsparqlquery.h:65
QSparqlConnection::driverName
QString driverName() const
Definition: qsparqlconnection.cpp:541
QSparqlConnection
The QSparqlConnection class provides an interface for accessing an RDF store.
Definition: qsparqlconnection.h:68
QSparqlResult
The QSparqlResult class provides an abstract interface for accessing the results of an executed QSpar...
Definition: qsparqlresult.h:65