Changeset 988
- Timestamp:
- 07/09/20 00:13:20 (4 years ago)
- Location:
- cpp/frams
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/genman.cpp
r977 r988 289 289 GenoOperators *gf = getOper_f(format); 290 290 if (gf == NULL) 291 return Geno("", Geno:: INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: Validate(): don't know how to handle genetic format %s", format.c_str()));291 return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: Validate(): don't know how to handle genetic format %s", format.c_str())); 292 292 char *g2 = strdup(geny.getGenes().c_str()); //copy for validation 293 293 int res = gf->validate(g2, geny.getName().c_str()); … … 297 297 return Geno(sg2, format, geny.getName(), geny.getComment()); 298 298 else 299 return Geno("", Geno:: INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: validate() for format %s returned invalid value", format.c_str()));299 return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: validate() for format %s returned invalid value", format.c_str())); 300 300 } 301 301 … … 307 307 GenoOperators *gf = getOper_f(format); 308 308 if (gf == NULL) 309 return Geno("", Geno:: INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: Mutate(): don't know how to handle genetic format %s", format.c_str()));309 return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: Mutate(): don't know how to handle genetic format %s", format.c_str())); 310 310 Geno gv = g; 311 311 bool canvalidate = true; 312 312 if (testValidity(gv, canvalidate) > 0 && canvalidate == false) 313 return Geno("", Geno:: INVALID_FORMAT, "", "GENOPER_OPFAIL: Mutate(): cannot validate invalid source genotype");313 return Geno("", Geno::FORMAT_INVALID, "", "GENOPER_OPFAIL: Mutate(): cannot validate invalid source genotype"); 314 314 bool ok = false; 315 315 int pcount = count; … … 354 354 { 355 355 SString format = g1.getFormat(); 356 if (format != g2.getFormat()) return Geno("", Geno:: INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: CrossOver(): does not work for parents with differing genetic formats (%s and %s)", format.c_str(), g2.getFormat().c_str()));356 if (format != g2.getFormat()) return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: CrossOver(): does not work for parents with differing genetic formats (%s and %s)", format.c_str(), g2.getFormat().c_str())); 357 357 GenoOperators *gf = getOper_f(format); 358 358 if (gf == NULL) 359 return Geno("", Geno:: INVALID_FORMAT, "", SString::sprintf("GENOPER_NOOPER: CrossOver(): no operators found for genetic format %s", format.c_str()));359 return Geno("", Geno::FORMAT_INVALID, "", SString::sprintf("GENOPER_NOOPER: CrossOver(): no operators found for genetic format %s", format.c_str())); 360 360 Geno g1v = g1, g2v = g2; 361 361 … … 364 364 bool canvalidate = true; 365 365 if (testValidity(g1v, canvalidate) > 0 && canvalidate == false) 366 return Geno("", Geno:: INVALID_FORMAT, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #1");366 return Geno("", Geno::FORMAT_INVALID, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #1"); 367 367 canvalidate = true; 368 368 if (testValidity(g2v, canvalidate) > 0 && canvalidate == false) 369 return Geno("", Geno:: INVALID_FORMAT, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #2");369 return Geno("", Geno::FORMAT_INVALID, "", "GENOPER_OPFAIL: CrossOver(): cannot validate invalid source genotype #2"); 370 370 } 371 371 … … 405 405 { 406 406 logPrintf("GenMan", "CrossOver", LOG_WARN, "Tried " GENMAN_REPEAT_FAILED_STR "x and failed: %s and %s", g1.getGenes().c_str(), g2.getGenes().c_str()); 407 return Geno("", Geno:: INVALID_FORMAT, "", "GENOPER_OPFAIL: CrossOver() tried " GENMAN_REPEAT_FAILED_STR "x and failed");407 return Geno("", Geno::FORMAT_INVALID, "", "GENOPER_OPFAIL: CrossOver() tried " GENMAN_REPEAT_FAILED_STR "x and failed"); 408 408 } 409 409 } … … 428 428 { 429 429 SString format = G->getFormat(); 430 if (format == Geno:: INVALID_FORMAT)430 if (format == Geno::FORMAT_INVALID) 431 431 return GENSTYLE_RGBS(64, 64, 64, 0); // gray & "valid" (unknown format so we don't know what is valid and what is not) 432 432 if ((pos = G->mapStringToGen(pos)) == -1) return GENSTYLE_COMMENT; … … 445 445 { 446 446 SString format = G->getFormat(); 447 if (format == Geno:: INVALID_FORMAT)447 if (format == Geno::FORMAT_INVALID) 448 448 { 449 449 for (unsigned int pos = 0; pos < strlen(g); pos++) -
cpp/frams/genetics/geno.cpp
r972 r988 38 38 } 39 39 40 const SString Geno:: INVALID_FORMAT= "invalid";41 const SString Geno:: UNKNOWN_FORMAT= "";40 const SString Geno::FORMAT_INVALID = "invalid"; 41 const SString Geno::FORMAT_UNKNOWN = ""; 42 42 const SString Geno::F0_FORMAT_LIST = "0,0s"; 43 43 … … 68 68 SString format = trim(input); 69 69 if (format.length() == 0 || strContainsOneOf(format.c_str(), " \r\n\t")) 70 return Geno:: INVALID_FORMAT;70 return Geno::FORMAT_INVALID; 71 71 return format; 72 72 } … … 78 78 SString gencopy(genstring); 79 79 SString genformat = in_genformat; 80 if (genformat == UNKNOWN_FORMAT)80 if (genformat == FORMAT_UNKNOWN) 81 81 { // unknown format 82 82 genformat = "1"; … … 118 118 break; 119 119 } 120 if (genformat == INVALID_FORMAT)120 if (genformat == FORMAT_INVALID) 121 121 { 122 122 SString cut; … … 191 191 Geno::Geno(const SString& src) 192 192 { 193 init(src, UNKNOWN_FORMAT, SString::empty(), SString::empty());193 init(src, FORMAT_UNKNOWN, SString::empty(), SString::empty()); 194 194 } 195 195 … … 204 204 { 205 205 freeF0(); 206 init(g, UNKNOWN_FORMAT, SString::empty(), SString::empty());206 init(g, FORMAT_UNKNOWN, SString::empty(), SString::empty()); 207 207 } 208 208 … … 277 277 if (isvalid >= 0) return; 278 278 if (gen.length() == 0) { isvalid = 0; return; } 279 if (format == INVALID_FORMAT) { isvalid = 0; return; }279 if (format == FORMAT_INVALID) { isvalid = 0; return; } 280 280 Validators* vals = getValidators(); 281 281 if (vals != NULL) -
cpp/frams/genetics/geno.h
r972 r988 55 55 56 56 public: 57 static const SString INVALID_FORMAT;58 static const SString UNKNOWN_FORMAT;57 static const SString FORMAT_INVALID; 58 static const SString FORMAT_UNKNOWN; 59 59 typedef SListTempl<GenoValidator*> Validators; 60 60 … … 93 93 94 94 /** @param genformat="" -> detect genotype format from genstring comment (like the constructor does), else specify the valid format in genformat and pure genes in genstring. */ 95 void setGenesAndFormat(const SString& genstring, const SString& genformat = UNKNOWN_FORMAT);95 void setGenesAndFormat(const SString& genstring, const SString& genformat = FORMAT_UNKNOWN); 96 96 /** g must be pure genes, without format. For the standard behavior use setGenesAndFormat() */ 97 97 void setGenesAssumingSameFormat(const SString& g); -
cpp/frams/genetics/genoconv.cpp
r981 r988 107 107 for (; gk = (GenoConverter*)converters(i); i++) 108 108 { 109 if ((in != Geno:: UNKNOWN_FORMAT) && (in != gk->in_format)) continue;110 if ((out != Geno:: UNKNOWN_FORMAT) && (out != gk->out_format)) continue;109 if ((in != Geno::FORMAT_UNKNOWN) && (in != gk->in_format)) continue; 110 if ((out != Geno::FORMAT_UNKNOWN) && (out != gk->out_format)) continue; 111 111 if ((enabled != -1) && (enabled != gk->enabled)) continue; 112 112 if ((name) && (strcmp(name, gk->name))) continue; … … 168 168 { 169 169 if (converter_missing) *converter_missing = false; 170 return Geno("", Geno:: INVALID_FORMAT, "", "Invalid genotype cannot be converted");170 return Geno("", Geno::FORMAT_INVALID, "", "Invalid genotype cannot be converted"); 171 171 } 172 172 int mapavail; … … 176 176 { 177 177 if (converter_missing) *converter_missing = true; 178 return Geno("", Geno:: INVALID_FORMAT, "", "Converter not found");178 return Geno("", Geno::FORMAT_INVALID, "", "Converter not found"); 179 179 } 180 180 if (converter_missing) *converter_missing = false; … … 193 193 { 194 194 string t = ssprintf("f%s->f%s conversion failed (%s)", gk->in_format.c_str(), gk->out_format.c_str(), gk->name); 195 return Geno("", Geno:: INVALID_FORMAT, "", t.c_str());195 return Geno("", Geno::FORMAT_INVALID, "", t.c_str()); 196 196 } 197 197 if (mapavail) -
cpp/frams/genetics/genoconv.h
r972 r988 56 56 virtual ~GenoConverter() {} 57 57 /// Don't forget to set public fields in your constructor 58 GenoConverter() :name(""), in_format(Geno:: UNKNOWN_FORMAT), out_format("0"), enabled(1), mapsupport(0) {}58 GenoConverter() :name(""), in_format(Geno::FORMAT_UNKNOWN), out_format("0"), enabled(1), mapsupport(0) {} 59 59 }; 60 60 … … 87 87 /// pass result=0 if you only need one result (by return value) 88 88 /// default criteria values mean "don't care", pass anything else to narrow your search 89 GenoConverter *findConverters(SListTempl<GenoConverter*>* result = 0, const SString& in = Geno:: UNKNOWN_FORMAT, const SString& out = Geno::UNKNOWN_FORMAT, int enabled = -1, char* name = 0);89 GenoConverter *findConverters(SListTempl<GenoConverter*>* result = 0, const SString& in = Geno::FORMAT_UNKNOWN, const SString& out = Geno::FORMAT_UNKNOWN, int enabled = -1, char* name = 0); 90 90 }; 91 91 -
cpp/frams/model/model.cpp
r975 r988 351 351 return; 352 352 } 353 if (declared_shape == SHAPE_UNKNOWN) 354 declareShapeType(shapeTypeForGenoFormat(f0geno.getFormat())); 353 355 SString f0txt = f0geno.getGenes(); 354 356 buildstatus = building; // was: open(); … … 447 449 if ((buildstatus != valid) && (buildstatus != building)) 448 450 { 449 g = Geno("", Geno:: INVALID_FORMAT, "", "invalid model");451 g = Geno("", Geno::FORMAT_INVALID, "", "invalid model"); 450 452 return; 451 453 } … … 563 565 return "0s"; 564 566 default: 565 return Geno:: INVALID_FORMAT;567 return Geno::FORMAT_INVALID; 566 568 } 567 569 } -
cpp/frams/vm/classes/genoobj.cpp
r972 r988 111 111 return v.getString(); 112 112 } 113 return Geno:: INVALID_FORMAT;113 return Geno::FORMAT_INVALID; 114 114 } 115 115 … … 198 198 SString n = vec->get(1) ? vec->get(1)->getString() : SString::empty(); 199 199 SString c = vec->get(2) ? vec->get(2)->getString() : SString::empty(); 200 *ret = makeDynamicObjectAndDecRef(new Geno(g, Geno:: UNKNOWN_FORMAT, n, c));200 *ret = makeDynamicObjectAndDecRef(new Geno(g, Geno::FORMAT_UNKNOWN, n, c)); 201 201 } 202 202 else
Note: See TracChangeset
for help on using the changeset viewer.