Lumiera  0.pre.03
»edit your freedom«
Query< RES > Class Template Reference

#include "common/query.hpp"

Description

template<class RES>
class lumiera::Query< RES >

Generic interface to express a query for specifically typed result elements exposing some capabilities or fulfilling some properties.

This is a generic umbrella for several kinds of queries and provides a mechanism for uniform usage of various resolution mechanisms.

Any query bears internal type classification and can be represented in a common syntactical form based on predicate logic. Query instances are created by some facilities allowing to query for objects. These query providers do know the specific kind (type) of query to expose. While client code uses these queries only by reference, there is the possibility to involve a generic QueryResolver, which – behind the scenes – manages a registry of specific resolution mechanisms. This way, clients may retrieve a set of results, where each result represents a possible solution to the original query.

Remarks
lumiera::Query is an interface, but can be used as-is to represent a generic query. Specialised subclasses are required to provide a syntactic representation, but are free to do so only on demand. In this case, generate an empty lib::QueryText definition and implement the Query::buildSyntacticRepresentation function. Every fundamentally different kind of query needs to be listed in Goal::Kind.
Note
until we really integrate a rules based system this can be considered dummy placeholder implementation. Some more specific query resolvers are available already, so, depending on the circumstances the actual resolution might be substantial or just a fake.
Warning
especially the classical resolution-type queries are just faked and use the given query-string as-is, without any normalisation. Moreover, as especially the fake-configrules match by string comparison, this may led to unexpected mis-matches. This is dummy code, after all.

Definition at line 270 of file query.hpp.

Public Types

typedef lib::IterAdapter< Cursor, PResoiterator
 
- Public Types inherited from Goal
enum  Kind {
  EMPTY = 0,
  GENERIC = 1,
  DISCOVERY,
  PLACEMENT
}
 

Public Member Functions

 Query (string querySpec)
 
string extractID (Symbol predicate) const
 convenience shortcut to extract a desired name-ID. More...
 
 operator QueryKey () const
 automatic conversion from Query to QueryKey for indexing and ordering. More...
 
iterator operator() (QueryResolver const &resolver) const
 notational convenience shortcut, synonymous to Query<RES>::resolveBy()
 
Builder rebuild () const
 
iterator resolveBy (QueryResolver const &resolver) const
 
bool usesPredicate (Symbol predicate) const
 
- Public Member Functions inherited from Goal
virtual ~Goal ()
 this is a marker baseclass
 
QueryID const & getQID () const
 

Static Public Member Functions

static Builder build (Kind queryType=Goal::GENERIC)
 

Classes

class  Builder
 Helper for establishing, reworking and remolding queries. More...
 
class  Cursor
 

Friends

class Builder
 
size_t hash_value (Query const &q)
 

Protected Member Functions

 Query (QueryID typeID, lib::QueryText const &genericQuerySpec)
 
 Query (QueryID typeID, string querySpec)
 
virtual lib::QueryText buildSyntacticRepresentation () const
 Extension point to generate a generic query definition on demand. More...
 
lib::QueryText getQueryDefinition () const
 access the complete syntactical representation of this query. More...
 
- Protected Member Functions inherited from Goal
 Goal (QueryID qid)
 

Static Protected Member Functions

static QueryID defineQueryTypeID (Kind queryType=Goal::GENERIC)
 

Private Attributes

lib::QueryText def_
 generic syntactical definition
 

Additional Inherited Members

- Protected Attributes inherited from Goal
QueryID id_
 

Member Function Documentation

◆ buildSyntacticRepresentation()

virtual lib::QueryText buildSyntacticRepresentation ( ) const
inlineprotectedvirtual

Extension point to generate a generic query definition on demand.

Some specialised kinds of queries, intended to be treated by a specific resolver, may choose skip constructing a generic query representation, but are then bound to supplement such a generic definition through this function when required. The generated query definition must be sufficient to reconstruct the query in all respects.

Returns
a complete definition of this query in predicate form
Return values
bottomtoken to indicate failure to comply to this requirement.

Reimplemented in ScopeQuery< MO >.

Definition at line 295 of file query.hpp.

◆ getQueryDefinition()

lib::QueryText getQueryDefinition ( ) const
inlineprotected

access the complete syntactical representation of this query.

May trigger on-demand initialisation

Definition at line 304 of file query.hpp.

◆ operator QueryKey()

operator QueryKey ( ) const
inline

automatic conversion from Query to QueryKey for indexing and ordering.

By defining a parameter of type QueryKey, any provided Query will be automatically transformed into an generic representation usable for ordered storage in sets, maps and for generation of metrics.

Definition at line 607 of file query.hpp.

◆ extractID()

string extractID ( Symbol  predicate) const
inline

convenience shortcut to extract a desired name-ID.

Todo:
used extensively for the mock implementation of query resolution. For real resolution queries, such a function is quite nonsensical. To be revisited and (likely) to be removed on the long run
See also
Query::Builder::extractID

Definition at line 586 of file query.hpp.

Referenced by StructFactoryImpl::createIdent(), MockTable::detect_case(), MockTable::fabricate_Sequence_on_demand(), MockTable::fabricate_Timeline_on_demand(), and steam::mobject::_mapping::is_defaults_query_with_channel().

+ Here is the caller graph for this function:
+ Inheritance diagram for Query< RES >:
+ Collaboration diagram for Query< RES >:

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