Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Implementation datastructure for use by the Advice system.
To support the Advice collaboration, it is necessary to match advice requests with existing advice provisions. Each successful match creates an advice solution, resulting in the bound piece of advice (data) to become visible to all the advised entities having placed a matching advice request into the advice system.
This header is intended to be incorporated as part of the advice system implementation (advice.cpp). It is not usable as an external interface. But it is written in a rather self-contained manner, in order to be testable in isolation. To this end, the actual PointOfAdvice entities being organised by this index datastructure remain abstract (defined as template parameter), and are only manipulated through the following functions:
hash_value(POA)
POA::getMatcher()
POA::getSolution()
POA::setSolution(solution*)
While both hashtables are organised by the binding pattern hash, the individual buckets are coded explicitly as ProvisionCluster and RequestCluster – both based on a vector of entries. In case of the provisions, there is a stack-like order, inasmuch additions happen at the back and solutions are always searched starting from the end. Because of the basic structure of a binding match, solutions are possible only between provision/request - clusters with the same hash value (which is based on the predicate symbols within the patterns to match). Thus, in case of changing an existing request or solution, the internal handling is different, depending on the new value to belong or don't belong to the same cluster (hash code). It's possible (for patterns including variables) that an entry leading to a solution with the old provision doesn't match a new provision (and vice versa); thus we'll have to traverse the contents of the whole cluster, find all old solutions, match against the new counterpart and treating those entries not matching with the new value as if they where completely newly added entries. In case we don't find any solution, the entries are supposed to be implemented such as to fall back to an default solution automatically (when receiving a NULL
solution)
Definition in file index.hpp.
#include "lib/error.hpp"
#include "lib/symbol.hpp"
#include "include/logging.h"
#include "lib/iter-adapter-stl.hpp"
#include "lib/format-obj.hpp"
#include "lib/util-foreach.hpp"
#include "lib/util.hpp"
#include "common/advice/binding.hpp"
#include <boost/operators.hpp>
#include <unordered_map>
#include <string>
Classes | |
struct | Index< POA >::Cluster |
struct | Index< POA >::Entry |
class | Index< POA > |
Index datastructure for organising advice solutions. More... | |
struct | Index< POA >::ProvisionCluster |
struct | Index< POA >::RequestCluster |
struct | SelfCheckFailure |
Macros | |
#define | VERIFY(_CHECK_, DESCRIPTION) |
Functions | |
LUMIERA_ERROR_DEFINE (INDEX_CORRUPTED, "Advice-Index corrupted") | |
Namespaces | |
lumiera | |
Lumiera public interface. | |