Changeset 346 for cpp/frams/genetics
- Timestamp:
- 04/07/15 04:20:14 (10 years ago)
- Location:
- cpp/frams/genetics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/geno.cpp
r286 r346 7 7 #include <frams/model/model.h> 8 8 9 SListTempl<GenoValidator*> Geno::validators;10 9 GenoConvManager *Geno::converters = NULL; 10 11 THREAD_LOCAL_DEF(Geno::Validators, geno_validators); 12 13 Geno::Validators& Geno::getValidators() {return tlsGetRef(geno_validators);} 11 14 12 15 void Geno::init(const SString& genstring, char genformat, const SString& genname, const SString& comment) … … 234 237 if (isvalid >= 0) return; 235 238 if (gen.len() == 0) { isvalid = 0; return; } 236 FOREACH(GenoValidator*, v, validators) 239 Validators& vals=getValidators(); 240 FOREACH(GenoValidator*, v, vals) 237 241 if ((isvalid = v->testGenoValidity(*this)) >= 0) 238 242 return; -
cpp/frams/genetics/geno.h
r286 r346 54 54 55 55 public: 56 typedef SListTempl<GenoValidator*> Validators; 57 56 58 /// create a genotype object from primitives 57 59 /// @param genstring pure genotype, without any comments … … 116 118 117 119 // managing global Geno-related objects (used for validation and conversion) 118 static void addValidator(GenoValidator* gv) { validators += gv; } 119 static void removeValidator(GenoValidator* gv) { validators -= gv; } 120 static Validators& getValidators(); 121 static void addValidator(GenoValidator* gv,int at_position=9999) { getValidators().insert(at_position,gv); } 122 static void removeValidator(GenoValidator* gv) { getValidators() -= gv; } 120 123 static void useConverters(GenoConvManager& gcm) { converters = &gcm; } 121 124 static GenoConvManager &getConverters() { return *converters; } 122 125 protected: 123 126 static GenoConvManager *converters; 124 static SListTempl<GenoValidator*> validators;125 127 }; 126 128 -
cpp/frams/genetics/preconfigured.h
r286 r346 30 30 }; 31 31 32 /** Initialization procedure for applications adding their own validators */ 33 class PreconfiguredGenetics_NoValidators 34 { 35 public: 36 DefaultGenoConvManager gcm; 37 38 PreconfiguredGenetics_NoValidators() 39 { 40 gcm.addDefaultConverters(); //without converters, the application would only handle "format 0" genotypes 41 Geno::useConverters(gcm); 42 } 43 }; 44 32 45 #endif 33 46
Note: See TracChangeset
for help on using the changeset viewer.