Changeset 551


Ignore:
Timestamp:
07/30/16 03:19:31 (8 years ago)
Author:
Maciej Komosinski
Message:

PreconfiguredGenetics? warns about unexpected use case and unregisters its objects on destruction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/preconfigured.h

    r348 r551  
    2424        {
    2525        gcm.addDefaultConverters(); //without converters, the application would only handle "format 0" genotypes
    26         Geno::useConverters(&gcm);
    27 
    28         Geno::useValidators(&validators);
     26        if (Geno::useConverters(&gcm)!=NULL)
     27                logPrintf("PreconfiguredGenetics", "init", LOG_WARN, "Geno converters already configured"); //someone is using multiple PreconfiguredGenetics objects? (or other potentially unsafe configuration)
     28        if (Geno::useValidators(&validators)!=NULL)
     29                logPrintf("PreconfiguredGenetics", "init", LOG_WARN, "Geno validators already configured");
    2930        validators+=&genman; //primary validation: use the extended validity checking (through dedicated genetic operators)
    3031        validators+=&model_validator; //secondary validation: this simple validator handles all cases when there is no dedicated genetic validation operator, but a converter for a particular format is available. Converters may be less strict in detecting invalid genotypes but using them and checking whether they produced a valid f0 genotype is also some way to tell whether the initial genotype was valid. Otherwise, without dedicated genetic validation operator, we would have no validity check at all.
     32        }
     33
     34~PreconfiguredGenetics()
     35        {
     36        Geno::useConverters(NULL);
     37        Geno::useValidators(NULL);
    3138        }
    3239};
Note: See TracChangeset for help on using the changeset viewer.