00001
00002
00003
00004
00006 #ifndef _FUZZYRULE_H_
00007 #define _FUZZYRULE_H_
00008
00009 #include <string>
00010 #include <vector>
00011 #include "BufferedNode.h"
00012 #include "Object.h"
00013 #include "Vector.h"
00014
00015 namespace FD {
00016
00017 class FuzzyRule : public BufferedNode {
00018
00019 public:
00020
00021 friend std::istream& operator>> (std::istream &in, FuzzyRule &rule);
00022 friend std::ostream& operator<< (std::ostream &out, FuzzyRule &rule);
00023
00024
00025
00026 void print_rule (std::ostream &out);
00027
00028
00029 void add_consequent (const std::string &set_name, const std::string &funct_name);
00030
00031
00032 void add_antecedant(const std::string& set_name, const std::string &funct_name);
00033
00034
00035 FuzzyRule();
00036
00037
00038 FuzzyRule(int rule_number);
00039
00040 FuzzyRule(const FuzzyRule& cpy);
00041
00042 FuzzyRule(std::string nodeName, ParameterSet params);
00043
00044 FuzzyRule(std::istream &in);
00045
00046
00047 virtual ~FuzzyRule();
00048
00049
00050 std::vector<std::pair<std::string,std::string> >& get_antecedant_part() {return m_antecedant;}
00051
00052
00053 std::vector<std::pair<std::string,std::string> >& get_consequent_part() {return m_consequent;}
00054
00055
00056 int get_rule_number() {return m_rule_number;}
00057
00058 void set_rule_number(int rule_number) {m_rule_number = rule_number;}
00059
00060 virtual void calculate(int output_id, int count, Buffer &out);
00061
00062 virtual ObjectRef clone();
00063
00064 virtual void printOn(std::ostream &out=std::cout) const;
00065
00066 virtual void readFrom(std::istream &in=std::cin);
00067
00068 private:
00069
00070
00071 std::vector<std::pair<std::string,std::string> > m_antecedant;
00072
00073
00074 std::vector<std::pair<std::string,std::string> > m_consequent;
00075
00076
00077 int m_rule_number;
00078
00079 int m_ruleID;
00080 };
00081
00082 template<>
00083 inline void Vector<FuzzyRule*>::printOn(std::ostream &out) const {
00084 for (int i = 0; i < size(); i++) {
00085 operator[](i)->printOn(out);
00086 }
00087 }
00088
00089 template<>
00090 inline void Vector<FuzzyRule*>::destroy() {
00091
00092 for (Vector<FuzzyRule*>::iterator iter = this->begin();
00093 iter != this->end(); iter++) {
00094 delete (*iter);
00095 }
00096
00097 delete this;
00098 }
00099
00100 }
00101
00102 #endif