Changeset 35


Ignore:
Timestamp:
10/31/09 14:44:45 (15 years ago)
Author:
Maciej Komosinski
Message:

simple productions are now more complete, and stored once, in a constant variable

Location:
cpp/f8-to-f1
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpp/f8-to-f1/conv_f8tof1.cpp

    r33 r35  
    2727using namespace std;
    2828
    29 Lsystem::Lsystem() {
    30         PrimitiveProduction *pp1 = new PrimitiveProduction(SString("X"));
    31         this->primitiveProductions.insert(make_pair("X", pp1));
    32         PrimitiveProduction *pp2 = new PrimitiveProduction(SString("R"));
    33         this->primitiveProductions.insert(make_pair("R", pp2));
    34         PrimitiveProduction *pp3 = new PrimitiveProduction(SString("r"));
    35         this->primitiveProductions.insert(make_pair("r", pp3));
    36         PrimitiveProduction *pp4 = new PrimitiveProduction(SString("C"));
    37         this->primitiveProductions.insert(make_pair("C", pp4));
    38         PrimitiveProduction *pp5 = new PrimitiveProduction(SString("c"));
    39         this->primitiveProductions.insert(make_pair("c", pp5));
    40         PrimitiveProduction *pp6 = new PrimitiveProduction(SString("Q"));
    41         this->primitiveProductions.insert(make_pair("Q", pp6));
    42         PrimitiveProduction *pp7 = new PrimitiveProduction(SString("q"));
    43         this->primitiveProductions.insert(make_pair("q", pp7));
    44         PrimitiveProduction *pp8 = new PrimitiveProduction(SString("["));
    45         this->primitiveProductions.insert(make_pair("[", pp8));
    46         PrimitiveProduction *pp9 = new PrimitiveProduction(SString("]"));
    47         this->primitiveProductions.insert(make_pair("]", pp9));
    48         PrimitiveProduction *pp10 = new PrimitiveProduction(SString("^"));
    49         this->primitiveProductions.insert(make_pair("^", pp10));
    50        
    51 }
    52                  
     29Lsystem::Lsystem()
     30{
     31        for(int i=0;i<strlen(GenoConv_F8ToF1::simpleprods);i++)
     32        {
     33                string s(1,GenoConv_F8ToF1::simpleprods[i]);
     34                SString ss(s.c_str());
     35                this->primitiveProductions.insert(make_pair(s, new PrimitiveProduction(ss)));
     36        }
     37}
     38
    5339Lsystem::~Lsystem() {
    54         for (map<string, Production*>::iterator iter = this->productions.begin(); 
     40        for (map<string, Production*>::iterator iter = this->productions.begin();
    5541                 iter != this->productions.end(); iter++) {
    5642                delete iter->second;
    5743        }
    58         for (map<string, PrimitiveProduction*>::iterator iter = this->primitiveProductions.begin(); 
     44        for (map<string, PrimitiveProduction*>::iterator iter = this->primitiveProductions.begin();
    5945                 iter != this->primitiveProductions.end(); iter++) {
    6046                delete iter->second;
     
    524510
    525511
     512const char* GenoConv_F8ToF1::simpleprods="X[]^RrLlAaCcFfMmSsIiQqWw"; //Ee skipped
     513
     514
    526515#define FIELDSTRUCT GenoConv_F8ToF1
    527516
  • cpp/f8-to-f1/conv_f8tof1.h

    r33 r35  
    249249
    250250        int maxF1Length;
     251        static const char* simpleprods;
     252
    251253protected:
    252254        bool parseInput(const char* src, Lsystem* lsys);
  • cpp/f8-to-f1/geno_f8.cpp

    r34 r35  
    5050}
    5151
    52 Geno_f8::Geno_f8() {
     52Geno_f8::Geno_f8()
     53{
    5354        supported_format = '8';
    54         this->simpleCommandLetters.push_back('X');
    55         this->simpleCommandLetters.push_back('R');
    56         this->simpleCommandLetters.push_back('r');
    57         this->simpleCommandLetters.push_back('C');
    58         this->simpleCommandLetters.push_back('c');
    59         this->simpleCommandLetters.push_back('Q');
    60         this->simpleCommandLetters.push_back('q');
    61         this->simpleCommandLetters.push_back('[');
    62         this->simpleCommandLetters.push_back(']');
    63         this->simpleCommandLetters.push_back('^');
     55
     56        for(int i=0;i<strlen(GenoConv_F8ToF1::simpleprods);i++)
     57                this->simpleCommandLetters.push_back(GenoConv_F8ToF1::simpleprods[i]);
     58               
    6459        this->converter = new GenoConv_F8ToF1();
    6560
     
    301296SString Geno_f8::mutateChangeArg(SString &in, float& chg) {
    302297        SString mutated;
    303        
     298
    304299        Lsystem *newLsystem = this->converter->createLsystem(in);
    305300        if (newLsystem == NULL) {
     
    10871082       
    10881083#if GENO_F8_DEBUG > 0
    1089         string mutationName = (method == 0) ? "F8_CHANGE_BEGINNING_ARG" :
     1084        string mutationName = (method == 0) ? "F8_CHANGE_BEGINNING_ARG" : //TODO use mutation_method_names[] here
    10901085        (method == 1) ? "F8_CHANGE_ARG" :
    10911086        (method == 2) ? "F8_DELETE_COMMAND" :
Note: See TracChangeset for help on using the changeset viewer.