Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Gen.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2008-2011 LpzRobots development team *
3  * Joerg Weider <joergweide84 at aol dot com> (robot12) *
4  * Georg Martius <georg dot martius at web dot de> *
5  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
6  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
7  * Ralf Der <ralfder at mis dot mpg dot de> *
8  * Joern Hoffmann <jhoffmann at informatik dot uni-leipzig dot de *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24  * *
25  ***************************************************************************/
26 
27 #ifndef GEN_H_
28 #define GEN_H_
29 
30 // standard includes
31 #include <string>
32 
33 // forward declarations
34 
35 // gen. alg. includes
36 #include "IValue.h"
37 #include "GenPrototype.h"
38 
39 /**
40  * The Gen class.
41  *
42  * This class is used for representing one gen in the gen. alg.
43  * It has one ID which make it individual and an name (string)
44  * which group it with other gens to a gen pool.
45  * Also it has a IValue which is used to save the real value.
46  * An IValue can be a number, a matrix, a 3D Modell or something else.
47  *
48  * Places for saving the gen inside the gen. alg. are the GenContext,
49  * the Individual and the GenEngine. Deleting only in the GenEngine!
50  */
51 class Gen {
52 public:
53  /**
54  * constructor to create a gen. Information which the class need are
55  * the prototype (name an group of gens) and the id, which the gen
56  * identified.
57  *
58  * @param prototype (GenPrototype*) Pointer to the prototype.
59  * @param id (int) ID of the gen
60  */
61  Gen(GenPrototype* prototype, int id);
62 
63  /**
64  * destructor to delete a gen.
65  */
66  virtual ~Gen(void);
67 
68  /**
69  * [const]
70  * This function gives the Name of this Gen (name of the prototype) back.
71  *
72  * @return (string) Name of the Gen.
73  */
74  std::string getName(void)const;
75 
76  /**
77  * [inline], [const]
78  * This function gives the value which is saved in the Gen back.
79  *
80  * @return (IValue*) The value
81  */
82  inline IValue* getValue(void)const {return m_value;}
83 
84  /**
85  * [inline]
86  * This function change the saved pointer to the IValue. So the Gen changed his value.
87  *
88  * @param value (IVaue*) the new Value
89  */
90  inline void setValue(IValue* value) {m_value=value;}
91 
92  /**
93  * [inline], [const]
94  * This function gives the ID of the Gen back.
95  *
96  * @return (int) The ID
97  */
98  inline int getID(void)const {return m_ID;}
99 
100  /**
101  * [const]
102  * This function gives the prototype of the Gen back.
103  *
104  * @return (GenPrototyp*) The prototype
105  */
106  GenPrototype* getPrototype(void)const;
107 
108  /**
109  * [const]
110  * This function returns a string representation of this Gen.
111  *
112  * @return (string) The Gen in string - Form
113  */
114  std::string toString(bool onlyValue = true)const;
115 
116  /**
117  * store the gene in a file
118  * @param f (FILE*) the file to store
119  * @return (bool) true if all ok
120  */
121  bool store(FILE* f)const;
122 
123 protected:
124  /**
125  * (IValue*)
126  * The value of the Gen.
127  */
129 
130  /**
131  * (GenPrototyp*)
132  * The prototype of the Gen. After creating unchangeable.
133  */
135 
136  /**
137  * (int)
138  * The ID of the Gen. The ID is individual. Every Gen has his own.
139  */
140  int m_ID;
141 
142 private:
143  /**
144  * disable default constructor
145  */
146  Gen(void);
147 };
148 
149 #endif /* GEN_H_ */
GenPrototype * m_prototype
(GenPrototyp*) The prototype of the Gen.
Definition: Gen.h:134
The Gen class.
Definition: Gen.h:51
virtual ~Gen(void)
destructor to delete a gen.
Definition: Gen.cpp:40
The GenPrototype class.
Definition: GenPrototype.h:55
IValue * m_value
(IValue*) The value of the Gen.
Definition: Gen.h:128
void setValue(IValue *value)
[inline] This function change the saved pointer to the IValue.
Definition: Gen.h:90
int m_ID
(int) The ID of the Gen.
Definition: Gen.h:140
std::string toString(bool onlyValue=true) const
[const] This function returns a string representation of this Gen.
Definition: Gen.cpp:53
This class is a interface for a value which is part of a gen.
Definition: IValue.h:38
IValue * getValue(void) const
[inline], [const] This function gives the value which is saved in the Gen back.
Definition: Gen.h:82
int getID(void) const
[inline], [const] This function gives the ID of the Gen back.
Definition: Gen.h:98
bool store(FILE *f) const
store the gene in a file
Definition: Gen.cpp:69
std::string getName(void) const
[const] This function gives the Name of this Gen (name of the prototype) back.
Definition: Gen.cpp:45
GenPrototype * getPrototype(void) const
[const] This function gives the prototype of the Gen back.
Definition: Gen.cpp:49