Public Member Functions | Protected Member Functions

PatternGroup Class Reference

Models a graph pattern (a set of triples). More...

Inheritance diagram for PatternGroup:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 PatternGroup ()
 Constructs an empty PatternGroup.
bool optional () const
 Returns true if the group is optional, false else.
void setOptional (bool optional)
 Sets the optionality of this group.
QList< PatternBasepatterns () const
 Returns the list of patterns in this group.
void setPatterns (const QList< PatternBase > &patterns)
 Sets the list of patterns of this group.
void addPattern (const PatternBase &pattern)
 Adds a new pattern to the group.
void addPattern (const Value &s, const Value &p, const Value &o)
 Adds a new triple to the group.
void addPattern (const Value &s, const ValueChain &chain, const Value &o)
 Adds a triple chain to the group.
Filter filter () const
 Returns the current group's filter, or an invalid Filter if there is none.
void setFilter (const Filter &filter)
 Sets a filter on the group.

Protected Member Functions

 PatternGroup (PatternGroupData *data)

Detailed Description

Models a graph pattern (a set of triples).

The PatternGroup class can be used to group triples together. Grouping triples together can be useful if you want to define some of them as optional, or apply filtering only to a set of triples.


Member Function Documentation

void PatternGroup::addPattern ( const PatternBase pattern  ) 

Adds a new pattern to the group.

You will probably use this function to a nested PatternGroup to the group.

The user keeps ownership of the pattern and must free it.

void PatternGroup::addPattern ( const Value s,
const Value p,
const Value o 
)

Adds a new triple to the group.

The user keeps the ownership of the variables and must free them.

void PatternGroup::addPattern ( const Value s,
const ValueChain &  chain,
const Value o 
)

Adds a triple chain to the group.

A triple chain allows you to easily generate triples for complex graph patterns. Say that you want to select the phone numbers of all the affiliations of a contact, you would create the a ValueChain with the three predicate nco:hasAffiliation, nco:hasPhoneNumber, nco:phoneNumber and two variables, for example ?c and ?phoneNumber.

Passed those parameters, the function would generate the following pattern:

 ?_c nco:hasAffiliation ?tmp0 . ?tmp0 nco:hasPhoneNumber ?tmp1 . ?tmp1 nco:phoneNumber ?_phoneNumber

Note that user variable are always prefixed with _ in queries to avoid name clashes with variables generated automatically.

The user keeps the ownership of the variables and must free them.

QList< PatternBase > PatternGroup::patterns (  )  const

Returns the list of patterns in this group.

Note that this list is actually a tree, since it can contain PatternGroup instances, that contains restrictions themselves.

void PatternGroup::setOptional ( bool  optional  ) 

Sets the optionality of this group.

The generated Sparql will be enclosed in an OPTIONAL {} block if the group is set to be optional.

void PatternGroup::setPatterns ( const QList< PatternBase > &  patterns  ) 

Sets the list of patterns of this group.

The existing patterns will get replaced by the patterns in the list.


The documentation for this class was generated from the following files:
 All Classes Functions Enumerations