[286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
[635] | 2 | // Copyright (C) 1999-2016 Maciej Komosinski and Szymon Ulatowski. |
---|
[286] | 3 | // See LICENSE.txt for details. |
---|
[109] | 4 | |
---|
| 5 | #ifndef _GENOTYPELOADER_H_ |
---|
| 6 | #define _GENOTYPELOADER_H_ |
---|
| 7 | |
---|
| 8 | #include <frams/util/sstring.h> |
---|
| 9 | #include <frams/param/multiparamload.h> |
---|
[732] | 10 | #include "genotypemini.h" |
---|
[109] | 11 | |
---|
| 12 | /** In most simple cases this is the class you would use to load a series of genotypes from |
---|
[635] | 13 | the Framsticks genotype file. |
---|
[109] | 14 | |
---|
[635] | 15 | Usage pattern: (see loader_test_geno.cpp for the working code) |
---|
[109] | 16 | |
---|
[635] | 17 | 1.Initialize |
---|
[109] | 18 | |
---|
[635] | 19 | 2.while(genotype=loadNextGenotype()) doSomethingWith(genotype); |
---|
[109] | 20 | |
---|
[635] | 21 | 3.Done! |
---|
[109] | 22 | |
---|
[635] | 23 | MiniGenotypeLoader is simply the MultiParamLoader configured to load one kind of data: "org:" objects. |
---|
| 24 | The instance of this class can also be reconfigured to recognize more objects by using MultiParamLoader |
---|
| 25 | methods, or you can use it as a guide for creating your own specialized class. |
---|
| 26 | */ |
---|
[732] | 27 | class GenotypeMiniLoader : public MultiParamLoader |
---|
[109] | 28 | { |
---|
[732] | 29 | GenotypeMini genotype_object; |
---|
[635] | 30 | Param genotype_param; |
---|
| 31 | bool initialized; |
---|
| 32 | void init(); |
---|
[109] | 33 | public: |
---|
[732] | 34 | GenotypeMiniLoader(); |
---|
| 35 | GenotypeMiniLoader(VirtFILE *f); |
---|
| 36 | GenotypeMiniLoader(const char* filename); |
---|
[109] | 37 | |
---|
[635] | 38 | /** @returns genotype object if one was loaded or NULL otherwise. |
---|
[109] | 39 | |
---|
[732] | 40 | Returned GenotypeMini pointer always references the the same object (GenotypeMiniLoader::genotype_object) |
---|
[635] | 41 | which means you may need to copy the data from it before calling loadNextGenotype() again. |
---|
[732] | 42 | In the default configuration (simple GenotypeMiniLoader) NULL is always final and should be used |
---|
[635] | 43 | to finish processing. |
---|
[109] | 44 | |
---|
[635] | 45 | If the loader is configured to load other objects or stop on other conditions, NULL will also mean |
---|
| 46 | every condition other than "GenotypeLoaded". In such cases you need MultiParamLoader::getStatus(), |
---|
| 47 | MultiParamLoader::finished() and other methods to determine the real cause of NULL. |
---|
| 48 | */ |
---|
[732] | 49 | GenotypeMini* loadNextGenotype(); |
---|
[109] | 50 | }; |
---|
| 51 | |
---|
| 52 | #endif |
---|