source: cpp/gdk/geno.h @ 70

Last change on this file since 70 was 66, checked in by Maciej Komosinski, 14 years ago

set 'eol-style' to 'native'

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1// This file is a part of the Framsticks GDK library.
2// Copyright (C) 2002-2011  Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#ifndef _GENO_H_
6#define _GENO_H_
7
8#include "sstring.h"
9#include "extvalue.h"
10
11class MultiMap;
12
13/// basic information about a single genotype.
14class Geno: public DestrBase
15{
16SString gen;
17SString name;
18char format;
19SString txt;
20int isvalid; ///< <0 -> unknown   >=0 -> value for "isValid"
21
22Geno *f0gen;
23
24int mapinshift; /// # of characters in the initial comment
25int mapoutshift; /// # of characters in the output comment
26int multiline;
27
28void init(const SString& genstring,int genformat,const SString& genname,const SString& comment);
29void validate(void);
30
31void freeF0();
32
33int isInvalid() {return isvalid==0;}
34
35friend class Model;
36friend class GenoConvManager;
37       
38public:
39/// create a genotype object from primitives
40/// @param genstring pure genotype, without any comments
41/// @param genformat genotype format
42/// @param comment information about genotype (for genetic operators and "history")
43Geno(const char *genstring=0,int genformat=-1,const char *genname=0,const char *comment=0);
44
45/// create a genotype object from primitives
46/// @param genstring pure genotype, wihtout any comments
47/// @param genformat genotype format
48/// @param name genotype name, new name will generated if needed
49/// @param comment information about genotype (for genetic operators and "history")
50Geno(const SString& genstring,int genformat,const SString& genname,const SString& comment);
51
52/// create object from full string, containing optional format and comment information
53Geno(const SString & fullstring);
54
55/// clone
56Geno(const Geno& src);
57
58void operator=(const Geno& src);
59
60~Geno();
61
62void setValid(int v) {isvalid=v;}
63int getValid() {return isvalid;}
64
65/// return string representation, with format comment at the beginning
66SString toString(void);
67SString shortString(void);
68
69void setString(const SString& genewithcomments);
70
71/** @param newformat=-1 -> don't change */
72void setGene(const SString& g, int newformat=-1);
73SString getGene(void) const;
74
75SString getName(void) const;
76void setName(const SString&);
77int getFormat(void) const;
78
79SString getComment(void) const;
80void setComment(const SString&);
81
82/// invalid genotype cannot be used to build a creature
83int isValid(void);
84
85/// make converted version of the genotype.
86Geno getConverted(int otherformat,MultiMap *m=0);
87
88/// @return -1 = before first char in the string
89/// @return -2 = after last char in the string
90int mapGenToString(int genpos) const;
91/// @return -1 = before first char in the genotype
92/// @return -2 = after last char in the genotype
93int mapStringToGen(int stringpos) const;
94
95int operator==(const Geno &g) {return (format==g.format)&&(gen==g.gen);}
96
97void* owner;
98};
99
100#ifndef NO_GENOCONVMANAGER
101#include "genoconv.h"
102#endif
103
104#endif
Note: See TracBrowser for help on using the repository browser.