QSDK 1.1 Documentation
Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

Q::Query Struct Reference
[Knowledge Base]

#include <Q/q.h>

Inheritance diagram for Q::Query:

Q::ObjectBase List of all members.

Public Member Functions

 Query ()
bool valid () const
void reset ()
void next ()
Concept key () const
Concept current () const
bool light () const
void removeCurrent ()
bool setCurrent (const Concept &value)
Concept operator * () const
Queryoperator++ ()

Static Public Member Functions

Query create (const Concept &con, const Concept &relation)
Query create (const Concept &con)
bool affirm (const Concept &con, const Concept &rel, const Concept &value)
ClassType classType ()
Query cast (const ObjectBase &obj)

Detailed Description

Retrieve information from the knowledge database.
See also:
Concept, ConceptIterator, ObjectIterator


Constructor & Destructor Documentation

Q::Query::Query  )  [inline]
 

Create a null Query reference.


Member Function Documentation

bool Q::Query::affirm const Concept con,
const Concept rel,
const Concept value
[static]
 

Concise form of Query that looks up a specific fact, exactly (con rel value). A fully specified fact will be there or not, there is no iteration here. This process is equivalent to Query(con, rel) and expecting (at most) one value Query::current() of value.

Query Q::Query::cast const ObjectBase obj  )  [static]
 

If the object referenced by obj is a Query, then return a suitable reference to the object.

ClassType Q::Query::classType  )  [static]
 

Return the type of this class.

Query Q::Query::create const Concept con  )  [static]
 

Same as create(con, Concept()).

Query Q::Query::create const Concept con,
const Concept relation
[static]
 

Create a Query iterating the facts of con subject to the given relation. If relation is the null Concept, all facts of con are retrieved. For each fact, its relation is given by Query::key() and the value given by Query::current(). When relation is defined, Query::key() is relation, and Query::current() ranges over all facts of con with the same relation.

Concept Q::Query::current  )  const
 

The current value is the value term of a fact, ie. the last term. For example, when the iteration Query(bob) parks on (bob likes porridge), "porridge" is Query::current().

Note:
Unlike for the relation, the value term of a fact could be a value concept (ie ConceptValue). Use Concept::isValue() to determine this.

Concept Q::Query::key  )  const
 

The key is the relation term of the fact, ie. the middle term. For example, when the iteration Query(bob) parks on (bob likes porridge), "likes" is Query::key().

Note:
the key, ie. the relation, is never a value concept.

bool Q::Query::light  )  const
 

true if the knowledge database in which the current fact is found is lightweight, and also this fact is light.

void Q::Query::next  ) 
 

Advance the iterator to the next result of the query or if the current result is the last result of the query, then set the state of the query to invalid.

Concept Q::Query::operator *  )  const [inline]
 

See also:
current

Query& Q::Query::operator++  )  [inline]
 

See also:
next

void Q::Query::removeCurrent  ) 
 

Delete the current fact, ie. (con relation value) from the knowledge database.

void Q::Query::reset  ) 
 

Set the iterator to point at the first result.

bool Q::Query::setCurrent const Concept value  ) 
 

Concise way of removing the current fact, eg. (con relation oldVal) and adding (con relation value). This is a handy way to change the value of facts used to store object properties.

bool Q::Query::valid  )  const
 

Is the iteration still valid?

Reimplemented from Q::ObjectBase.

Return to QSDK documentation Contents page. Contact details for support, information and fault-reporting.
Qube Software Limited © 2000-2004