Gen.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008-2011 LpzRobots development team                    *
00003  *    Joerg Weider   <joergweide84 at aol dot com> (robot12)               *
00004  *    Georg Martius  <georg dot martius at web dot de>                     *
00005  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00006  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00007  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00008  *    Joern Hoffmann <jhoffmann at informatik dot uni-leipzig dot de       *
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 
00027 #ifndef GEN_H_
00028 #define GEN_H_
00029 
00030 // standard includes
00031 #include <string>
00032 
00033 // forward declarations
00034 
00035 // gen. alg. includes
00036 #include "IValue.h"
00037 #include "GenPrototype.h"
00038 
00039 /**
00040  * The Gen class.
00041  *
00042  *   This class is used for representing one gen in the gen. alg.
00043  *   It has one ID which make it individual and an name (string)
00044  *   which group it with other gens to a gen pool.
00045  *   Also it has a IValue which is used to save the real value.
00046  *   An IValue can be a number, a matrix, a 3D Modell or something else.
00047  *
00048  *   Places for saving the gen inside the gen. alg. are the GenContext,
00049  *   the Individual and the GenEngine. Deleting only in the GenEngine!
00050  */
00051 class Gen {
00052 public:
00053         /**
00054          * constructor to create a gen. Information which the class need are
00055          * the prototype (name an group of gens) and the id, which the gen
00056          * identified.
00057          *
00058          * @param prototype (GenPrototype*) Pointer to the prototype.
00059          * @param id (int) ID of the gen
00060          */
00061         Gen(GenPrototype* prototype, int id);
00062 
00063         /**
00064          * destructor to delete a gen.
00065          */
00066         virtual ~Gen(void);
00067 
00068         /**
00069          * [const]
00070          * This function gives the Name of this Gen (name of the prototype) back.
00071          *
00072          * @return (string) Name of the Gen.
00073          */
00074         std::string getName(void)const;
00075 
00076         /**
00077          * [inline], [const]
00078          * This function gives the value which is saved in the Gen back.
00079          *
00080          * @return (IValue*) The value
00081          */
00082         inline IValue* getValue(void)const {return m_value;}
00083 
00084         /**
00085          * [inline]
00086          * This function change the saved pointer to the IValue. So the Gen changed his value.
00087          *
00088          * @param value (IVaue*) the new Value
00089          */
00090         inline void setValue(IValue* value) {m_value=value;}
00091 
00092         /**
00093          * [inline], [const]
00094          * This function gives the ID of the Gen back.
00095          *
00096          * @return (int) The ID
00097          */
00098         inline int getID(void)const {return m_ID;}
00099 
00100         /**
00101          * [const]
00102          * This function gives the prototype of the Gen back.
00103          *
00104          * @return (GenPrototyp*) The prototype
00105          */
00106         GenPrototype* getPrototype(void)const;
00107 
00108         /**
00109          *  [const]
00110          *  This function returns a string representation of this Gen.
00111          *
00112          *  @return (string) The Gen in string - Form
00113          */
00114         std::string toString(bool onlyValue = true)const;
00115 
00116         /**
00117          * store the gene in a file
00118          * @param f (FILE*) the file to store
00119          * @return (bool) true if all ok
00120          */
00121         bool store(FILE* f)const;
00122 
00123 protected:
00124         /**
00125          * (IValue*)
00126          * The value of the Gen.
00127          */
00128         IValue* m_value;
00129 
00130         /**
00131          * (GenPrototyp*)
00132          * The prototype of the Gen. After creating unchangeable.
00133          */
00134         GenPrototype* m_prototype;
00135 
00136         /**
00137          * (int)
00138          * The ID of the Gen. The ID is individual. Every Gen has his own.
00139          */
00140         int m_ID;
00141 
00142 private:
00143         /**
00144          * disable default constructor
00145          */
00146         Gen(void);
00147 };
00148 
00149 #endif /* GEN_H_ */
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3