65 #ifndef LUMIERA_ADVICE_BINDING_H 66 #define LUMIERA_ADVICE_BINDING_H 114 Atom (
string const& symbol =
"nil", uint arity =0,
string const& arg =
"")
115 : ari_(arity), sym_(symbol), arg_(arg)
118 string const& sym()
const {
return sym_; }
119 string const& arg()
const {
return arg_; }
120 uint arity()
const {
return ari_; }
122 operator string()
const;
125 identical (
Atom const& oa)
const 127 return ari_ == oa.ari_
136 if (0 != (res=sym().
compare (oa.sym())))
return res;
137 if (0 != (res=arity() - (oa.arity())))
return res;
138 return arg().compare (oa.arg());
142 operator< (
Atom const& a1,
Atom const& a2)
149 typedef std::set<Atom> NormalisedAtoms;
151 NormalisedAtoms atoms_;
174 bool matches (
Binding const& obi)
const;
197 template<
typename TY>
204 operator string()
const;
215 template<
typename TY>
217 Binding::addTypeGuard()
219 atoms_.insert (
Atom (
"advice.type."+lib::query::buildTypeID<TY>()));
232 return not (b1 == b2);
239 return b1.buildMatcher().matches (b2);
245 return m1.matches (m2);
250 Binding::buildMatcher()
const 252 return Matcher (this->calculateHash());
260 Binding::Matcher::matches (
Binding const& obi)
const 262 return bindingHash_ == obi.calculateHash();
268 return bindingHash_ == hash_value(oma);
274 return bm.bindingHash_;
280 return bi.calculateHash();
Utilities to support working with predicate queries.
Conjunction of predicates to be matched against a collaboration partner for establishing an Advice co...
friend bool operator==(Binding const &, Binding const &)
bindings are considered equivalent if, after normalisation, their respective definitions are identica...
void parse_and_append(Literal def)
internal: parse into atoms, and insert them
Functor object for matching against another Binding.
inline string literal This is a marker type to indicate that
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
single predicate as part of an advice binding pattern
Marker types to indicate a literal string and a Symbol.
Lumiera error handling (C++ interface).
Hash value types and utilities.
void addPredicate(Literal spec)
extend the definition of this binding by adding a predicate according to the given textual definition...
size_t HashVal
a STL compatible hash value
Lumiera public interface.
int compare(Atom const &oa) const
<
Binding()
create the empty binding, equivalent to true