initial revision
[lsystem3d.git] / src / rule.h
diff --git a/src/rule.h b/src/rule.h
new file mode 100644 (file)
index 0000000..fcef31f
--- /dev/null
@@ -0,0 +1,130 @@
+// Copyright (C) 2006 Erik Dahlberg
+// 
+// This file is part of LSystem3D.
+// 
+// LSystem3D is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+// 
+// LSystem3D is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with LSystem3D; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+
+
+#ifndef RULE_H
+#define RULE_H
+
+#include <string>
+
+using namespace std;
+
+
+
+/**
+ * L-system rule
+ */
+class Rule
+{
+public:
+    
+    /**
+     * Constructor
+     */
+    Rule();
+    
+    /**
+     * Constructor
+     * @param name name of rule
+     * @param content content of rule
+     * @param probability probability of rule
+     */
+    Rule(string name, string content, double probability);
+    
+    /**
+     * Constructor
+     * @param ruleString the rule string
+     */
+    Rule(string ruleString);
+    
+    /**
+     * Destructor
+     */
+    ~Rule();
+    
+    /**
+     * Clear rule
+     */
+    void clear();
+    
+    /**
+     * Construct rule from string
+     * @param ruleString the rule string
+     */
+    void fromString(string ruleString);
+    
+    /**
+     * Construct rule string
+     * @return the rule string
+     */
+    string toString();
+    
+    /**
+     * Set rule name
+     * @param name the name
+     */
+    void setName(string name);
+    
+    /**
+     * Set rule content
+     * @param content the content
+     */
+    void setContent(string content);
+    
+    /**
+     * Set rule probability
+     * @param probability the probability factor
+     */
+    void setProbability(double probability);
+    
+    /**
+     * Get rule name
+     * @return the rule name
+     */
+    string getName();
+    
+    /**
+     * Get rule content
+     * @return the rule content
+     */
+    string getContent();
+    
+    /**
+     * Get rule probability
+     * @return the probability
+     */
+    double getProbability();
+    
+    /**
+     * Get preprocessed content
+     * @return the preprocessed content
+     */
+    string getPreprocessedContent();
+    
+protected:
+        
+    string _name;
+    string _content;
+    double _probability;
+};
+
+
+
+#endif