Soprano
2.9.2
|
A Model is the central class in Soprano. It is a queryable collection of RDF quadruples, i.e statements. More...
#include <Soprano/Model>
Signals | |
void | statementsAdded () |
void | statementsRemoved () |
void | statementAdded (const Soprano::Statement &statement) |
void | statementRemoved (const Soprano::Statement &statement) |
Public Member Functions | |
virtual | ~Model () |
virtual Error::ErrorCode | addStatement (const Statement &statement)=0 |
Error::ErrorCode | addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) |
Error::ErrorCode | addStatements (const QList< Statement > &statements) |
virtual Error::ErrorCode | removeStatement (const Statement &statement)=0 |
Error::ErrorCode | removeStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) |
virtual Error::ErrorCode | removeAllStatements (const Statement &statement)=0 |
Error::ErrorCode | removeAllStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) |
Error::ErrorCode | removeStatements (const QList< Statement > &statements) |
Error::ErrorCode | removeContext (const Node &) |
Error::ErrorCode | removeAllStatements () |
virtual StatementIterator | listStatements (const Statement &partial) const =0 |
StatementIterator | listStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const |
StatementIterator | listStatements () const |
StatementIterator | listStatementsInContext (const Node &context) const |
virtual NodeIterator | listContexts () const =0 |
virtual QueryResultIterator | executeQuery (const QString &query, Query::QueryLanguage language, const QString &userQueryLanguage=QString()) const =0 |
virtual bool | containsAnyStatement (const Statement &statement) const =0 |
bool | containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const |
virtual bool | containsStatement (const Statement &statement) const =0 |
bool | containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const |
bool | containsContext (const Node &context) const |
virtual bool | isEmpty () const =0 |
virtual int | statementCount () const =0 |
virtual Error::ErrorCode | write (QTextStream &os) const |
virtual Node | createBlankNode ()=0 |
![]() | |
QObject (QObject *parent=0) | |
blockSignals (bool block) | |
childEvent (QChildEvent *event) | |
children () | |
connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type=Qt::AutoCompatConnection) | |
connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type=Qt::AutoCompatConnection) | |
connectNotify (const char *signal) | |
customEvent (QEvent *event) | |
deleteLater () | |
destroyed (QObject *obj=0) | |
disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) | |
disconnect (const char *signal=0, const QObject *receiver=0, const char *method=0) | |
disconnect (const QObject *receiver, const char *method=0) | |
disconnectNotify (const char *signal) | |
dumpObjectInfo () | |
dumpObjectTree () | |
dynamicPropertyNames () | |
event (QEvent *e) | |
eventFilter (QObject *watched, QEvent *event) | |
findChild (const QString &name=QString() | |
findChildren (const QString &name=QString() | |
findChildren (const QRegExp ®Exp) | |
inherits (const char *className) | |
installEventFilter (QObject *filterObj) | |
isWidgetType () | |
killTimer (int id) | |
metaObject () | |
moveToThread (QThread *targetThread) | |
parent () | |
property (const char *name) | |
receivers (const char *signal) | |
removeEventFilter (QObject *obj) | |
sender () | |
setParent (QObject *parent) | |
setProperty (const char *name, const QVariant &value) | |
signalsBlocked () | |
startTimer (int interval) | |
thread () | |
timerEvent (QTimerEvent *event) | |
tr (const char *sourceText, const char *comment=0, int n=-1) | |
trUtf8 (const char *sourceText, const char *comment=0, int n=-1) | |
staticMetaObject | |
QObject (QObject *parent, const char *name) | |
checkConnectArgs (const char *signal, const QObject *object, const char *method) | |
child (const char *objName, const char *inheritsClass=0, bool recursiveSearch=true) | |
className () | |
insertChild (QObject *object) | |
isA (const char *className) | |
name () | |
name (const char *defaultName) | |
normalizeSignalSlot (const char *signalSlot) | |
removeChild (QObject *object) | |
setName (const char *name) | |
![]() | |
virtual | ~ErrorCache () |
virtual Error | lastError () const |
Protected Member Functions | |
Model () | |
![]() | |
ErrorCache () | |
void | clearError () const |
void | setError (const Error &) const |
void | setError (const QString &errorMessage, int code=ErrorUnknown) const |
A Model is the central class in Soprano. It is a queryable collection of RDF quadruples, i.e statements.
Model itself is just an interface for numerous implementations. (If you are looking for a simple container for statements, see Graph.) There are basically two types of Models in Soprano:
The simplest way to create a memory Model is to use the default Backend:
Error handling:
Model is based on Soprano's own error handling system which tries to emulate exceptions to a certain extend. Most methods in Model have a means of reporting if an operation was successful or not. For additional error information Model inherits ErrorCache which provides the method lastError().
Thus, advanced error handling would look as follows:
For this to work properly Model implementations have to reset the error in each method by either calling clearError() or setError().
Model is thread-safe when used with a thread-safe backend (all "official" Soprano backends are thread-safe). However, it is recommended to create Model instances in the main thread.
|
virtual |
|
protected |
|
pure virtual |
Add the Statement to the Model.
statement | The Statement to add. |
Implemented in Soprano::Client::SparqlModel, Soprano::Util::ReadOnlyModel, Soprano::Index::IndexFilterModel, Soprano::Client::DBusModel, Soprano::Util::MutexModel, Soprano::Inference::InferenceModel, Soprano::FilterModel, and Soprano::Util::DummyModel.
Error::ErrorCode Soprano::Model::addStatement | ( | const Node & | subject, |
const Node & | predicate, | ||
const Node & | object, | ||
const Node & | context = Node() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Error::ErrorCode Soprano::Model::addStatements | ( | const QList< Statement > & | statements) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
pure virtual |
Remove one statement. For removing statements with wildward matching see removeAllStatements().
statement | The statement that should be removed. This has to be a valid statement. |
Implemented in Soprano::Client::SparqlModel, Soprano::Index::IndexFilterModel, Soprano::Util::ReadOnlyModel, Soprano::Client::DBusModel, Soprano::Util::MutexModel, Soprano::FilterModel, Soprano::Inference::InferenceModel, and Soprano::Util::DummyModel.
Error::ErrorCode Soprano::Model::removeStatement | ( | const Node & | subject, |
const Node & | predicate, | ||
const Node & | object, | ||
const Node & | context = Node() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
pure virtual |
Remove all statements that match the partial statement. For removing one specific statement see removeStatement().
statement | A possible partially defined statement that serves as a filter for all statements that should be removed. |
Implemented in Soprano::NRLModel, Soprano::Client::SparqlModel, Soprano::Index::IndexFilterModel, Soprano::Util::ReadOnlyModel, Soprano::Client::DBusModel, Soprano::FilterModel, Soprano::Inference::InferenceModel, Soprano::Util::MutexModel, Soprano::StorageModel, and Soprano::Util::DummyModel.
Error::ErrorCode Soprano::Model::removeAllStatements | ( | const Node & | subject, |
const Node & | predicate, | ||
const Node & | object, | ||
const Node & | context = Node() |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
subject | The subject node to match. Can be empty as a wildcard. |
predicate | The predicate node to match. Can be empty as a wildcard. |
object | The object node to match. Can be empty as a wildcard. |
context | The context node to match. Can be empty as a wildcard. |
Error::ErrorCode Soprano::Model::removeStatements | ( | const QList< Statement > & | statements) |
Convenience method which removes all statements in statements.
Error::ErrorCode Soprano::Model::removeContext | ( | const Node & | ) |
Convenience method that removes all statements in the context.
Error::ErrorCode Soprano::Model::removeAllStatements | ( | ) |
Convenience method that clear the Model of all statements
|
pure virtual |
Return an iterator over Model Statements that "partial" match the input Statement.
partial | The partial Statement to match. |
Implemented in Soprano::Util::AsyncModel, Soprano::Client::SparqlModel, Soprano::FilterModel, Soprano::Client::DBusModel, Soprano::Util::MutexModel, Soprano::Util::DummyModel, and Soprano::Util::ReadOnlyModel.
StatementIterator Soprano::Model::listStatements | ( | const Node & | subject, |
const Node & | predicate, | ||
const Node & | object, | ||
const Node & | context = Node() |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
subject | The subject node to match. Can be empty as a wildcard. |
predicate | The predicate node to match. Can be empty as a wildcard. |
object | The object node to match. Can be empty as a wildcard. |
context | The context node to match. Can be empty as a wildcard. |
StatementIterator Soprano::Model::listStatements | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
StatementIterator Soprano::Model::listStatementsInContext | ( | const Node & | context) | const |
Convenience method which lists all statements in context.
|
pure virtual |
List all contexts in the model, i.e. all named graphs.
Implemented in Soprano::Util::AsyncModel, Soprano::Client::SparqlModel, Soprano::FilterModel, Soprano::Client::DBusModel, Soprano::Util::MutexModel, Soprano::Util::DummyModel, and Soprano::Util::ReadOnlyModel.
|
pure virtual |
query_api_disabled Execute the given query over the Model.
This is a const read-only method. As such Model implementations should not support SPARQL extensions such as INSERT or UPDATE through this method. A future version of Soprano will provide an additional API for queries that change the Model.
query | The query to evaluate. |
language | The query language used to encode query . |
userQueryLanguage | If language equals Query::QueryLanguageUser userQueryLanguage defines the language to use. |
Implemented in Soprano::Util::AsyncModel, Soprano::Client::SparqlModel, Soprano::NRLModel, Soprano::Index::IndexFilterModel, Soprano::FilterModel, Soprano::Client::DBusModel, Soprano::Util::MutexModel, Soprano::Util::DummyModel, and Soprano::Util::ReadOnlyModel.
|
pure virtual |
Check if the model contains certain statements.
statement | A partially defined statement that serves as a pattern. |
Implemented in Soprano::Client::SparqlModel, Soprano::FilterModel, Soprano::Client::DBusModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, Soprano::Util::DummyModel, and Soprano::StorageModel.
bool Soprano::Model::containsAnyStatement | ( | const Node & | subject, |
const Node & | predicate, | ||
const Node & | object, | ||
const Node & | context = Node() |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
subject | The subject node to match. Can be empty as a wildcard. |
predicate | The predicate node to match. Can be empty as a wildcard. |
object | The object node to match. Can be empty as a wildcard. |
context | The context node to match. Can be empty as a wildcard. |
|
pure virtual |
Check if the model contains a statements.
statement | The statement in question. This has to be a valid statement, i.e. subject, predicate, and object need to be defined. If the context node is empty the default graph is searched. |
Implemented in Soprano::Client::SparqlModel, Soprano::FilterModel, Soprano::Client::DBusModel, Soprano::Util::MutexModel, Soprano::Util::DummyModel, Soprano::Util::ReadOnlyModel, and Soprano::StorageModel.
bool Soprano::Model::containsStatement | ( | const Node & | subject, |
const Node & | predicate, | ||
const Node & | object, | ||
const Node & | context = Node() |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Soprano::Model::containsContext | ( | const Node & | context) | const |
Convenience method which is based on containsAnyStatement
|
pure virtual |
|
pure virtual |
The number of statements stored in this Model.
Implemented in Soprano::Client::SparqlModel, Soprano::FilterModel, Soprano::Client::DBusModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, and Soprano::Util::DummyModel.
|
virtual |
Write all statements in this Model to os.
Default implementation is based on Model::listStatements
Reimplemented in Soprano::FilterModel, and Soprano::Util::DummyModel.
|
pure virtual |
Creates a new blank node with a unique identifier.
Implemented in Soprano::Client::SparqlModel, Soprano::FilterModel, Soprano::Util::ReadOnlyModel, Soprano::Client::DBusModel, and Soprano::Util::DummyModel.
|
signal |
Emitted when new statements have been added to the model.
Implementations of this interface have to emit this signal.
|
signal |
Emitted when statements have been removed from the model.
Implementations of this interface have to emit this signal.
|
signal |
Notification signal for new statements. Model implementations should emit this signal for each newly added statement.
|
signal |
Notification signal for removed statements. Model implementations should emit this signal for each removed statement.