Soprano  2.9.4
Public Types | Public Member Functions | List of all members
Soprano::Util::MutexModel Class Reference

Protect a Model for multiple calls in multi-threaded applications. More...

#include <Soprano/Util/MutexModel>

+ Inheritance diagram for Soprano::Util::MutexModel:

Public Types

enum  ProtectionMode { PlainMultiThreading , ReadWriteMultiThreading , ReadWriteSingleThreading }
 

Public Member Functions

 MutexModel (ProtectionMode mode, Model *parent=0)
 
 ~MutexModel ()
 
Error::ErrorCode addStatement (const Statement &statement)
 
Error::ErrorCode removeStatement (const Statement &statement)
 
Error::ErrorCode removeAllStatements (const Statement &statement)
 
StatementIterator listStatements (const Statement &partial) const
 
NodeIterator listContexts () const
 
QueryResultIterator executeQuery (const QString &query, Query::QueryLanguage language, const QString &userQueryLanguage=QString()) const
 
bool containsStatement (const Statement &statement) const
 
bool containsAnyStatement (const Statement &statement) const
 
bool isEmpty () const
 
int statementCount () const
 
virtual Error::ErrorCode addStatement (const Statement &statement)
 
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 addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
virtual Error::ErrorCode removeStatement (const Statement &statement)
 
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 removeStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
virtual Error::ErrorCode removeAllStatements (const Statement &statement)
 
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 removeAllStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode removeAllStatements ()
 
virtual StatementIterator listStatements (const Statement &partial) 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 listStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
StatementIterator listStatements () const
 
virtual bool containsStatement (const Statement &statement) 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
 
bool containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
virtual bool containsAnyStatement (const Statement &statement) const
 
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 containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
- Public Member Functions inherited from Soprano::FilterModel
virtual ~FilterModel ()
 
virtual void setParentModel (Model *model)
 
virtual ModelparentModel () const
 
Error::ErrorCode addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode removeStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode removeAllStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
StatementIterator listStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
bool containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
bool containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
virtual Error::ErrorCode write (QTextStream &os) const
 
virtual Node createBlankNode ()
 
virtual Error::ErrorCode addStatement (const Statement &statement)=0
 
Error::ErrorCode addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
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 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
 
virtual bool containsStatement (const Statement &statement) const=0
 
bool containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
virtual bool containsAnyStatement (const Statement &statement) const=0
 
bool containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
- Public Member Functions inherited from Soprano::Model
virtual ~Model ()
 
Error::ErrorCode addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
Error::ErrorCode addStatements (const QList< Statement > &statements)
 
Error::ErrorCode removeStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
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 ()
 
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
 
bool containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
bool containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
bool containsContext (const Node &context) const
 
- Public Member Functions inherited from QObject
 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 &regExp)
 
 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)
 
- Public Member Functions inherited from Soprano::Error::ErrorCache
virtual ~ErrorCache ()
 
virtual Error lastError () const
 

Additional Inherited Members

- Signals inherited from Soprano::Model
void statementsAdded ()
 
void statementsRemoved ()
 
void statementAdded (const Soprano::Statement &statement)
 
void statementRemoved (const Soprano::Statement &statement)
 
- Protected Member Functions inherited from Soprano::FilterModel
 FilterModel ()
 
 FilterModel (Model *parent)
 
virtual void parentStatementsAdded ()
 
virtual void parentStatementsRemoved ()
 
virtual void parentStatementAdded (const Statement &)
 
virtual void parentStatementRemoved (const Statement &)
 
- Protected Member Functions inherited from Soprano::Model
 Model ()
 
- Protected Member Functions inherited from Soprano::Error::ErrorCache
 ErrorCache ()
 
void clearError () const
 
void setError (const Error &) const
 
void setError (const QString &errorMessage, int code=ErrorUnknown) const
 

Detailed Description

Protect a Model for multiple calls in multi-threaded applications.

In most cases one does not need to use this FilterModel since Models created by Soprano::createModel and Soprano::Backend::createModel are thread-safe. It may, however, come in handy for custom models.

Author
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org

Definition at line 44 of file mutexmodel.h.

Member Enumeration Documentation

◆ ProtectionMode

Enumerator
PlainMultiThreading 

In PlainMultiThreading mode only one action can be performed at the same time. Calls block until the previous call is done.

Warning
In this mode nesting iterators will result in a deadlock.
ReadWriteMultiThreading 

In ReadWriteMultiThreading mode multiple read operations can be performed at the same time but only one write operation.

In general write operations take precedence over read operations when locking. However, the same thread can perform nested read locks an arbitrary number of times.

ReadWriteSingleThreading 
Deprecated:
This was a buggy mode which was impossible to fix. Use Soprano::Util::AsyncModel instead.

Definition at line 49 of file mutexmodel.h.

Constructor & Destructor Documentation

◆ MutexModel()

Soprano::Util::MutexModel::MutexModel ( ProtectionMode  mode,
Model parent = 0 
)

Create a new MutexModel.

Parameters
modeThe mode to use.
parentThe parent Model to forward the actual calls to.

◆ ~MutexModel()

Soprano::Util::MutexModel::~MutexModel ( )

Destructor.

Member Function Documentation

◆ addStatement() [1/5]

Error::ErrorCode Soprano::Util::MutexModel::addStatement ( const Statement statement)
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ removeStatement() [1/5]

Error::ErrorCode Soprano::Util::MutexModel::removeStatement ( const Statement statement)
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ removeAllStatements() [1/6]

Error::ErrorCode Soprano::Util::MutexModel::removeAllStatements ( const Statement statement)
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ listStatements() [1/6]

