65#ifndef LUMIERA_QUERY_H
66#define LUMIERA_QUERY_H
78#include <boost/lexical_cast.hpp>
93 using boost::lexical_cast;
106 typedef std::shared_ptr<Resolution>
PReso;
163 template<
typename RES>
168 return *
reinterpret_cast<RES*
> (
cur_);
172 explicit operator bool()
const {
return isValid(); }
197 template<
typename RES>
262 QueryID id(queryType, getResultTypeID<RES>());
279 WARN (query,
"internal query not outfitted with a suitable query definition");
280 return string(
"bottom");
288 if (isnil(this->def_))
298 ,
def_(genericQuerySpec)
380 ENSURE (!isnil(
def_));
394 REQUIRE (getResultTypeID<RES>() ==
id_.
type);
401 return "kind=" + lexical_cast<string>(
id_.
kind)
402 +
",type=" + lexical_cast<string>(
id_.
type)
403 +
",def=" + string(
def_);
426 friend std::strong_ordering
431 if (
auto o1 = d1 <=> d2; o1 != 0)
433 if (
auto o2 = q1.
def_ <=> q2.
def_; o2 != 0)
463 , predicateForm_(baseDef)
466 friend class Query<RES>;
485 + lexical_cast<string> (getResultTypeID<RES>())
486 +
"), "+predicateForm_;
516 this->predicateForm_ =
524 this->predicateForm_ =
532 this->predicateForm_ = queryPredicates;
544 return Builder(defineQueryTypeID (queryType));
552 return Builder(this->id_, getQueryDefinition());
566 return this->rebuild().extractID (predicate);
587 return QueryKey (this->id_, getQueryDefinition());
Adapter for building an implementation of the »Lumiera Forward Iterator« concept.
Syntactical query representation.
uint degree_of_constriction() const
synthetic total order to classify query definitions.
Token or Atom with distinct identity.
Provide type-IDs for a specific context.
Single Solution, possibly part of a result set.
Result()
create an NIL result
Query ABC: unspecific goal for resolution or retrieval.
virtual ~Goal()
this is a marker baseclass
QueryID const & getQID() const
Wrapper for indexing and ordering.
QueryKey()
the empty or bottom query key
friend size_t hash_value(QueryKey const &q)
string getQueryString() const
friend std::strong_ordering operator<=>(QueryKey const &q1, QueryKey const &q2)
QueryKey(Goal::QueryID id, lib::QueryText q)
bool operator==(QueryKey const &) const =default
Interface: a facility for resolving (some kind of) queries A concrete subclass has the ability to cre...
Helper for establishing, reworking and remolding queries.
Builder(QueryID kind, string baseDef="")
Builder & prependConditions(string additionalQueryPredicates)
Builder & fromText(string queryPredicates)
Builder & removeTerm(Symbol termPredicate)
remove the first term from this query definition, which matches the given predicate symbol
Builder & withConditions(string additionalQueryPredicates)
string extractID(Symbol predicate) const
extract an ID term defined as (single) parameter for the given predicate.
Generic interface to express a query for specifically typed result elements exposing some capabilitie...
iterator operator()(QueryResolver const &resolver) const
notational convenience shortcut, synonymous to Query<RES>::resolveBy()
static Builder build(Kind queryType=Goal::GENERIC)
static QueryID defineQueryTypeID(Kind queryType=Goal::GENERIC)
Query(QueryID typeID, string querySpec)
Query(QueryID typeID, lib::QueryText const &genericQuerySpec)
bool usesPredicate(Symbol predicate) const
lib::QueryText def_
generic syntactical definition
virtual lib::QueryText buildSyntacticRepresentation() const
Extension point to generate a generic query definition on demand.
lib::IterAdapter< Cursor, PReso > iterator
friend size_t hash_value(Query const &q)
string extractID(Symbol predicate) const
convenience shortcut to extract a desired name-ID.
lib::QueryText getQueryDefinition() const
access the complete syntactical representation of this query.
iterator resolveBy(QueryResolver const &resolver) const
Types marked with this mix-in may be duplicated by copy-construction, yet may not be moved or transfe...
Hash combine function extracted from LibBoost 1.67 Combine two hash values to form a composite depend...
Helper template(s) for creating Lumiera Forward Iterators.
void combine(size_t &combinedHash, size_t additionalHash)
meld the additional hash value into the given base hash value.
bool hasTerm(Symbol sym, string const &queryString)
string appendTerms(string const &pred1, string const &pred2)
string extractID(Symbol sym, const string &termString)
(preliminary) helper: instead of really parsing and evaluating the terms, just do a regular expressio...
string removeTerm(Symbol sym, string &queryString)
(preliminary) helper: cut a term with the given symbol.
size_t taggedHash(size_t hash, Goal::QueryID typeID)
includes the QueryID type distinction into the given hash value
Lumiera public interface.
std::shared_ptr< Resolution > PReso
Allow to take ownership of a result set.
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
bool isnil(lib::time::Duration const &dur)
Mix-Ins to allow or prohibit various degrees of copying and cloning.
A generic syntactical representation for all kinds of queries.
Utilities to support working with predicate queries.
QueryID(Kind k=EMPTY, IxID t=1)
auto operator<=>(QueryID const &) const =default
Marker types to indicate a literal string and a Symbol.
Creating series of type-based contexts.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...