Lumiera  0.pre.03
»edit your freedom«
common/advice/binding.hpp File Reference

Go to the source code of this file.

Description

A pattern to define and identify a specific attachment to the Advice system.

This pattern is comprised of a predicate list and intended to be matched or unified against a similar pattern associated with the attachment of a possible collaboration partner. Semantically, this list of atoms forms an conjunction of predicates to be resolved against similar predicates of the partner. Informally, when two entities attach to the Advice system, each specifying a binding, they can be paired up if any condition included into the binding holds true for both sides.

Typically, a binding includes a type-guard predicate advice.type.xx where xx is an identifier denoting a type used within an instantiation of the Advice collaboration, i.e. a type used as advice value in a instantiation of the PointOfAdvice<AD> template. Besides the type guard, a binding may narrow down the topic of the advice by providing further predicates. This allows for Advice collaborations targeted at a more specific topic. The goal and intention behind this Advice system is to allow collaboration of entities without requiring them to be tightly coupled. Indeed, the only dependency besides the common type used as advice is to know any specific topic used within the binding. Thus, and advisor entity could put up a piece of advice, i.e. a value of the advice type, and another client entity (the advised entity) could pick up this value without the need to now anything about the advisor.

implementation notes

Any binding will be normalised prior to further processing. This normalisation is based on ordering by predicate symbol and arity. Patterns just comprised of constant symbols (nullary atoms) can even be condensed into a single hash value, which allows for fast match checking. For each pattern, we provide a matcher functor, allowing to check a match against this pattern. In case of the mentioned symbol-only patterns, this matcher will just hold the hash value of the normalised pattern.

The advice system uses a binding index datastructure to keep track of any participating patterns and especially of the matching pairs. Actually, this datastructure needs to store only these matcher functors; thus, for a new binding to be used within the advice system, the symbolic definition is parsed, then normalised and finally, after creating the matcher functor, the full pattern definition can be discarded.

Remarks
while binding is defined in the context of the advice system for now, obviously this is the foundation of a more generic system to deal with predicate terms.
Note
as of 4/2010 this is an experimental setup and implemented just enough to work out the interfaces. Ichthyo expects this collaboration service to play a central role at various places within steam-layer.
Todo:
for now, only the case of a completely constant (ground) pattern is implemented. Later we may consider to extend the binding patterns to allow variables, which, on match could be fed as parameters to the bound advice. But this extension requires to extend the simple hash-based match check to an actual unification of the patterns. ///TICKET #615
See also
advice.hpp
advice-binding-pattern-test.cpp

Definition in file common/advice/binding.hpp.

#include "lib/error.hpp"
#include "lib/symbol.hpp"
#include "lib/hash-value.h"
#include "lib/query-util.hpp"
#include <string>
#include <set>

Classes

class  Binding::Atom
 single predicate as part of an advice binding pattern More...
 
class  Binding
 Conjunction of predicates to be matched against a collaboration partner for establishing an Advice connection. More...
 
class  Binding::Matcher
 Functor object for matching against another Binding. More...
 

Functions

HashVal hash_value (Binding::Matcher const &bm)
 
HashVal hash_value (Binding const &bi)
 
 LUMIERA_ERROR_DECLARE (BINDING_PATTERN_SYNTAX)
 Unable to parse the given binding pattern definition.
 
bool matches (Binding const &b1, Binding const &b2)
 
bool matches (Binding::Matcher const &m1, Binding::Matcher const &m2)
 
bool operator!= (Binding const &b1, Binding const &b2)
 

Namespaces

 lumiera
 Lumiera public interface.