StatementIterator Soprano::Util::MutexModel::listStatements ( const Statement partial) const
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ listContexts()

NodeIterator Soprano::Util::MutexModel::listContexts ( ) const
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ executeQuery()

QueryResultIterator Soprano::Util::MutexModel::executeQuery ( const QString query,
Query::QueryLanguage  language,
const QString userQueryLanguage = QString() 
) const
virtual

Default implementation simply pipes the call through to the parent model. Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ containsStatement() [1/5]

bool Soprano::Util::MutexModel::containsStatement ( const Statement statement) const
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ containsAnyStatement() [1/5]

bool Soprano::Util::MutexModel::containsAnyStatement ( const Statement statement) const
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ isEmpty()

bool Soprano::Util::MutexModel::isEmpty ( ) const
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ statementCount()

int Soprano::Util::MutexModel::statementCount ( ) const
virtual

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

◆ addStatement() [2/5]

virtual Error::ErrorCode Soprano::FilterModel::addStatement

Default implementation simply pipes the call through to the parent model.

◆ addStatement() [3/5]

Error::ErrorCode Soprano::FilterModel::addStatement

◆ addStatement() [4/5]

virtual Error::ErrorCode Soprano::Model::addStatement

Add the Statement to the Model.

Parameters
statementThe Statement to add.

◆ addStatement() [5/5]

Error::ErrorCode Soprano::Model::addStatement

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ removeStatement() [2/5]

virtual Error::ErrorCode Soprano::FilterModel::removeStatement

Default implementation simply pipes the call through to the parent model.

◆ removeStatement() [3/5]

Error::ErrorCode Soprano::FilterModel::removeStatement

◆ removeStatement() [4/5]

virtual Error::ErrorCode Soprano::Model::removeStatement

Remove one statement. For removing statements with wildward matching see removeAllStatements().

Parameters
statementThe 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.

◆ removeStatement() [5/5]

Error::ErrorCode Soprano::Model::removeStatement

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ removeAllStatements() [2/6]

virtual Error::ErrorCode Soprano::FilterModel::removeAllStatements

Default implementation simply pipes the call through to the parent model.

◆ removeAllStatements() [3/6]

Error::ErrorCode Soprano::FilterModel::removeAllStatements

◆ removeAllStatements() [4/6]

virtual Error::ErrorCode Soprano::Model::removeAllStatements

Remove all statements that match the partial statement. For removing one specific statement see removeStatement().

Parameters
statementA possible partially defined statement that serves as a filter for all statements that should be removed.

◆ removeAllStatements() [5/6]

Error::ErrorCode Soprano::Model::removeAllStatements

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
subjectThe subject node to match. Can be empty as a wildcard.
predicateThe predicate node to match. Can be empty as a wildcard.
objectThe object node to match. Can be empty as a wildcard.
contextThe context node to match. Can be empty as a wildcard.

◆ removeAllStatements() [6/6]

Error::ErrorCode Soprano::Model::removeAllStatements

Convenience method that clear the Model of all statements

◆ listStatements() [2/6]

virtual StatementIterator Soprano::FilterModel::listStatements

Default implementation simply pipes the call through to the parent model.

◆ listStatements() [3/6]

StatementIterator Soprano::FilterModel::listStatements

Reimplemented for convenience. Calls Model::listStatements(const Node&,const Node&,const Node&,const Node&)

◆ listStatements() [4/6]

virtual StatementIterator Soprano::Model::listStatements

Return an iterator over Model Statements that "partial" match the input Statement.

Parameters
partialThe partial Statement to match.
Returns
An iterator for all the matched Statements, on error an invalid iterator is returned.

◆ listStatements() [5/6]

StatementIterator Soprano::Model::listStatements

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
subjectThe subject node to match. Can be empty as a wildcard.
predicateThe predicate node to match. Can be empty as a wildcard.
objectThe object node to match. Can be empty as a wildcard.
contextThe 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.

◆ listStatements() [6/6]

StatementIterator Soprano::Model::listStatements

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.

◆ containsStatement() [2/5]

virtual bool Soprano::FilterModel::containsStatement

Default implementation simply pipes the call through to the parent model.

◆ containsStatement() [3/5]

bool Soprano::FilterModel::containsStatement

Reimplemented for convenience. Calls Model::containsStatement(const Node&,const Node&,const Node&,const Node&)

◆ containsStatement() [4/5]

virtual bool Soprano::Model::containsStatement

Check if the model contains a statements.

Parameters
statementThe 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.
Returns
true if the Model contains the Statement, false otherwise or is statement is invalid.

◆ containsStatement() [5/5]

bool Soprano::Model::containsStatement

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ containsAnyStatement() [2/5]

virtual bool Soprano::FilterModel::containsAnyStatement

Default implementation simply pipes the call through to the parent model.

◆ containsAnyStatement() [3/5]

bool Soprano::FilterModel::containsAnyStatement

Reimplemented for convenience. Calls Model::containsAnyStatement(const Node&,const Node&,const Node&,const Node&)

◆ containsAnyStatement() [4/5]

virtual bool Soprano::Model::containsAnyStatement

Check if the model contains certain statements.

Parameters
statementA partially defined statement that serves as a pattern.
Returns
true if the Model contains a Statement matching the given statement pattern.

◆ containsAnyStatement() [5/5]

bool Soprano::Model::containsAnyStatement

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
subjectThe subject node to match. Can be empty as a wildcard.
predicateThe predicate node to match. Can be empty as a wildcard.
objectThe object node to match. Can be empty as a wildcard.
contextThe context node to match. Can be empty as a wildcard.

The documentation for this class was generated from the following file: