Gen.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2009 by Robot Group Leipzig                        *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *    guettler@informatik.uni-leipzig.de                                   *
00007  *    jhoffmann@informatik.uni-leipzig.de                                  *
00008  *    joergweide84@aol.com (robot12)                                       *
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  *   This program is distributed in the hope that it will be useful,       *
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00018  *   GNU General Public License for more details.                          *
00019  *                                                                         *
00020  *   You should have received a copy of the GNU General Public License     *
00021  *   along with this program; if not, write to the                         *
00022  *   Free Software Foundation, Inc.,                                       *
00023  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00024  ***************************************************************************
00025  *                                                                         *
00026  *   This class is used for representing one gen in the gen. alg.          *
00027  *   It has one ID which make it individual and a name (string)            *
00028  *   which group it with other gens to a gen pool.                         *
00029  *   Also it has a IValue which is used to save the real value.            *
00030  *   An IValue can be a number, a matrix, a 3D Modell or something else.   *
00031  *                                                                         *
00032  *   Places for saving the gen inside the gen. alg. are the GenContext,    *
00033  *   the Individual and the GenEngine. Deleting only in the GenEngine!     *
00034  *                                                                         *
00035  *   $Log: Gen.h,v $
00036  *   Revision 1.8  2009/10/21 14:08:06  robot12
00037  *   add restore and store functions to the ga package
00038  *
00039  *   Revision 1.7  2009/07/21 08:37:59  robot12
00040  *   add some comments
00041  *
00042  *   Revision 1.6  2009/05/12 13:29:25  robot12
00043  *   some new function
00044  *   -> toString methodes
00045  *
00046  *   Revision 1.5  2009/05/07 14:47:47  robot12
00047  *   some comments
00048  *
00049  *   Revision 1.4  2009/05/04 15:27:56  robot12
00050  *   rename of some files and moving files to other positions
00051  *    - SingletonGenAlgAPI has one error!!! --> is not ready now
00052  *
00053  *   Revision 1.6  2009/04/30 11:35:53  robot12
00054  *   some changes:
00055  *    - insert a SelectStrategie
00056  *    - insert a MutationStrategie
00057  *    - reorganisation of the design
00058  *
00059  *   Revision 1.5  2009/04/27 10:59:33  robot12
00060  *   some implements
00061  *
00062  *
00063  ***************************************************************************/
00064 
00065 #ifndef GEN_H_
00066 #define GEN_H_
00067 
00068 // standard includes
00069 #include <string>
00070 
00071 // forward declarations
00072 
00073 // gen. alg. includes
00074 #include "IValue.h"
00075 #include "GenPrototype.h"
00076 
00077 /**
00078  * The Gen class.
00079  *
00080  *   This class is used for representing one gen in the gen. alg.
00081  *   It has one ID which make it individual and an name (string)
00082  *   which group it with other gens to a gen pool.
00083  *   Also it has a IValue which is used to save the real value.
00084  *   An IValue can be a number, a matrix, a 3D Modell or something else.
00085  *
00086  *   Places for saving the gen inside the gen. alg. are the GenContext,
00087  *   the Individual and the GenEngine. Deleting only in the GenEngine!
00088  */
00089 class Gen {
00090 public:
00091         /**
00092          * constructor to create a gen. Information which the class need are
00093          * the prototype (name an group of gens) and the id, which the gen
00094          * identified.
00095          *
00096          * @param prototype (GenPrototype*) Pointer to the prototype.
00097          * @param id (int) ID of the gen
00098          */
00099         Gen(GenPrototype* prototype, int id);
00100 
00101         /**
00102          * destructor to delete a gen.
00103          */
00104         virtual ~Gen(void);
00105 
00106         /**
00107          * [const]
00108          * This function gives the Name of this Gen (name of the prototype) back.
00109          *
00110          * @return (string) Name of the Gen.
00111          */
00112         std::string getName(void)const;
00113 
00114         /**
00115          * [inline], [const]
00116          * This function gives the value which is saved in the Gen back.
00117          *
00118          * @return (IValue*) The value
00119          */
00120         inline IValue* getValue(void)const {return m_value;}
00121 
00122         /**
00123          * [inline]
00124          * This function change the saved pointer to the IValue. So the Gen changed his value.
00125          *
00126          * @param value (IVaue*) the new Value
00127          */
00128         inline void setValue(IValue* value) {m_value=value;}
00129 
00130         /**
00131          * [inline], [const]
00132          * This function gives the ID of the Gen back.
00133          *
00134          * @return (int) The ID
00135          */
00136         inline int getID(void)const {return m_ID;}
00137 
00138         /**
00139          * [const]
00140          * This function gives the prototype of the Gen back.
00141          *
00142          * @return (GenPrototyp*) The prototype
00143          */
00144         GenPrototype* getPrototype(void)const;
00145 
00146         /**
00147          *  [const]
00148          *  This function returns a string representation of this Gen.
00149          *
00150          *  @return (string) The Gen in string - Form
00151          */
00152         std::string toString(bool onlyValue = true)const;
00153 
00154         /**
00155          * store the gene in a file
00156          * @param f (FILE*) the file to store
00157          * @return (bool) true if all ok
00158          */
00159         bool store(FILE* f)const;
00160 
00161 protected:
00162         /**
00163          * (IValue*)
00164          * The value of the Gen.
00165          */
00166         IValue* m_value;
00167 
00168         /**
00169          * (GenPrototyp*)
00170          * The prototype of the Gen. After creating unchangeable.
00171          */
00172         GenPrototype* m_prototype;
00173 
00174         /**
00175          * (int)
00176          * The ID of the Gen. The ID is individual. Every Gen has his own.
00177          */
00178         int m_ID;
00179 
00180 private:
00181         /**
00182          * disable default constructor
00183          */
00184         Gen(void);
00185 };
00186 
00187 #endif /* GEN_H_ */

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7