2.2.13.1. rule/Composer.hpp

2.2.13.1.1. Class rule::Composer

class rule::Composer

This class can evaluate rule composition expressions. During evaluation an expression graph is recorded.

The expression graph is a directed hypergraph \((V, E)\), with each vertex representing a rule. Each edge represent all compositions calculated for a unique input. That is every edge \(e\in E\) is on the form \(((u, v), R_e)\) with \((u, v)\in V\times V\) as an ordered pair of rules and \(R_e\subseteq V\) is the set of all resulting rules found.

The graph is visualised as a bipartite graph with point-shaped vertices representing the hyperedges. The in-edges to these hyperedge vertices are labelled with 1 and 2.

2.2.13.1.1.1. Synopsis

class MOD_DECL Composer {
    Composer(const std::unordered_set<std::shared_ptr<Rule> > &database, LabelSettings labelSettings);
    Composer(Composer &&) = delete;
    Composer &operator=(Composer &&) = delete;
public:
    ~Composer();
    const std::unordered_set<std::shared_ptr<Rule>> &getRuleDatabase() const;
    const std::unordered_set<std::shared_ptr<Rule>> &getProducts() const;
    std::unordered_set<std::shared_ptr<Rule>> eval(const RCExp::Expression &exp, int verbosity);
    void print() const;
private:
    struct Pimpl;
    std::unique_ptr<Pimpl> p;
public:
    static std::shared_ptr<Composer> create(const std::unordered_set<std::shared_ptr<Rule> > &database,
                                                         LabelSettings labelSettings);
};

2.2.13.1.1.2. Details

const std::unordered_set<std::shared_ptr<Rule>> &getRuleDatabase() const
Returns

the set of unique rules known by the evaluator.

const std::unordered_set<std::shared_ptr<Rule>> &getProducts() const
Returns

the set of unique rules this evaluator has constructed.

std::unordered_set<std::shared_ptr<Rule>> eval(const RCExp::Expression &exp, int verbosity)

Evaluates a rule composition expression. Any created rule is replaced by a rule in the database if they are isomorphic.

The verbosity has the following meaning:

  • 0 (or less): no information is printed.

  • 10: Print information about morphism generation for rule composition.

  • 20: Print rule composition information.

Returns

the result of the expression.

void print() const

Print the graph representing all expressions evaluated so far.

static std::shared_ptr<Composer> create(const std::unordered_set<std::shared_ptr<Rule>> &database, LabelSettings labelSettings)
Returns

a new instance of an evaluator with its database initialised with the given rules.

Note

The caller is responsible for ensuring the given rules are unique.