File: AmbiguousRule.h

package info (click to toggle)
structure-synth 1.5.0-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,268 kB
  • ctags: 1,966
  • sloc: cpp: 10,209; python: 164; makefile: 71; sh: 15
file content (37 lines) | stat: -rw-r--r-- 954 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include "Rule.h"
#include "CustomRule.h"

namespace StructureSynth {
	namespace Model {	


		/// If several definitions for the same rule exists,
		/// an Ambiguous Rule is created which contains the multiple definitions.
		///
		/// When the rule is executed, a random rule is chosen from the multiple definitions,
	    /// taking their weights into account.
		class AmbiguousRule : public Rule {
		public:
			AmbiguousRule(QString name) : Rule(name) {};

			virtual void apply(Builder* builder) const;
	
			/// Returns a list over rules that this rule references.
			virtual QList<RuleRef*> getRuleRefs() const;

			QList<CustomRule*> getRules() { return rules; };
			
			void appendRule(CustomRule* r) { rules.append(r); }

			virtual void setMaxDepth(int maxDepth) { for (int i = 0; i < rules.size(); i++) rules[i]->setMaxDepth(maxDepth); }
			
		private:
			QList<CustomRule*> rules;
		};


	}
}