Soprano 2.9.4
Public Member Functions | List of all members
Soprano::Graph Class Reference

A simple collection of statements. More...

#include <Soprano/Graph>

Public Member Functions

 Graph ()
 
 Graph (const Graph &)
 
 Graph (const QList< Statement > &)
 
 ~Graph ()
 
void addStatement (const Statement &statement)
 
void addStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
void addStatements (const QList< Statement > &statements)
 
void removeStatement (const Statement &statement)
 
void removeStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
void removeAllStatements (const Statement &statement=Statement())
 
void removeAllStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node())
 
void removeStatements (const QList< Statement > &statements)
 
void removeContext (const Node &)
 
StatementIterator listStatements (const Statement &partial=Statement()) const
 
StatementIterator listStatements (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
StatementIterator listStatementsInContext (const Node &context) const
 
NodeIterator listContexts () const
 
bool containsAnyStatement (const Statement &statement) const
 
bool containsAnyStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
bool containsStatement (const Statement &statement) const
 
bool containsStatement (const Node &subject, const Node &predicate, const Node &object, const Node &context=Node()) const
 
bool containsContext (const Node &context) const
 
bool isEmpty () const
 
int statementCount () const
 
QList< StatementtoList () const
 
QSet< StatementtoSet () const
 

Operators

Graphoperator= (const Graph &g)
 
Graphoperator= (const QList< Statement > &statements)
 
Graph operator+ (const Graph &g) const
 
Graph operator+ (const Statement &s) const
 
Graphoperator+= (const Graph &g)
 
Graphoperator+= (const Statement &s)
 
Graph operator- (const Graph &) const
 
Graph operator- (const Statement &s) const
 
Graphoperator-= (const Graph &g)
 
Graphoperator-= (const Statement &s)
 
Graphoperator<< (const Graph &)
 
Graphoperator<< (const Statement &)
 
bool operator== (const Graph &g) const
 
bool operator!= (const Graph &g) const
 

Detailed Description

A simple collection of statements.

A Graph is a simple in-memory collection of Statements. It is supposed to be used where one needs a quick way to exchange or store a small number of statements. It is basically a fancy QSet of statements.

In comparision to Model it does not support queries, it does not use a specific backend plugin, and it is not optimized in any way.

One graph does not represent one named graph, i.e. one context, it can contain Statements with different context nodes.

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

Definition at line 60 of file graph.h.

Constructor & Destructor Documentation

◆ Graph() [1/3]

Soprano::Graph::Graph ( )

Create an empty graph.

◆ Graph() [2/3]

Soprano::Graph::Graph ( const Graph )

Copy constructor.

◆ Graph() [3/3]

Soprano::Graph::Graph ( const QList< Statement > &  )

Create a graph from a list of statements.

See also
operator=(const QList<Statement>&)

◆ ~Graph()

Soprano::Graph::~Graph ( )

Destructor

Member Function Documentation

◆ addStatement() [1/2]

void Soprano::Graph::addStatement ( const Statement statement)

Add the Statement to the Graph.

Parameters
statementThe Statement to add.

◆ addStatement() [2/2]

void Soprano::Graph::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.

◆ addStatements()

void Soprano::Graph::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.

◆ removeStatement() [1/2]

void Soprano::Graph::removeStatement ( const Statement statement)

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() [2/2]

void Soprano::Graph::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.

◆ removeAllStatements() [1/2]

void Soprano::Graph::removeAllStatements ( const Statement statement = Statement())

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() [2/2]

void Soprano::Graph::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
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.

◆ removeStatements()

void Soprano::Graph::removeStatements ( const QList< Statement > &  statements)

Convenience method which removes all statements in statements.

◆ removeContext()

void Soprano::Graph::removeContext ( const Node )

Convenience method that removes all statements in the context.

◆ listStatements() [1/2]

StatementIterator Soprano::Graph::listStatements ( const Statement partial = Statement()) const

Return an iterator over Graph 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() [2/2]

StatementIterator Soprano::Graph::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
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.

◆ listStatementsInContext()

StatementIterator Soprano::Graph::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.

◆ listContexts()

NodeIterator Soprano::Graph::listContexts ( ) const

List all contexts in the graph, i.e. all named graphs.

Returns
An iterator over context Nodes, on error an invalid iterator is returned.

◆ containsAnyStatement() [1/2]

bool Soprano::Graph::containsAnyStatement ( const Statement statement) const

Check if the graph contains certain statements.

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

◆ containsAnyStatement() [2/2]

bool Soprano::Graph::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
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.

◆ containsStatement() [1/2]

bool Soprano::Graph::containsStatement ( const Statement statement) const

Check if the graph 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 Graph contains the Statement, false otherwise or is statement is invalid.

◆ containsStatement() [2/2]

bool Soprano::Graph::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.

◆ containsContext()

bool Soprano::Graph::containsContext ( const Node context) const

Convenience method which is based on containsAnyStatement

◆ isEmpty()

bool Soprano::Graph::isEmpty ( ) const
Returns
true if the Graph doesn't contains any Statement.

◆ statementCount()

int Soprano::Graph::statementCount ( ) const

The number of statements stored in this Graph.

Returns
The size of the Graph.

◆ toList()

QList< Statement > Soprano::Graph::toList ( ) const

Convert the Graph into a list

◆ toSet()

QSet< Statement > Soprano::Graph::toSet ( ) const

Convert the Graph into a set

◆ operator=() [1/2]

Graph & Soprano::Graph::operator= ( const Graph g)

Assings g to this graph and returns a refernce to this graph.

◆ operator=() [2/2]

Graph & Soprano::Graph::operator= ( const QList< Statement > &  statements)

Assings statements to this graph and returns a refernce to this graph.

◆ operator+() [1/2]

Graph Soprano::Graph::operator+ ( const Graph g) const

Returns a graph containing all statements from this graph and from g.

◆ operator+() [2/2]

Graph Soprano::Graph::operator+ ( const Statement s) const

Returns a graph containing all statements from this graph and from s.

◆ operator+=() [1/2]

Graph & Soprano::Graph::operator+= ( const Graph g)

Inserts the statements in graph g into this graph and returns a reference to this graph.

◆ operator+=() [2/2]

Graph & Soprano::Graph::operator+= ( const Statement s)

Inserts the statement s into this graph and returns a reference to this graph.

◆ operator-() [1/2]

Graph Soprano::Graph::operator- ( const Graph ) const

Substracts all statements in g from this graph and returns a reference to this graph.

◆ operator-() [2/2]

Graph Soprano::Graph::operator- ( const Statement s) const

Substracts s from this graph and returns a reference to this graph.

◆ operator-=() [1/2]

Graph & Soprano::Graph::operator-= ( const Graph g)

Removes the statements in graph g from this graph and returns a reference to this graph.

◆ operator-=() [2/2]

Graph & Soprano::Graph::operator-= ( const Statement s)

Removes the statement s from this graph and returns a reference to this graph.

◆ operator<<() [1/2]

Graph & Soprano::Graph::operator<< ( const Graph )
See also
operator+=

◆ operator<<() [2/2]

Graph & Soprano::Graph::operator<< ( const Statement )
See also
operator+=

◆ operator==()

bool Soprano::Graph::operator== ( const Graph g) const

Comparision operator.

Returns
true if this graph and g contain the same statements, false otherwise.

◆ operator!=()

bool Soprano::Graph::operator!= ( const Graph g) const

Comparision operator.

Returns
true if this graph contains a statement g does not contain or the other way around, false otherwise.

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