00001 #ifndef __GENOTYPEDECODER_H 00002 #define __GENOTYPEDECODER_H 00003 00004 #include <ishtar/settings.h> 00005 #include <an/Geometry.h> 00006 #include "../utils/Graph.h" 00007 00016 namespace Teem 00017 { 00018 class Controller; 00019 class Genome; 00020 00026 class GenotypeDecoder 00027 { 00028 public: 00030 GenotypeDecoder(const std::string &root) { inputCount = 0; outputCount = 0; this->root = root; } 00032 virtual ~GenotypeDecoder() {} 00033 00035 virtual void controllerIOSetup(unsigned inCount, unsigned outCount) { inputCount = inCount; outputCount = outCount; } 00036 00038 virtual Genome* createGenome() = 0; 00039 00041 virtual Controller* decode(Genome *genome) = 0; 00042 00043 protected: 00044 00045 unsigned inputCount; 00046 unsigned outputCount; 00047 std::string root; 00048 }; 00049 00054 class DummyGenotypeDecoder : public GenotypeDecoder 00055 { 00056 public: 00058 DummyGenotypeDecoder(const std::string &root); 00060 virtual ~DummyGenotypeDecoder() { } 00062 virtual Controller* decode(Genome *genome) { return 0; } 00063 00065 virtual Genome* createGenome(); 00067 void setGenomeLength(size_t len) { genomeLength = len; } 00068 00069 protected: 00070 size_t genomeLength; 00071 }; 00072 00081 class GraphGenotypeDecoder : public GenotypeDecoder 00082 { 00083 public: 00085 GraphGenotypeDecoder(const std::string &root) : GenotypeDecoder(root) { graphFilter = NULL; } 00087 virtual ~GraphGenotypeDecoder() {} 00088 00090 void setGraphFilter(Graph::Filter *filter) { graphFilter = filter; } 00091 00092 protected: 00093 Graph::Filter* graphFilter; 00094 00097 void callFilter(Graph* graph) { if (graphFilter) graphFilter->filter(graph); } 00098 }; 00099 } 00100 00101 #endif