The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cIndividual.h
Go to the documentation of this file.
1 /**
2  * @file cIndividual
3  * file name: cIndividual.h
4  * @author Betti Oesterholz
5  * @date 28.02.2010
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This header specifies a class for a individal.
11  * Copyright (C) @c GPL3 2010 Betti Oesterholz
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License (GPL) as
15  * published by the Free Software Foundation, either version 3 of the
16  * License, or any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25  *
26  *
27  * This header specifies a class for a individals.
28  * An individal is an central object on which the genetic algorithm
29  * (enviroment) works.
30  *
31  * @see cEnviroment
32  *
33  */
34 /*
35 History:
36 28.02.2010 Oesterholz created
37 */
38 
39 #ifndef ___C_INDIVIDUAL_H__
40 #define ___C_INDIVIDUAL_H__
41 
42 #include "version.h"
43 
44 #include "cIndividualInfo.h"
45 
46 
47 namespace enviroment{
48 
49 
51 
52 friend class cEnviroment;
53 
54 protected:
55 
56  /**
57  * The object which is represented by the individual.
58  */
59  void * pObject;
60 
61  /**
62  * the information for the individual
63  */
65 
66  /**
67  * the information for the individual
68  */
70 
71 public:
72 
73  /**
74  * constructor
75  *
76  * @param pInObject the object which is represented by the individual;
77  * this object won't be copied but destructed when the individual is
78  * destructed if bInDeleteObjectOnDestruction is true
79  * @param inIndividalInfo the information for the individual
80  * @param bInDeleteObjectOnDestruction if true delete the object
81  * (pInObject) when the individual is deleted
82  */
83  cIndividual( void * pInObject, const cIndividualInfo & inIndividalInfo,
84  bool bInDeleteObjectOnDestruction=true );
85 
86  /**
87  * copyconstructor
88  * Beware: it down't copy the contained object
89  *
90  * @param individual the individual to copy
91  */
92  cIndividual( const cIndividual & individual );
93 
94  /**
95  * destructor
96  * It deletes the objekt to the individual.
97  */
98  virtual ~cIndividual();
99 
100  /**
101  * @return a pointer to the object which is represented by the individual
102  */
103  virtual void * getObject();
104 
105  /**
106  * @return a pointer to the object which is represented by the individual
107  */
108  virtual const void * getObject() const;
109 
110  /**
111  * @return a pointer to the information for the individual
112  */
114 
115  /**
116  * @return a pointer to the information for the individual
117  */
118  const cIndividualInfo * getInfo() const;
119 
120  /**
121  * This method updates the fitness of the individual.
122  *
123  * @see getFitness()
124  * @param pInFitnessAlgorithm the fitnessalgorithm with which to update
125  * the fitness, if NULL it will be tryed to use an existing fitnessalgorithm
126  * @param pBestObjectFitness if given, the fitness of the best individual
127  * at creation time (else NULL)
128  * @see cIndividualInfo::pFitnessOfBestAtCreationTime
129  * @return true if the fitness was changed, else false
130  */
131  bool updateFitness( const cObjectFitnessAlgorithm * pInFitnessAlgorithm = NULL,
132  const cObjectFitness * pBestObjectFitness = NULL );
133 
134  /**
135  * Comparisson on equal method for two cIndividual objects.
136  *
137  * @param individual the cIndividual to compare this
138  * idIndividualobject to
139  * @param checkIdentifiers if true (standradvalue) the identifiers will
140  * be checked also, else not
141  * @return true if the cIndividual this object represents is
142  * equal to the cIndividual the given object individual
143  * represents
144  */
145  virtual bool equal( const cIndividual &individual, bool checkIdentifiers=true ) const;
146 
147  /**
148  * Comparisson on equal operator for two cIndividual objects.
149  *
150  * @param individual the cIndividual to compare this
151  * idIndividualobject to
152  * @return true if the cIndividual this object represents is
153  * equal to the cIndividual the given object individual
154  * represents
155  */
156  bool operator==( const cIndividual &individual ) const;
157 
158  /**
159  * Comparisson on not equal operator for two cIndividual objects.
160  *
161  * @param individual the cIndividual to compare this
162  * idIndividualobject to
163  * @param checkIdentifiers if true (standradvalue) the identifiers will
164  * be checked allso, else not
165  * @return true if the cIndividual this object represents is
166  * not equal to the cIndividual the given object individual
167  * represents
168  */
169  bool operator!=( const cIndividual &individual ) const;
170 
171  /**
172  * @return the name of this class
173  */
174  virtual string getClassName() const;
175 
176  /**
177  * This method clones this individual inclusive the containing object.
178  *
179  * @return a clone of this object
180  */
181  virtual cIndividual * clone() const;
182 
183  /**
184  * This method clones this individual inclusive the containing object.
185  * Beware: You have to overwrite this method in every direct child class.
186  *
187  * @return a clone of this object
188  * @param bCloneObject if true the object will be cloned and
189  * @see bInDeleteObjectOnDestruction will be set to true, if false
190  * the object won't be cloned and @see bInDeleteObjectOnDestruction
191  * will be set to false
192  */
193  virtual cIndividual * clone( bool bCloneObject ) const;
194 
195 
196 #ifndef TEST
197 protected:
198 #endif
199  /**
200  * This method kills the individual, so it isn't living anymor.
201  *
202  * @see cIndividualInfo::isLiving()
203  * @see cIndividualInfo::bIsLiving
204  * @return true if the individal was killed, else false
205  */
206  virtual bool kill();
207 
208 };//end class cIndividual
209 
210 
211 };//end namespace enviroment
212 
213 #endif //___C_INDIVIDUAL_H__
214 
215 
216 
217 
218 
219 
220