Changeset 635 for cpp/frams/_demos/genotypeloader.h
- Timestamp:
- 12/03/16 01:47:15 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/genotypeloader.h
r517 r635 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2016 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 10 10 11 11 /** Defines the association between "org:" object (found in genotype files) 12 13 14 12 and the MiniGenotype fields. MiniGenotypeLoader uses this definition 13 but you can also use it to make MultiParamLoader load genotype 14 */ 15 15 extern ParamEntry minigenotype_paramtab[]; 16 16 17 17 /** Helper class, mostly useful with MultiParamLoader 18 19 20 18 or its specialized version: MiniGenotypeLoader. 19 MiniGenotype stores the subset of Genotype fields (the ones normally saved in .gen files) 20 */ 21 21 class MiniGenotype 22 22 { 23 23 public: 24 SString name,genotype,info,uid; 25 double energy0,lifespan,velocity,distance,vertvel,vertpos; 26 paInt numparts,numjoints,numneurons,numconnections,ordnumber,generation,instances,is_valid; 27 ExtValue user1,user2,user3; 28 void clear() {Param p(minigenotype_paramtab,this); p.setDefault();} 24 SString name, genotype, info, uid; 25 double info_timestamp; 26 SString info_author, info_email; 27 paInt info_author_ispublic, info_email_ispublic, info_origin; 28 SString info_how_created, info_performance; 29 double energy0, lifespan, velocity, distance, vertvel, vertpos; 30 paInt numparts, numjoints, numneurons, numconnections, ordnumber, generation, instances, is_valid; 31 ExtValue user1, user2, user3; 32 void clear() { Param p(minigenotype_paramtab, this); p.setDefault(); } 29 33 }; 30 34 31 35 /** In most simple cases this is the class you would use to load a series of genotypes from 32 36 the Framsticks genotype file. 33 37 34 38 Usage pattern: (see loader_test_geno.cpp for the working code) 35 39 36 40 1.Initialize 37 41 38 42 2.while(genotype=loadNextGenotype()) doSomethingWith(genotype); 39 43 40 44 3.Done! 41 45 42 43 44 45 46 class MiniGenotypeLoader : public MultiParamLoader46 MiniGenotypeLoader is simply the MultiParamLoader configured to load one kind of data: "org:" objects. 47 The instance of this class can also be reconfigured to recognize more objects by using MultiParamLoader 48 methods, or you can use it as a guide for creating your own specialized class. 49 */ 50 class MiniGenotypeLoader : public MultiParamLoader 47 51 { 48 MiniGenotype genotype_object;49 Param genotype_param;50 bool initialized;51 void init();52 MiniGenotype genotype_object; 53 Param genotype_param; 54 bool initialized; 55 void init(); 52 56 public: 53 MiniGenotypeLoader();54 MiniGenotypeLoader(VirtFILE *f);55 MiniGenotypeLoader(const char* filename);57 MiniGenotypeLoader(); 58 MiniGenotypeLoader(VirtFILE *f); 59 MiniGenotypeLoader(const char* filename); 56 60 57 /** @returns genotype object if one was loaded or NULL otherwise.61 /** @returns genotype object if one was loaded or NULL otherwise. 58 62 59 60 61 62 63 Returned MiniGenotype pointer always references the the same object (MiniGenotypeLoader::genotype_object) 64 which means you may need to copy the data from it before calling loadNextGenotype() again. 65 In the default configuration (simple MiniGenotypeLoader) NULL is always final and should be used 66 to finish processing. 63 67 64 65 66 67 68 MiniGenotype* loadNextGenotype();68 If the loader is configured to load other objects or stop on other conditions, NULL will also mean 69 every condition other than "GenotypeLoaded". In such cases you need MultiParamLoader::getStatus(), 70 MultiParamLoader::finished() and other methods to determine the real cause of NULL. 71 */ 72 MiniGenotype* loadNextGenotype(); 69 73 }; 70 74
Note: See TracChangeset
for help on using the changeset viewer.