74 #ifndef LUMIERA_ADVICE_BINDING_H 75 #define LUMIERA_ADVICE_BINDING_H 123 Atom (
string const& symbol =
"nil", uint arity =0,
string const& arg =
"")
124 : ari_(arity), sym_(symbol), arg_(arg)
127 string const& sym()
const {
return sym_; }
128 string const& arg()
const {
return arg_; }
129 uint arity()
const {
return ari_; }
131 operator string()
const;
134 identical (
Atom const& oa)
const 136 return ari_ == oa.ari_
145 if (0 != (res=sym().
compare (oa.sym())))
return res;
146 if (0 != (res=arity() - (oa.arity())))
return res;
147 return arg().compare (oa.arg());
151 operator< (
Atom const& a1,
Atom const& a2)
158 typedef std::set<Atom> NormalisedAtoms;
160 NormalisedAtoms atoms_;
183 bool matches (
Binding const& obi)
const;
206 template<
typename TY>
213 operator string()
const;
224 template<
typename TY>
226 Binding::addTypeGuard()
228 atoms_.insert (
Atom (
"advice.type."+lib::query::buildTypeID<TY>()));
241 return not (b1 == b2);
248 return b1.buildMatcher().matches (b2);
254 return m1.matches (m2);
259 Binding::buildMatcher()
const 261 return Matcher (this->calculateHash());
269 Binding::Matcher::matches (
Binding const& obi)
const 271 return bindingHash_ == obi.calculateHash();
277 return bindingHash_ == hash_value(oma);
283 return bm.bindingHash_;
289 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