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< Statement > | toList () const |
Operators | |
Graph & | operator= (const Graph &g) |
Graph & | operator= (const QList< Statement > &statements) |
Graph | operator+ (const Graph &g) const |
Graph | operator+ (const Statement &s) const |
Graph & | operator+= (const Graph &g) |
Graph & | operator+= (const Statement &s) |
Graph | operator- (const Graph &) const |
Graph | operator- (const Statement &s) const |
Graph & | operator-= (const Graph &g) |
Graph & | operator-= (const Statement &s) |
Graph & | operator<< (const Graph &) |
Graph & | operator<< (const Statement &) |
bool | operator== (const Graph &g) const |
bool | operator!= (const Graph &g) const |
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.
Definition at line 59 of file graph.h.
Soprano::Graph::Graph | ( | ) |
Create an empty graph.
Soprano::Graph::Graph | ( | const Graph & | ) |
Copy constructor.
Create a graph from a list of statements.
Soprano::Graph::~Graph | ( | ) |
Destructor
void Soprano::Graph::addStatement | ( | const Statement & | statement | ) |
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.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Soprano::Graph::removeStatement | ( | const Statement & | statement | ) |
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. |
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.
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. |
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.
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. |
Convenience method which removes all statements in statements.
void Soprano::Graph::removeContext | ( | const Node & | ) |
Convenience method that removes all statements in the context.
StatementIterator Soprano::Graph::listStatements | ( | const Statement & | partial = Statement() |
) | const |
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.
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::Graph::listStatementsInContext | ( | const Node & | context | ) | const |
Convenience method which lists all statements in context.
NodeIterator Soprano::Graph::listContexts | ( | ) | const |
List all contexts in the graph, i.e. all named graphs.
bool Soprano::Graph::containsAnyStatement | ( | const Statement & | statement | ) | const |
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.
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. |
bool Soprano::Graph::containsStatement | ( | const Statement & | statement | ) | const |
Check if the graph 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. |
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.
bool Soprano::Graph::containsContext | ( | const Node & | context | ) | const |
Convenience method which is based on containsAnyStatement
int Soprano::Graph::statementCount | ( | ) | const |
Assings g to this graph and returns a refernce to this graph.
Assings statements to this graph and returns a refernce to this graph.
Returns a graph containing all statements from this graph and from g.
Returns a graph containing all statements from this graph and from s.
Inserts the statements in graph g into this graph and returns a reference to this graph.
Inserts the statement s into this graph and returns a reference to this graph.
Substracts all statements in g from this graph and returns a reference to this graph.
Substracts s from this graph and returns a reference to this graph.
Removes the statements in graph g from this graph and returns a reference to this graph.
Removes the statement s from this graph and returns a reference to this graph.
bool Soprano::Graph::operator== | ( | const Graph & | g | ) | const |
Comparision operator.
true
if this graph and g contain the same statements, false
otherwise. bool Soprano::Graph::operator!= | ( | const Graph & | g | ) | const |
Comparision operator.
true
if this graph contains a statement g does not contain or the other way around, false
otherwise.