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

Last change on this file since 286 was 286, checked in by Maciej Komosinski, 10 years ago

Updated headers

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2015  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
11/** Helper class, mostly useful with MultiParamLoader
12    or its specialized version: MiniGenotypeLoader.
13    MiniGenotype stores 3 essential fields of the Genotype (name, gene and info)
14 */
15class MiniGenotype
16{
17public:
18SString name,genotype,info;
19void clear() {name=""; genotype=""; info="";}
20};
21
22
23/** Defines the association between "org:" object (found in genotype files)
24    and the MiniGenotype fields. MiniGenotypeLoader uses this definition
25    but you can also use it to make MultiParamLoader load genotype
26 */
27extern ParamEntry minigenotype_paramtab[];
28
29
30/** In most simple cases this is the class you would use to load a series of genotypes from
31    the Framsticks genotype file.
32
33    Usage pattern: (see loadertest.cpp for the working code)
34
35    1.Initialize
36
37    2.while(genotype=loadNextGenotype()) doSomethingWith(genotype);
38
39    3.Done!
40
41    MiniGenotypeLoader is simply the MultiParamLoader configured to load one kind of data: "org:" objects.
42    The instance of this class can also be reconfigured to recognize more objects by using MultiParamLoader
43    methods, or you can use it as a guide for creating your own specialized class.
44 */
45class MiniGenotypeLoader: public MultiParamLoader
46{
47MiniGenotype genotype_object;
48Param genotype_param;
49bool initialized;
50void init();
51public:
52MiniGenotypeLoader();
53MiniGenotypeLoader(VirtFILE *f);
54MiniGenotypeLoader(const char* filename);
55
56/** @returns genotype object if one was loaded or NULL otherwise.
57
58    Returned MiniGenotype pointer always references the the same object (MiniGenotypeLoader::genotype_object)
59    which means you may need to copy the data from it before calling loadNextGenotype() again.
60    In the default configuration (simple MiniGenotypeLoader) NULL is always final and should be used
61    to finish processing.
62
63    If the loader is configured to load other objects or stop on other conditions, NULL will also mean
64    every condition other than "GenotypeLoaded". In such cases you need MultiParamLoader::getStatus(),
65    MultiParamLoader::finished() and other methods to determine the real cause of NULL.
66 */
67MiniGenotype* loadNextGenotype();
68};
69
70#endif
Note: See TracBrowser for help on using the repository browser.