[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 | |
---|
[855] | 15 | Typical usage: (see loader_test_geno.cpp for the working code) |
---|
| 16 | while(genotype=loader.loadNextGenotype()) doSomethingWith(genotype); |
---|
[109] | 17 | |
---|
[927] | 18 | GenotypeMiniLoader is simply the MultiParamLoader configured to load one kind of data: "org:" objects. |
---|
[635] | 19 | The instance of this class can also be reconfigured to recognize more objects by using MultiParamLoader |
---|
| 20 | methods, or you can use it as a guide for creating your own specialized class. |
---|
| 21 | */ |
---|
[732] | 22 | class GenotypeMiniLoader : public MultiParamLoader |
---|
[109] | 23 | { |
---|
[732] | 24 | GenotypeMini genotype_object; |
---|
[635] | 25 | Param genotype_param; |
---|
| 26 | void init(); |
---|
[109] | 27 | public: |
---|
[732] | 28 | GenotypeMiniLoader(); |
---|
| 29 | GenotypeMiniLoader(VirtFILE *f); |
---|
| 30 | GenotypeMiniLoader(const char* filename); |
---|
[109] | 31 | |
---|
[635] | 32 | /** @returns genotype object if one was loaded or NULL otherwise. |
---|
[109] | 33 | |
---|
[732] | 34 | Returned GenotypeMini pointer always references the the same object (GenotypeMiniLoader::genotype_object) |
---|
[635] | 35 | which means you may need to copy the data from it before calling loadNextGenotype() again. |
---|
[732] | 36 | In the default configuration (simple GenotypeMiniLoader) NULL is always final and should be used |
---|
[635] | 37 | to finish processing. |
---|
[109] | 38 | |
---|
[635] | 39 | If the loader is configured to load other objects or stop on other conditions, NULL will also mean |
---|
| 40 | every condition other than "GenotypeLoaded". In such cases you need MultiParamLoader::getStatus(), |
---|
| 41 | MultiParamLoader::finished() and other methods to determine the real cause of NULL. |
---|
| 42 | */ |
---|
[732] | 43 | GenotypeMini* loadNextGenotype(); |
---|
[109] | 44 | }; |
---|
| 45 | |
---|
| 46 | #endif |
---|