1
#include "CustomRule.h"
3
#include "../../SyntopiaCore/Logging/Logging.h"
6
using namespace SyntopiaCore::Logging;
8
namespace StructureSynth {
11
CustomRule::CustomRule(QString name) : Rule(name) {
16
CustomRule::~CustomRule() {
17
delete (retirementRule);
20
void CustomRule::apply(Builder* b) const {
23
/// If there is a maxdepth set for this object check it.
24
if (getMaxDepth() != -1) {
25
if (!b->getState().maxDepths.contains(this)) {
26
/// We will add a new maxdepth for this rule to the state.
27
newDepth = getMaxDepth()-1;
30
int depth = b->getState().maxDepths[this];
32
/// This rule is retired.
34
retirementRule->rule()->apply(b);
44
/// Apply all actions.
45
for (int i = 0; i < actions.size(); i++) {
46
if (getMaxDepth() != -1) {
47
actions[i].apply(b, this, newDepth);
49
actions[i].apply(b, 0 ,0);
54
QList<RuleRef*> CustomRule::getRuleRefs() const {
56
for (int i = 0; i < actions.size(); i++) {
57
RuleRef* a = actions[i].getRuleRef();
58
if (a) list.append(a);
60
if (retirementRule) list.append(retirementRule);