source: cpp/frams/_demos/genotypeloader.h @ 836

Last change on this file since 836 was 732, checked in by Maciej Komosinski, 19 months ago

Added support for "checkpoints" (intermediate phases of development of the Model when converting between genetic encodings). See Model.checkpoint() and conv_f1.cpp for an example.

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2016  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _GENOTYPELOADER_H_
6#define _GENOTYPELOADER_H_
7
8#include <frams/util/sstring.h>
9#include <frams/param/multiparamload.h>
10#include "genotypemini.h"
11
12/** In most simple cases this is the class you would use to load a series of genotypes from
13        the Framsticks genotype file.
14
15        Usage pattern: (see loader_test_geno.cpp for the working code)
16
17        1.Initialize
18
19        2.while(genotype=loadNextGenotype()) doSomethingWith(genotype);
20
21        3.Done!
22
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        */
27class GenotypeMiniLoader : public MultiParamLoader
28{
29        GenotypeMini genotype_object;
30        Param genotype_param;
31        bool initialized;
32        void init();
33public:
34        GenotypeMiniLoader();
35        GenotypeMiniLoader(VirtFILE *f);
36        GenotypeMiniLoader(const char* filename);
37
38        /** @returns genotype object if one was loaded or NULL otherwise.
39
40                Returned GenotypeMini pointer always references the the same object (GenotypeMiniLoader::genotype_object)
41                which means you may need to copy the data from it before calling loadNextGenotype() again.
42                In the default configuration (simple GenotypeMiniLoader) NULL is always final and should be used
43                to finish processing.
44
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                */
49        GenotypeMini* loadNextGenotype();
50};
51
52#endif
Note: See TracBrowser for help on using the repository browser.