soprano
Soprano::Model Class Reference
#include <Soprano/Model>

Detailed Description
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. There are basically two types of Models in Soprano:
- StorageModel is the base class for Model implementations that actually store RDF quadruples. StorageModels are created transparently by Soprano backend plugins: Backend::createModel()
- FilterModel is the base class for all filter models. FilterModels can be stacked on top of a StorageModel to perform arbitrary tasks like inference or actual content filtering. An important FilterModel is Inference::InferenceModel.
Model* memModel = Soprano::createModel();
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:
Soprano::Model* model = Soprano::createModel(); Soprano::Statement invalidStatement; if( model->addStatement( invalidStatement ) != Error::ErrorNone ) { showErrorMessage( model->lastError().message() ); }
For this to work properly Model implementations have to reset the error in each method by either calling clearError() or setError().
- See also:
- Error handling in Soprano
Definition at line 94 of file model.h.
Signals | |
| void | statementAdded (const Soprano::Statement &statement) |
| void | statementRemoved (const Soprano::Statement &statement) |
| void | statementsAdded () |
| void | statementsRemoved () |
Public Member Functions | |
| virtual | ~Model () |
| Error::ErrorCode | addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) |
| virtual Error::ErrorCode | addStatement (const Statement &statement)=0 |
| Error::ErrorCode | addStatements (const QList< Statement > &statements) |
| bool | containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const |
| virtual bool | containsAnyStatement (const Statement &statement) const =0 |
| bool | containsContext (const Node &context) const |
| bool | containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const |
| virtual bool | containsStatement (const Statement &statement) const =0 |
| virtual bool | isEmpty () const =0 |
| virtual int | statementCount () const =0 |
| virtual Node | createBlankNode ()=0 |
| virtual QueryResultIterator | executeQuery (const QString &query, Query::QueryLanguage language, const QString &userQueryLanguage=QString()) const =0 |
| virtual NodeIterator | listContexts () const =0 |
| StatementIterator | listStatements () const |
| StatementIterator | listStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const |
| virtual StatementIterator | listStatements (const Statement &partial) const =0 |
| StatementIterator | listStatementsInContext (const Node &context) const |
| Error::ErrorCode | removeAllStatements () |
| Error::ErrorCode | removeAllStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) |
| virtual Error::ErrorCode | removeAllStatements (const Statement &statement)=0 |
| Error::ErrorCode | removeContext (const Node &) |
| Error::ErrorCode | removeStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) |
| virtual Error::ErrorCode | removeStatement (const Statement &statement)=0 |
| Error::ErrorCode | removeStatements (const QList< Statement > &statements) |
| virtual Error::ErrorCode | write (QTextStream &os) const |
Protected Member Functions | |
| Model () | |
Constructor & Destructor Documentation
| virtual Soprano::Model::~Model | ( | ) | [virtual] |
| Soprano::Model::Model | ( | ) | [protected] |
Member Function Documentation
| 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.
Reimplemented in Soprano::FilterModel, and Soprano::Util::DummyModel.
| virtual Error::ErrorCode Soprano::Model::addStatement | ( | const Statement & | statement | ) | [pure virtual] |
Add the Statement to the Model.
- Parameters:
-
statement The Statement to add.
Implemented in Soprano::FilterModel, Soprano::NRLModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, Soprano::Inference::InferenceModel, Soprano::Index::IndexFilterModel, and Soprano::Client::DBusModel.
| 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.
Reimplemented in Soprano::Util::DummyModel.
| 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.
- Parameters:
-
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.
Reimplemented in Soprano::FilterModel, and Soprano::Util::DummyModel.
| virtual bool Soprano::Model::containsAnyStatement | ( | const Statement & | statement | ) | const [pure virtual] |
Check if the model contains certain statements.
- Parameters:
-
statement A partially defined statement that serves as a pattern.
Implemented in Soprano::FilterModel, Soprano::StorageModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, and Soprano::Client::DBusModel.
| bool Soprano::Model::containsContext | ( | const Node & | context | ) | const |
Convenience method which is based on containsAnyStatement.
Reimplemented in Soprano::Util::DummyModel.
| 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.
Reimplemented in Soprano::FilterModel, and Soprano::Util::DummyModel.
| virtual bool Soprano::Model::containsStatement | ( | const Statement & | statement | ) | const [pure virtual] |
Check if the model contains a statements.
- Parameters:
-
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::FilterModel, Soprano::StorageModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, and Soprano::Client::DBusModel.
| virtual Node Soprano::Model::createBlankNode | ( | ) | [pure virtual] |
Creates a new blank node with a unique identifier.
- Returns:
- A blank node that can be used to create new statements.
Implemented in Soprano::FilterModel, Soprano::Util::DummyModel, Soprano::Util::ReadOnlyModel, and Soprano::Client::DBusModel.
| virtual QueryResultIterator Soprano::Model::executeQuery | ( | const QString & | query, | |
| Query::QueryLanguage | language, | |||
| const QString & | userQueryLanguage = QString() | |||
| ) | const [pure virtual] |
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.
- Parameters:
-
query The query to evaluate. language The query language used to encode query.userQueryLanguage If languageequals Query::QueryLanguageUser userQueryLanguage defines the language to use.
- Returns:
- An iterator over all results matching the query, on error an invalid iterator is returned.
Implemented in Soprano::FilterModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, Soprano::Index::IndexFilterModel, and Soprano::Client::DBusModel.
| virtual bool Soprano::Model::isEmpty | ( | ) | const [pure virtual] |
| virtual NodeIterator Soprano::Model::listContexts | ( | ) | const [pure virtual] |
List all contexts in the model, i.e.
all named graphs.
- Returns:
- An iterator over context Nodes, on error an invalid iterator is returned.
Implemented in Soprano::FilterModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, and Soprano::Client::DBusModel.
| 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.
- Returns:
- An iterator for all statements in the model, on error an invalid iterator is returned.
Reimplemented in Soprano::Util::DummyModel.
| 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.
- Parameters:
-
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.
- Returns:
- An iterator for all the matched Statements, on error an invalid iterator is returned.
Reimplemented in Soprano::FilterModel, and Soprano::Util::DummyModel.
| virtual StatementIterator Soprano::Model::listStatements | ( | const Statement & | partial | ) | const [pure virtual] |
Return an iterator over Model Statements that "partial" match the input Statement.
- Parameters:
-
partial The partial Statement to match.
- Returns:
- An iterator for all the matched Statements, on error an invalid iterator is returned.
Implemented in Soprano::FilterModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, and Soprano::Client::DBusModel.
| StatementIterator Soprano::Model::listStatementsInContext | ( | const Node & | context | ) | const |
Convenience method which lists all statements in context.
- Returns:
- An iterator for all the matched Statements, on error an invalid iterator is returned.
Reimplemented in Soprano::Util::DummyModel.
| Error::ErrorCode Soprano::Model::removeAllStatements | ( | ) |
Convenience method that clear the Model of all statements.
Reimplemented in 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.
- Parameters:
-
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.
Reimplemented in Soprano::FilterModel.
| virtual Error::ErrorCode Soprano::Model::removeAllStatements | ( | const Statement & | statement | ) | [pure virtual] |
Remove all statements that match the partial statement.
For removing one specific statement see removeStatement().
- Parameters:
-
statement A possible partially defined statement that serves as a filter for all statements that should be removed.
Implemented in Soprano::FilterModel, Soprano::StorageModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, Soprano::Inference::InferenceModel, Soprano::Index::IndexFilterModel, and Soprano::Client::DBusModel.
| Error::ErrorCode Soprano::Model::removeContext | ( | const Node & | ) |
Convenience method that removes all statements in the context.
Reimplemented in 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.
Reimplemented in Soprano::FilterModel, and Soprano::Util::DummyModel.
| virtual Error::ErrorCode Soprano::Model::removeStatement | ( | const Statement & | statement | ) | [pure virtual] |
Remove one statement.
For removing statements with wildward matching see removeAllStatements().
- Parameters:
-
statement The statement that should be removed. This has to be a valid statement.
- Returns:
- Error::ErrorNone on success and an error code if statement was invalid or an error occured.
Implemented in Soprano::FilterModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, Soprano::Inference::InferenceModel, Soprano::Index::IndexFilterModel, and Soprano::Client::DBusModel.
| Error::ErrorCode Soprano::Model::removeStatements | ( | const QList< Statement > & | statements | ) |
Convenience method which removes all statements in statements.
Reimplemented in Soprano::Util::DummyModel.
| void Soprano::Model::statementAdded | ( | const Soprano::Statement & | statement | ) | [signal] |
Notification signal for new statements.
Model implementations should emit this signal for each newly added statement.
| virtual int Soprano::Model::statementCount | ( | ) | const [pure virtual] |
The number of statements stored in this Model.
- Returns:
- The size of the Model, or -1 on error.
Implemented in Soprano::FilterModel, Soprano::Util::DummyModel, Soprano::Util::MutexModel, Soprano::Util::ReadOnlyModel, and Soprano::Client::DBusModel.
| void Soprano::Model::statementRemoved | ( | const Soprano::Statement & | statement | ) | [signal] |
Notification signal for removed statements.
Model implementations should emit this signal for each removed statement.
- Warning:
- Backends may choose not to emit this signal for each removed statement but only for a statement pattern (i.e. an invalid statement as used in removeAllStatements()) to prevent massive performance loss.
| void Soprano::Model::statementsAdded | ( | ) | [signal] |
Emitted when new statements have been added to the model.
Implementations of this interface have to emit this signal.
| void Soprano::Model::statementsRemoved | ( | ) | [signal] |
Emitted when statements have been removed from the model.
Implementations of this interface have to emit this signal.
| virtual Error::ErrorCode Soprano::Model::write | ( | QTextStream & | os | ) | const [virtual] |
Write all statements in this Model to os.
Default implementation is based on Model::listStatements
Reimplemented in Soprano::FilterModel, and Soprano::Util::DummyModel.
The documentation for this class was generated from the following file:
KDE 4.1 API Reference