00001 #ifndef Genotype_h
00002 #define Genotype_h
00003
00004 #include<string>
00005
00006
00007 class CrossoverOp;
00008 typedef boost::shared_ptr<CrossoverOp> CrossoverOpP;
00009 class MutationOp;
00010 typedef boost::shared_ptr<MutationOp> MutationOpP;
00011
00012
00013 class State;
00014 typedef boost::shared_ptr<State> StateP;
00015
00035 class Genotype
00036 {
00037 protected:
00038
00039 public:
00040 Genotype()
00041 { }
00042 virtual ~Genotype()
00043 { }
00044
00046 virtual bool initialize(StateP state) = 0;
00047
00049 virtual Genotype* copy() = 0;
00050
00052 virtual std::vector<CrossoverOpP> getCrossoverOp()
00053 {
00054 std::vector<CrossoverOpP> empty;
00055 return empty;
00056 }
00057
00059 virtual std::vector<MutationOpP> getMutationOp()
00060 {
00061 std::vector<MutationOpP> empty;
00062 return empty;
00063 }
00064
00066 virtual void registerParameters(StateP) {}
00067
00068 bool registerParameter(StateP state, std::string name, voidP value, enum ECF::type T, std::string description = "");
00069
00070 voidP getParameterValue(StateP state, std::string name);
00071
00072 bool setParameterValue(StateP state, std::string name, voidP value);
00073
00074 bool isParameterDefined(StateP state, std::string name);
00075
00077 virtual void read(XMLNode&) = 0;
00078
00080 virtual void write(XMLNode&) = 0;
00081
00082 virtual uint getGenomeSize()
00083 { return 0; }
00084
00086 std::string getName()
00087 { return name_; }
00088
00090 uint getGenotypeId()
00091 { return genotypeId_; }
00092
00094 void setGenotypeId(uint id)
00095 { genotypeId_ = id; }
00096
00098 std::string toString()
00099 {
00100 XMLNode xGene;
00101 write(xGene);
00102 char *s = xGene.createXMLString();
00103 std::string out(s);
00104 freeXMLString(s);
00105 return out;
00106 }
00107
00108 protected:
00109 std::string name_;
00110 uint genotypeId_;
00111 };
00112 typedef boost::shared_ptr<Genotype> GenotypeP;
00113
00114 #endif // Genotype_h
00115