2.2.10.1. dg/Builder.hpp¶
2.2.10.1.1. Class dg::Builder¶
-
class
dg::Builder¶ An RAII-style object obtained from
DG::build(). On destruction of an active builder object the owningDGwill be locked for further modifications. Builder objects are move-only types, and a moved from object becomes an inactive builder, not associated with anyDG.
2.2.10.1.1.1. Synopsis¶
class MOD_DECL Builder {
friend class DG;
explicit Builder(lib::DG::NonHyperBuilder &dg_);
public:
Builder(Builder &&other);
Builder &operator=(Builder &&other);
~Builder();
bool isActive() const;
public:
DG::HyperEdge addDerivation(const Derivations &d);
DG::HyperEdge addDerivation(const Derivations &d, IsomorphismPolicy graphPolicy);
ExecuteResult execute(std::shared_ptr<Strategy> strategy);
ExecuteResult execute(std::shared_ptr<Strategy> strategy, int verbosity);
ExecuteResult execute(std::shared_ptr<Strategy> strategy, int verbosity, bool ignoreRuleLabelTypes);
// rst: - 10: Print information about morphism generation for rule composition.
// rst: - 20: Print rule composition information.
std::vector<DG::HyperEdge> apply(const std::vector<std::shared_ptr<graph::Graph> > &graphs,
std::shared_ptr<rule::Rule> r);
std::vector<DG::HyperEdge> apply(const std::vector<std::shared_ptr<graph::Graph> > &graphs,
std::shared_ptr<rule::Rule> r,
int verbosity);
std::vector<DG::HyperEdge> apply(const std::vector<std::shared_ptr<graph::Graph> > &graphs,
std::shared_ptr<rule::Rule> r,
int verbosity, IsomorphismPolicy graphPolicy);
void addAbstract(const std::string &description);
void load(const std::vector<std::shared_ptr<rule::Rule>> &ruleDatabase, const std::string &file, int verbosity);
private:
struct Pimpl;
std::unique_ptr<Pimpl> p;
};
2.2.10.1.1.2. Details¶
-
DG::HyperEdge
addDerivation(const Derivations &d)¶ -
DG::HyperEdge
addDerivation(const Derivations &d, IsomorphismPolicy graphPolicy)¶ Adds a hyperedge corresponding to the given derivation to the associated
DG. If it already exists, only add the given rules to the edge. The givengraphPolicyrefers to adding the graphs ind, and it defaults toIsomorphismPolicy::Check.- Returns
the hyperedge corresponding to the given derivation.
- Throws
LogicErrorif!isActive().- Throws
LogicErrorifd.left.empty().- Throws
LogicErrorifd.right.empty().- Throws
LogicErrorif anullptris ind.left,d.right, ord.rules.- Throws
LogicErrorifgraphPolicy == IsomorphismPolicy::Checkand a given graph object is different but isomorphic to another given graph object or to a graph object already in the internal graph database in the associated derivation graph.
Execute the given strategy (Derivation Graph Strategies) and as a side-effect add vertices and hyperedges to the underlying derivation graph.
The
verbositydefaults to level 2. The levels have the following meaning:0 (or less): no information is printed.
2: Repetition strategies print information for each round.
4: All strategies print minimal information.
6: Derivation predicate strategies and filtering strategies also print their predicates.
8: Rule strategies print minimal information about graph binding.
10: Rule strategies print more information about graph binding, including failure due to derivation predicates.
50: Print information about morphism generation for rule composition.
60: Print rule composition information.
- Throws
LogicErrorif a static “add” strategy hasIsomorphismPolicy::Checkas graph policy, and it tries to add a graph object isomorphic to an already known, but different, graph object in the database. This is checked before execution, so there is strong exception guarantee.- Throws
LogicErrorif a dynamic “add” strategy hasIsomorphismPolicy::Checkas graph policy, and it tries to add a graph object isomorphic to an already known, but different, graph object in the database.Warning
This is checked during execution, so while the basic exception guarantee is provided, there may be modifications to the underlying derivation graph.
- Throws
LogicErrorif a dynamic “add” strategy is executed where a returned graph is anullptr.Warning
This is checked during execution, so while the basic exception guarantee is provided, there may be modifications to the underlying derivation graph.
- Throws
LogicError: ifignoreRuleLabelTypesisfalse, which is the default, and a rule in the given strategy has an associatedLabelTypewhich is different from the one in the derivation graph.
Compute proper direct derivations with
graphsthe left-hand side andras the rule.The given
graphPolicyrefers to adding the graphs ingraphs, and it defaults toIsomorphismPolicy::Check.The
verbositydefaults to level 0. The levels have the following meaning:0 (or less): no information is printed.
2: Print minimal information about graph binding.
- Returns
a list of hyper edges representing the found direct derivations. The list may contain duplicates if there are multiple ways of constructing the same direct derivation when ignoring the specific match morphism.
- Throws
LogicErrorif there is anullptringraphs.- Throws
LogicErrorifr == nullptr.- Throws
LogicErrorifgraphPolicy == IsomorphismPolicy::Checkand a given graph object is different but isomorphic to another given graph object or to a graph object already in the internal graph database in the associated derivation graph.
-
void
addAbstract(const std::string &description)¶ Add vertices and hyperedges based on the given abstract description. The description must adhere to the grammar described at Abstract Derivation Graphs.
For each vertex named in the description a graph object with no vertices will be created, and its name set to the given identifier.
- Throws
InputErrorif the description could not be parsed.
Load and add a derivation graph dump. Use
DG::load()to load a dump as a locked derivation graph.The label settings of this DG and the ones retrieved from the dump file must match. Vertices with graphs and hyperedges with rules are then added from the dump. Any graph in the dump which is isomorphic to a graph in the internal graph database of the DG is replaced by the given graph. The same procedure is done for the rules, but compared against the given rules. If a graph/rule is not found in the given lists, a new object is instantiated and used.
See
DG::load()for an explanation of the verbosity levels.- Throws
LogicErrorif there is anullptrinruleDatabase.- Throws
LogicErrorif the label settings of the dump does not match those of this DG. :throws:InputErrorif the file can not be opened or its content is bad.
2.2.10.1.2. Class dg::ExecuteResult¶
-
class
dg::ExecuteResult¶ The result from calling
Builder::execute().
2.2.10.1.2.1. Synopsis¶
class MOD_DECL ExecuteResult {
friend class Builder;
explicit ExecuteResult(std::shared_ptr<DG> dg_, lib::DG::ExecuteResult innerRes);
public:
ExecuteResult(ExecuteResult &&other);
ExecuteResult &operator=(ExecuteResult &&other);
~ExecuteResult();
const std::vector<std::shared_ptr<graph::Graph>> &getSubset() const;
const std::vector<std::shared_ptr<graph::Graph>> &getUniverse() const;
void list(bool withUniverse) const;
private:
struct Pimpl;
std::unique_ptr<Pimpl> p;
};
2.2.10.1.2.2. Details¶
-
const std::vector<std::shared_ptr<graph::Graph>> &
getSubset() const¶ -
const std::vector<std::shared_ptr<graph::Graph>> &
getUniverse() const¶ - Returns
respectively the subset and the universe computed by the strategy execution (see also Derivation Graph Strategies).
-
void
list(bool withUniverse) const¶ Output information from the execution of the strategy. The universe lists can be rather long so with
withUniverse == falsethey are omitted.