Changeset 1256 for cpp/frams/genetics/genoconv.h
- Timestamp:
- 06/22/23 03:33:58 (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/genoconv.h
r999 r1256 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 0Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2023 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 8 8 #include "geno.h" 9 9 #include <frams/param/param.h> 10 #include <frams/param/paramlist.h> 10 11 #include <frams/util/list.h> 11 12 #include <frams/util/sstring.h> … … 21 22 GenoConvManager *gcm; 22 23 std::vector<std::string> gcnames; //stores names of converters so that these names persist and pointers to these names can be safely used externally 23 char tmp_id[20]; 24 char tmp_id[20]; //id() always returns a pointer to this array, filled with the appropriate field id. The root of the problem is that Param functions return char pointers having unspecified lifetime. In contrast, name() returns individual preallocated pointers for individual items, but apparently, id() was too simple to deserve a better but more tedious implementation. Param api will not change, but what could be improved here is perhaps using ParamObject's dynamic paramtab (which did not exist when GenoConvParam was first implemented) so we don't have to care about individual pointers at all. 24 25 void freetab(); 25 26 public: … … 52 53 virtual SString convert(SString &i, MultiMap *map, bool using_checkpoints) = 0; 53 54 55 /// genoconverter enable/disable fields are named "genoconv_id", where id="f"+input_format+"_f"+output_format by default. 56 /// Converters should implement id() and provide unique value - required when adding more than one converter operating on the same formats. 57 virtual SString id() { return SString("f") + in_format + SString("_f") + out_format; } 58 59 /// Optional user-settable configuration for this converter which automatically gets added to GenoConvParam 60 virtual ParamInterface* getParam() { return NULL; } 61 54 62 virtual ~GenoConverter() {} 55 63 /// Don't forget to set public fields in your constructor … … 57 65 }; 58 66 59 /// This class gathers abilities of all converters and can 60 /// convert a genotype to any other one, provided there is 67 /// This class gathers abilities of all converters and can convert a genotype to any other one, provided there is 61 68 /// a path of GenoConverters between them. 62 /// In most cases you don't use this class directly, 63 /// Geno::getConverted(int) provides full converting functionality. 64 /// Explicit GenoConvManager object is only needed for registering 65 /// your GenoConverter. 69 /// In most cases you don't use this class directly, Geno::getConverted(int) provides full converting functionality. 70 /// Explicit GenoConvManager object is only needed for registering your GenoConverter. 66 71 /// Use DefaultGenoConvManager to register the standard genotype converters automatically. 67 72 class GenoConvManager … … 72 77 GenoConvManager(); 73 78 ~GenoConvManager(); 74 class GenoConvParam param; 79 class GenoConvParam conv_enabling_param; 80 ParamList param; 75 81 /// make a genotype in other format. genotype will be invalid 76 82 /// if GenoConvManager cannot convert it.
Note: See TracChangeset
for help on using the changeset viewer.